Skip to content

Commit fea952e

Browse files
cladischtiwai
authored andcommitted
ALSA: core: sparse cleanups
Change the core code where sparse complains. In most cases, this means just adding annotations to confirm that we indeed want to do the dirty things we're doing. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 88b27fd commit fea952e

18 files changed

Lines changed: 160 additions & 137 deletions

‎include/sound/mixer_oss.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ struct snd_mixer_oss_file {
7373
struct snd_mixer_oss *mixer;
7474
};
7575

76+
int snd_mixer_oss_ioctl_card(struct snd_card *card,
77+
unsigned int cmd, unsigned long arg);
78+
7679
#endif /* CONFIG_SND_MIXER_OSS */
7780

7881
#endif /* __SOUND_MIXER_OSS_H */

‎include/sound/pcm.h‎

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -136,48 +136,49 @@ struct snd_pcm_ops {
136136
SNDRV_PCM_RATE_88200|SNDRV_PCM_RATE_96000)
137137
#define SNDRV_PCM_RATE_8000_192000 (SNDRV_PCM_RATE_8000_96000|SNDRV_PCM_RATE_176400|\
138138
SNDRV_PCM_RATE_192000)
139-
#define SNDRV_PCM_FMTBIT_S8 (1ULL << SNDRV_PCM_FORMAT_S8)
140-
#define SNDRV_PCM_FMTBIT_U8 (1ULL << SNDRV_PCM_FORMAT_U8)
141-
#define SNDRV_PCM_FMTBIT_S16_LE (1ULL << SNDRV_PCM_FORMAT_S16_LE)
142-
#define SNDRV_PCM_FMTBIT_S16_BE (1ULL << SNDRV_PCM_FORMAT_S16_BE)
143-
#define SNDRV_PCM_FMTBIT_U16_LE (1ULL << SNDRV_PCM_FORMAT_U16_LE)
144-
#define SNDRV_PCM_FMTBIT_U16_BE (1ULL << SNDRV_PCM_FORMAT_U16_BE)
145-
#define SNDRV_PCM_FMTBIT_S24_LE (1ULL << SNDRV_PCM_FORMAT_S24_LE)
146-
#define SNDRV_PCM_FMTBIT_S24_BE (1ULL << SNDRV_PCM_FORMAT_S24_BE)
147-
#define SNDRV_PCM_FMTBIT_U24_LE (1ULL << SNDRV_PCM_FORMAT_U24_LE)
148-
#define SNDRV_PCM_FMTBIT_U24_BE (1ULL << SNDRV_PCM_FORMAT_U24_BE)
149-
#define SNDRV_PCM_FMTBIT_S32_LE (1ULL << SNDRV_PCM_FORMAT_S32_LE)
150-
#define SNDRV_PCM_FMTBIT_S32_BE (1ULL << SNDRV_PCM_FORMAT_S32_BE)
151-
#define SNDRV_PCM_FMTBIT_U32_LE (1ULL << SNDRV_PCM_FORMAT_U32_LE)
152-
#define SNDRV_PCM_FMTBIT_U32_BE (1ULL << SNDRV_PCM_FORMAT_U32_BE)
153-
#define SNDRV_PCM_FMTBIT_FLOAT_LE (1ULL << SNDRV_PCM_FORMAT_FLOAT_LE)
154-
#define SNDRV_PCM_FMTBIT_FLOAT_BE (1ULL << SNDRV_PCM_FORMAT_FLOAT_BE)
155-
#define SNDRV_PCM_FMTBIT_FLOAT64_LE (1ULL << SNDRV_PCM_FORMAT_FLOAT64_LE)
156-
#define SNDRV_PCM_FMTBIT_FLOAT64_BE (1ULL << SNDRV_PCM_FORMAT_FLOAT64_BE)
157-
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE (1ULL << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE)
158-
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE (1ULL << SNDRV_PCM_FORMAT_IEC958_SUBFRAME_BE)
159-
#define SNDRV_PCM_FMTBIT_MU_LAW (1ULL << SNDRV_PCM_FORMAT_MU_LAW)
160-
#define SNDRV_PCM_FMTBIT_A_LAW (1ULL << SNDRV_PCM_FORMAT_A_LAW)
161-
#define SNDRV_PCM_FMTBIT_IMA_ADPCM (1ULL << SNDRV_PCM_FORMAT_IMA_ADPCM)
162-
#define SNDRV_PCM_FMTBIT_MPEG (1ULL << SNDRV_PCM_FORMAT_MPEG)
163-
#define SNDRV_PCM_FMTBIT_GSM (1ULL << SNDRV_PCM_FORMAT_GSM)
164-
#define SNDRV_PCM_FMTBIT_SPECIAL (1ULL << SNDRV_PCM_FORMAT_SPECIAL)
165-
#define SNDRV_PCM_FMTBIT_S24_3LE (1ULL << SNDRV_PCM_FORMAT_S24_3LE)
166-
#define SNDRV_PCM_FMTBIT_U24_3LE (1ULL << SNDRV_PCM_FORMAT_U24_3LE)
167-
#define SNDRV_PCM_FMTBIT_S24_3BE (1ULL << SNDRV_PCM_FORMAT_S24_3BE)
168-
#define SNDRV_PCM_FMTBIT_U24_3BE (1ULL << SNDRV_PCM_FORMAT_U24_3BE)
169-
#define SNDRV_PCM_FMTBIT_S20_3LE (1ULL << SNDRV_PCM_FORMAT_S20_3LE)
170-
#define SNDRV_PCM_FMTBIT_U20_3LE (1ULL << SNDRV_PCM_FORMAT_U20_3LE)
171-
#define SNDRV_PCM_FMTBIT_S20_3BE (1ULL << SNDRV_PCM_FORMAT_S20_3BE)
172-
#define SNDRV_PCM_FMTBIT_U20_3BE (1ULL << SNDRV_PCM_FORMAT_U20_3BE)
173-
#define SNDRV_PCM_FMTBIT_S18_3LE (1ULL << SNDRV_PCM_FORMAT_S18_3LE)
174-
#define SNDRV_PCM_FMTBIT_U18_3LE (1ULL << SNDRV_PCM_FORMAT_U18_3LE)
175-
#define SNDRV_PCM_FMTBIT_S18_3BE (1ULL << SNDRV_PCM_FORMAT_S18_3BE)
176-
#define SNDRV_PCM_FMTBIT_U18_3BE (1ULL << SNDRV_PCM_FORMAT_U18_3BE)
177-
#define SNDRV_PCM_FMTBIT_G723_24 (1ULL << SNDRV_PCM_FORMAT_G723_24)
178-
#define SNDRV_PCM_FMTBIT_G723_24_1B (1ULL << SNDRV_PCM_FORMAT_G723_24_1B)
179-
#define SNDRV_PCM_FMTBIT_G723_40 (1ULL << SNDRV_PCM_FORMAT_G723_40)
180-
#define SNDRV_PCM_FMTBIT_G723_40_1B (1ULL << SNDRV_PCM_FORMAT_G723_40_1B)
139+
#define _SNDRV_PCM_FMTBIT(fmt) (1ULL << (__force int)SNDRV_PCM_FORMAT_##fmt)
140+
#define SNDRV_PCM_FMTBIT_S8 _SNDRV_PCM_FMTBIT(S8)
141+
#define SNDRV_PCM_FMTBIT_U8 _SNDRV_PCM_FMTBIT(U8)
142+
#define SNDRV_PCM_FMTBIT_S16_LE _SNDRV_PCM_FMTBIT(S16_LE)
143+
#define SNDRV_PCM_FMTBIT_S16_BE _SNDRV_PCM_FMTBIT(S16_BE)
144+
#define SNDRV_PCM_FMTBIT_U16_LE _SNDRV_PCM_FMTBIT(U16_LE)
145+
#define SNDRV_PCM_FMTBIT_U16_BE _SNDRV_PCM_FMTBIT(U16_BE)
146+
#define SNDRV_PCM_FMTBIT_S24_LE _SNDRV_PCM_FMTBIT(S24_LE)
147+
#define SNDRV_PCM_FMTBIT_S24_BE _SNDRV_PCM_FMTBIT(S24_BE)
148+
#define SNDRV_PCM_FMTBIT_U24_LE _SNDRV_PCM_FMTBIT(U24_LE)
149+
#define SNDRV_PCM_FMTBIT_U24_BE _SNDRV_PCM_FMTBIT(U24_BE)
150+
#define SNDRV_PCM_FMTBIT_S32_LE _SNDRV_PCM_FMTBIT(S32_LE)
151+
#define SNDRV_PCM_FMTBIT_S32_BE _SNDRV_PCM_FMTBIT(S32_BE)
152+
#define SNDRV_PCM_FMTBIT_U32_LE _SNDRV_PCM_FMTBIT(U32_LE)
153+
#define SNDRV_PCM_FMTBIT_U32_BE _SNDRV_PCM_FMTBIT(U32_BE)
154+
#define SNDRV_PCM_FMTBIT_FLOAT_LE _SNDRV_PCM_FMTBIT(FLOAT_LE)
155+
#define SNDRV_PCM_FMTBIT_FLOAT_BE _SNDRV_PCM_FMTBIT(FLOAT_BE)
156+
#define SNDRV_PCM_FMTBIT_FLOAT64_LE _SNDRV_PCM_FMTBIT(FLOAT64_LE)
157+
#define SNDRV_PCM_FMTBIT_FLOAT64_BE _SNDRV_PCM_FMTBIT(FLOAT64_BE)
158+
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_LE)
159+
#define SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE _SNDRV_PCM_FMTBIT(IEC958_SUBFRAME_BE)
160+
#define SNDRV_PCM_FMTBIT_MU_LAW _SNDRV_PCM_FMTBIT(MU_LAW)
161+
#define SNDRV_PCM_FMTBIT_A_LAW _SNDRV_PCM_FMTBIT(A_LAW)
162+
#define SNDRV_PCM_FMTBIT_IMA_ADPCM _SNDRV_PCM_FMTBIT(IMA_ADPCM)
163+
#define SNDRV_PCM_FMTBIT_MPEG _SNDRV_PCM_FMTBIT(MPEG)
164+
#define SNDRV_PCM_FMTBIT_GSM _SNDRV_PCM_FMTBIT(GSM)
165+
#define SNDRV_PCM_FMTBIT_SPECIAL _SNDRV_PCM_FMTBIT(SPECIAL)
166+
#define SNDRV_PCM_FMTBIT_S24_3LE _SNDRV_PCM_FMTBIT(S24_3LE)
167+
#define SNDRV_PCM_FMTBIT_U24_3LE _SNDRV_PCM_FMTBIT(U24_3LE)
168+
#define SNDRV_PCM_FMTBIT_S24_3BE _SNDRV_PCM_FMTBIT(S24_3BE)
169+
#define SNDRV_PCM_FMTBIT_U24_3BE _SNDRV_PCM_FMTBIT(U24_3BE)
170+
#define SNDRV_PCM_FMTBIT_S20_3LE _SNDRV_PCM_FMTBIT(S20_3LE)
171+
#define SNDRV_PCM_FMTBIT_U20_3LE _SNDRV_PCM_FMTBIT(U20_3LE)
172+
#define SNDRV_PCM_FMTBIT_S20_3BE _SNDRV_PCM_FMTBIT(S20_3BE)
173+
#define SNDRV_PCM_FMTBIT_U20_3BE _SNDRV_PCM_FMTBIT(U20_3BE)
174+
#define SNDRV_PCM_FMTBIT_S18_3LE _SNDRV_PCM_FMTBIT(S18_3LE)
175+
#define SNDRV_PCM_FMTBIT_U18_3LE _SNDRV_PCM_FMTBIT(U18_3LE)
176+
#define SNDRV_PCM_FMTBIT_S18_3BE _SNDRV_PCM_FMTBIT(S18_3BE)
177+
#define SNDRV_PCM_FMTBIT_U18_3BE _SNDRV_PCM_FMTBIT(U18_3BE)
178+
#define SNDRV_PCM_FMTBIT_G723_24 _SNDRV_PCM_FMTBIT(G723_24)
179+
#define SNDRV_PCM_FMTBIT_G723_24_1B _SNDRV_PCM_FMTBIT(G723_24_1B)
180+
#define SNDRV_PCM_FMTBIT_G723_40 _SNDRV_PCM_FMTBIT(G723_40)
181+
#define SNDRV_PCM_FMTBIT_G723_40_1B _SNDRV_PCM_FMTBIT(G723_40_1B)
181182

