Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: compress: fix the struct alignment to 4 bytes

In 64bit systems the compiler can default align to 8bytes causing mis-match with
32bit usermode. Avoid this is future by ensuring all the structures shared with
usermode are packed and aligned to 4 bytes irrespective of arch used

[coding style fixes by tiwai]

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Vinod Koul and committed by
Takashi Iwai
2da38e0c 8d42fda9

+14 -14
+7 -7
include/uapi/sound/compress_offload.h
··· 39 39 struct snd_compressed_buffer { 40 40 __u32 fragment_size; 41 41 __u32 fragments; 42 - }; 42 + } __attribute__((packed, aligned(4))); 43 43 44 44 /** 45 45 * struct snd_compr_params: compressed stream params ··· 51 51 struct snd_compressed_buffer buffer; 52 52 struct snd_codec codec; 53 53 __u8 no_wake_mode; 54 - }; 54 + } __attribute__((packed, aligned(4))); 55 55 56 56 /** 57 57 * struct snd_compr_tstamp: timestamp descriptor ··· 70 70 __u32 pcm_frames; 71 71 __u32 pcm_io_frames; 72 72 __u32 sampling_rate; 73 - }; 73 + } __attribute__((packed, aligned(4))); 74 74 75 75 /** 76 76 * struct snd_compr_avail: avail descriptor ··· 80 80 struct snd_compr_avail { 81 81 __u64 avail; 82 82 struct snd_compr_tstamp tstamp; 83 - } __attribute__((packed)); 83 + } __attribute__((packed, aligned(4))); 84 84 85 85 enum snd_compr_direction { 86 86 SND_COMPRESS_PLAYBACK = 0, ··· 107 107 __u32 max_fragments; 108 108 __u32 codecs[MAX_NUM_CODECS]; 109 109 __u32 reserved[11]; 110 - }; 110 + } __attribute__((packed, aligned(4))); 111 111 112 112 /** 113 113 * struct snd_compr_codec_caps: query capability of codec ··· 119 119 __u32 codec; 120 120 __u32 num_descriptors; 121 121 struct snd_codec_desc descriptor[MAX_NUM_CODEC_DESCRIPTORS]; 122 - }; 122 + } __attribute__((packed, aligned(4))); 123 123 124 124 /** 125 125 * @SNDRV_COMPRESS_ENCODER_PADDING: no of samples appended by the encoder at the ··· 140 140 struct snd_compr_metadata { 141 141 __u32 key; 142 142 __u32 value[8]; 143 - }; 143 + } __attribute__((packed, aligned(4))); 144 144 145 145 /** 146 146 * compress path ioctl definitions
+7 -7
include/uapi/sound/compress_params.h
··· 268 268 __u32 max_bit_rate; 269 269 __u32 min_bit_rate; 270 270 __u32 downmix; 271 - }; 271 + } __attribute__((packed, aligned(4))); 272 272 273 273 274 274 /** ··· 284 284 __u32 quant_bits; 285 285 __u32 start_region; 286 286 __u32 num_regions; 287 - }; 287 + } __attribute__((packed, aligned(4))); 288 288 289 289 /** 290 290 * struct snd_enc_flac ··· 308 308 struct snd_enc_flac { 309 309 __u32 num; 310 310 __u32 gain; 311 - }; 311 + } __attribute__((packed, aligned(4))); 312 312 313 313 struct snd_enc_generic { 314 314 __u32 bw; /* encoder bandwidth */ 315 315 __s32 reserved[15]; 316 - }; 316 + } __attribute__((packed, aligned(4))); 317 317 318 318 union snd_codec_options { 319 319 struct snd_enc_wma wma; ··· 321 321 struct snd_enc_real real; 322 322 struct snd_enc_flac flac; 323 323 struct snd_enc_generic generic; 324 - }; 324 + } __attribute__((packed, aligned(4))); 325 325 326 326 /** struct snd_codec_desc - description of codec capabilities 327 327 * @max_ch: Maximum number of audio channels ··· 358 358 __u32 formats; 359 359 __u32 min_buffer; 360 360 __u32 reserved[15]; 361 - }; 361 + } __attribute__((packed, aligned(4))); 362 362 363 363 /** struct snd_codec 364 364 * @id: Identifies the supported audio encoder/decoder. ··· 399 399 __u32 align; 400 400 union snd_codec_options options; 401 401 __u32 reserved[3]; 402 - }; 402 + } __attribute__((packed, aligned(4))); 403 403 404 404 #endif