182183
#ifdef SNDRV_LITTLE_ENDIAN
183184
#define SNDRV_PCM_FMTBIT_S16 SNDRV_PCM_FMTBIT_S16_LE
@@ -490,7 +491,7 @@ int snd_pcm_info_user(struct snd_pcm_substream *substream,
490491
int snd_pcm_status(struct snd_pcm_substream *substream,
491492
struct snd_pcm_status *status);
492493
int snd_pcm_start(struct snd_pcm_substream *substream);
493-
int snd_pcm_stop(struct snd_pcm_substream *substream, int status);
494+
int snd_pcm_stop(struct snd_pcm_substream *substream, snd_pcm_state_t status);
494495
int snd_pcm_drain_done(struct snd_pcm_substream *substream);
495496
#ifdef CONFIG_PM
496497
int snd_pcm_suspend(struct snd_pcm_substream *substream);
@@ -748,8 +749,8 @@ static inline const struct snd_interval *hw_param_interval_c(const struct snd_pc
748749
return &params->intervals[var - SNDRV_PCM_HW_PARAM_FIRST_INTERVAL];
749750
}
750751

751-
#define params_access(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS))
752-
#define params_format(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT))
752+
#define params_access(p) ((__force snd_pcm_access_t)snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_ACCESS)))
753+
#define params_format(p) ((__force snd_pcm_format_t)snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_FORMAT)))
753754
#define params_subformat(p) snd_mask_min(hw_param_mask((p), SNDRV_PCM_HW_PARAM_SUBFORMAT))
754755
#define params_channels(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_CHANNELS)->min
755756
#define params_rate(p) hw_param_interval((p), SNDRV_PCM_HW_PARAM_RATE)->min

‎sound/core/device.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,16 @@ int snd_device_free_all(struct snd_card *card, snd_device_cmd_t cmd)
225225
{
226226
struct snd_device *dev;
227227
int err;
228-
unsigned int range_low, range_high;
228+
unsigned int range_low, range_high, type;
229229

230230
if (snd_BUG_ON(!card))
231231
return -ENXIO;
232-
range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
232+
range_low = (__force unsigned int)cmd * SNDRV_DEV_TYPE_RANGE_SIZE;
233233
range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1;
234234
__again:
235235
list_for_each_entry(dev, &card->devices, list) {
236-
if (dev->type >= range_low && dev->type <= range_high) {
236+
type = (__force unsigned int)dev->type;
237+
if (type >= range_low && type <= range_high) {
237238
if ((err = snd_device_free(card, dev->device_data)) < 0)
238239
return err;
239240
goto __again;

‎sound/core/memalloc.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ int snd_dma_alloc_pages(int type, struct device *device, size_t size,
192192
dmab->bytes = 0;
193193
switch (type) {
194194
case SNDRV_DMA_TYPE_CONTINUOUS:
195-
dmab->area = snd_malloc_pages(size, (unsigned long)device);
195+
dmab->area = snd_malloc_pages(size,
196+
(__force gfp_t)(unsigned long)device);
196197
dmab->addr = 0;
197198
break;
198199
#ifdef CONFIG_HAS_DMA

‎sound/core/oss/linear.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin,
114114
return frames;
115115
}
116116

117-
static void init_data(struct linear_priv *data, int src_format, int dst_format)
117+
static void init_data(struct linear_priv *data,
118+
snd_pcm_format_t src_format, snd_pcm_format_t dst_format)
118119
{
119120
int src_le, dst_le, src_bytes, dst_bytes;
120121

@@ -140,9 +141,9 @@ static void init_data(struct linear_priv *data, int src_format, int dst_format)
140141
if (snd_pcm_format_signed(src_format) !=
141142
snd_pcm_format_signed(dst_format)) {
142143
if (dst_le)
143-
data->flip = cpu_to_le32(0x80000000);
144+
data->flip = (__force u32)cpu_to_le32(0x80000000);
144145
else
145-
data->flip = cpu_to_be32(0x80000000);
146+
data->flip = (__force u32)cpu_to_be32(0x80000000);
146147
}
147148
}
148149

‎sound/core/oss/mixer_oss.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ static int snd_mixer_oss_get_recsrc(struct snd_mixer_oss_file *fmixer)
190190
return -EIO;
191191
if (mixer->put_recsrc && mixer->get_recsrc) { /* exclusive */
192192
int err;
193-
if ((err = mixer->get_recsrc(fmixer, &result)) < 0)
193+
unsigned int index;
194+
if ((err = mixer->get_recsrc(fmixer, &index)) < 0)
194195
return err;
195-
result = 1 << result;
196+
result = 1 << index;
196197
} else {
197198
struct snd_mixer_oss_slot *pslot;
198199
int chn;
@@ -214,6 +215,7 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr
214215
struct snd_mixer_oss *mixer = fmixer->mixer;
215216
struct snd_mixer_oss_slot *pslot;
216217
int chn, active;
218+
unsigned int index;
217219
int result = 0;
218220

219221
if (mixer == NULL)
@@ -222,8 +224,8 @@ static int snd_mixer_oss_set_recsrc(struct snd_mixer_oss_file *fmixer, int recsr
222224
if (recsrc & ~mixer->oss_recsrc)
223225
recsrc &= ~mixer->oss_recsrc;
224226
mixer->put_recsrc(fmixer, ffz(~recsrc));
225-
mixer->get_recsrc(fmixer, &result);
226-
result = 1 << result;
227+
mixer->get_recsrc(fmixer, &index);
228+
result = 1 << index;
227229
}
228230
for (chn = 0; chn < 31; chn++) {
229231
pslot = &mixer->slots[chn];

‎sound/core/oss/mulaw.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static snd_pcm_sframes_t mulaw_transfer(struct snd_pcm_plugin *plugin,
274274
return frames;
275275
}
276276

277-
static void init_data(struct mulaw_priv *data, int format)
277+
static void init_data(struct mulaw_priv *data, snd_pcm_format_t format)
278278
{
279279
#ifdef SNDRV_LITTLE_ENDIAN
280280
data->cvt_endian = snd_pcm_format_big_endian(format) > 0;

‎sound/core/oss/pcm_oss.c‎

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <sound/info.h>
4242
#include <linux/soundcard.h>
4343
#include <sound/initval.h>
44+
#include <sound/mixer_oss.h>
4445

4546
#define OSS_ALSAEMULVER _SIOR ('M', 249, int)
4647

@@ -60,7 +61,6 @@ MODULE_PARM_DESC(nonblock_open, "Don't block opening busy PCM devices.");
6061
MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM);
6162
MODULE_ALIAS_SNDRV_MINOR(SNDRV_MINOR_OSS_PCM1);
6263

63-
extern int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned long arg);
6464
static int snd_pcm_oss_get_rate(struct snd_pcm_oss_file *pcm_oss_file);
6565
static int snd_pcm_oss_get_channels(struct snd_pcm_oss_file *pcm_oss_file);
6666
static int snd_pcm_oss_get_format(struct snd_pcm_oss_file *pcm_oss_file);
@@ -656,7 +656,7 @@ snd_pcm_uframes_t get_hw_ptr_period(struct snd_pcm_runtime *runtime)
656656
#define AFMT_AC3 0x00000400
657657
#define AFMT_VORBIS 0x00000800
658658

659-
static int snd_pcm_oss_format_from(int format)
659+
static snd_pcm_format_t snd_pcm_oss_format_from(int format)
660660
{
661661
switch (format) {
662662
case AFMT_MU_LAW: return SNDRV_PCM_FORMAT_MU_LAW;
@@ -680,7 +680,7 @@ static int snd_pcm_oss_format_from(int format)
680680
}
681681
}
682682

683-
static int snd_pcm_oss_format_to(int format)
683+
static int snd_pcm_oss_format_to(snd_pcm_format_t format)
684684
{
685685
switch (format) {
686686
case SNDRV_PCM_FORMAT_MU_LAW: return AFMT_MU_LAW;
@@ -843,7 +843,8 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
843843
size_t oss_frame_size;
844844
int err;
845845
int direct;
846-
int format, sformat, n;
846+
snd_pcm_format_t format, sformat;
847+
int n;
847848
struct snd_mask sformat_mask;
848849
struct snd_mask mask;
849850

@@ -868,11 +869,11 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
868869
_snd_pcm_hw_param_min(sparams, SNDRV_PCM_HW_PARAM_PERIODS, 2, 0);
869870
snd_mask_none(&mask);
870871
if (atomic_read(&substream->mmap_count))
871-
snd_mask_set(&mask, SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
872+
snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_MMAP_INTERLEAVED);
872873
else {
873-
snd_mask_set(&mask, SNDRV_PCM_ACCESS_RW_INTERLEAVED);
874+
snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_RW_INTERLEAVED);
874875
if (!direct)
875-
snd_mask_set(&mask, SNDRV_PCM_ACCESS_RW_NONINTERLEAVED);
876+
snd_mask_set(&mask, (__force int)SNDRV_PCM_ACCESS_RW_NONINTERLEAVED);
876877
}
877878
err = snd_pcm_hw_param_mask(substream, sparams, SNDRV_PCM_HW_PARAM_ACCESS, &mask);
878879
if (err < 0) {
@@ -891,19 +892,22 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
891892
else
892893
sformat = snd_pcm_plug_slave_format(format, &sformat_mask);
893894

894-
if (sformat < 0 || !snd_mask_test(&sformat_mask, sformat)) {
895-
for (sformat = 0; sformat <= SNDRV_PCM_FORMAT_LAST; sformat++) {
896-
if (snd_mask_test(&sformat_mask, sformat) &&
895+
if ((__force int)sformat < 0 ||
896+
!snd_mask_test(&sformat_mask, (__force int)sformat)) {
897+
for (sformat = (__force snd_pcm_format_t)0;
898+
(__force int)sformat <= (__force int)SNDRV_PCM_FORMAT_LAST;
899+
sformat = (__force snd_pcm_format_t)((__force int)sformat + 1)) {
900+
if (snd_mask_test(&sformat_mask, (__force int)sformat) &&
897901
snd_pcm_oss_format_to(sformat) >= 0)
898902
break;
899903
}
900-
if (sformat > SNDRV_PCM_FORMAT_LAST) {
904+
if ((__force int)sformat > (__force int)SNDRV_PCM_FORMAT_LAST) {
901905
snd_printd("Cannot find a format!!!\n");
902906
err = -EINVAL;
903907
goto failure;
904908
}
905909
}
906-
err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0);
910+
err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, (__force int)sformat, 0);
907911
if (err < 0)
908912
goto failure;
909913

@@ -912,9 +916,9 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
912916
} else {
913917
_snd_pcm_hw_params_any(params);
914918
_snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_ACCESS,
915-
SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0);
919+
(__force int)SNDRV_PCM_ACCESS_RW_INTERLEAVED, 0);
916920
_snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_FORMAT,
917-
snd_pcm_oss_format_from(runtime->oss.format), 0);
921+
(__force int)snd_pcm_oss_format_from(runtime->oss.format), 0);
918922
_snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_CHANNELS,
919923
runtime->oss.channels, 0);
920924
_snd_pcm_hw_param_set(params, SNDRV_PCM_HW_PARAM_RATE,
@@ -1185,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
11851189
if (in_kernel) {
11861190
mm_segment_t fs;
11871191
fs = snd_enter_user();
1188-
ret = snd_pcm_lib_write(substream, (void __user *)ptr, frames);
1192+
ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
11891193
snd_leave_user(fs);
11901194
} else {
1191-
ret = snd_pcm_lib_write(substream, (void __user *)ptr, frames);
1195+
ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
11921196
}
11931197
if (ret != -EPIPE && ret != -ESTRPIPE)
11941198
break;
@@ -1230,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
12301234
if (in_kernel) {
12311235
mm_segment_t fs;
12321236
fs = snd_enter_user();
1233-
ret = snd_pcm_lib_read(substream, (void __user *)ptr, frames);
1237+
ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
12341238
snd_leave_user(fs);
12351239
} else {
1236-
ret = snd_pcm_lib_read(substream, (void __user *)ptr, frames);
1240+
ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
12371241
}
12381242
if (ret == -EPIPE) {
12391243
if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
@@ -1333,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
13331337
struct snd_pcm_plugin_channel *channels;
13341338
size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
13351339
if (!in_kernel) {
1336-
if (copy_from_user(runtime->oss.buffer, (const char __user *)buf, bytes))
1340+
if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
13371341
return -EFAULT;
13381342
buf = runtime->oss.buffer;
13391343
}
@@ -1429,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
14291433
struct snd_pcm_runtime *runtime = substream->runtime;
14301434
snd_pcm_sframes_t frames, frames1;
14311435
#ifdef CONFIG_SND_PCM_OSS_PLUGINS
1432-
char __user *final_dst = (char __user *)buf;
1436+
char __user *final_dst = (char __force __user *)buf;
14331437
if (runtime->oss.plugin_first) {
14341438
struct snd_pcm_plugin_channel *channels;
14351439
size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
@@ -1549,6 +1553,7 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
15491553
{
15501554
struct snd_pcm_runtime *runtime;
15511555
ssize_t result = 0;
1556+
snd_pcm_state_t state;
15521557
long res;
15531558
wait_queue_t wait;
15541559

@@ -1570,9 +1575,9 @@ static int snd_pcm_oss_sync1(struct snd_pcm_substream *substream, size_t size)
15701575
result = 0;
15711576
set_current_state(TASK_INTERRUPTIBLE);
15721577
snd_pcm_stream_lock_irq(substream);
1573-
res = runtime->status->state;
1578+
state = runtime->status->state;
15741579
snd_pcm_stream_unlock_irq(substream);
1575-
if (res != SNDRV_PCM_STATE_RUNNING) {
1580+
if (state != SNDRV_PCM_STATE_RUNNING) {
15761581
set_current_state(TASK_RUNNING);
15771582
break;
15781583
}
@@ -1658,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
16581663
size1);
16591664
size1 /= runtime->channels; /* frames */
16601665
fs = snd_enter_user();
1661-
snd_pcm_lib_write(substream, (void __user *)runtime->oss.buffer, size1);
1666+
snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
16621667
snd_leave_user(fs);
16631668
}
16641669
} else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {

0 commit comments

Comments
 (0)