aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/oss
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-08-08 11:09:09 -0400
committerJaroslav Kysela <perex@perex.cz>2008-08-13 05:46:35 -0400
commit7eaa943c8ed8e91e05d0f5d0dc7a18e3319b45cf (patch)
tree51d86a4cb01cf5735b18c36ca62471f8c759a041 /sound/core/oss
parent5ef03460a6ffc1d3ee6b6f2abc6765d3e224cf89 (diff)
ALSA: Kill snd_assert() in sound/core/*
Kill snd_assert() in sound/core/*, either removed or replaced with if () with snd_BUG_ON(). Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Diffstat (limited to 'sound/core/oss')
-rw-r--r--sound/core/oss/copy.c30
-rw-r--r--sound/core/oss/io.c24
-rw-r--r--sound/core/oss/linear.c29
-rw-r--r--sound/core/oss/mixer_oss.c18
-rw-r--r--sound/core/oss/mulaw.c27
-rw-r--r--sound/core/oss/pcm_oss.c52
-rw-r--r--sound/core/oss/pcm_plugin.c38
-rw-r--r--sound/core/oss/rate.c42
-rw-r--r--sound/core/oss/route.c12
9 files changed, 173 insertions, 99 deletions
diff --git a/sound/core/oss/copy.c b/sound/core/oss/copy.c
index 9ded30d0e97..05b58d4fc2b 100644
--- a/sound/core/oss/copy.c
+++ b/sound/core/oss/copy.c
@@ -32,17 +32,18 @@ static snd_pcm_sframes_t copy_transfer(struct snd_pcm_plugin *plugin,
32 unsigned int channel; 32 unsigned int channel;
33 unsigned int nchannels; 33 unsigned int nchannels;
34 34
35 snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); 35 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
36 return -ENXIO;
36 if (frames == 0) 37 if (frames == 0)
37 return 0; 38 return 0;
38 nchannels = plugin->src_format.channels; 39 nchannels = plugin->src_format.channels;
39 for (channel = 0; channel < nchannels; channel++) { 40 for (channel = 0; channel < nchannels; channel++) {
40 snd_assert(src_channels->area.first % 8 == 0 && 41 if (snd_BUG_ON(src_channels->area.first % 8 ||
41 src_channels->area.step % 8 == 0, 42 src_channels->area.step % 8))
42 return -ENXIO); 43 return -ENXIO;
43 snd_assert(dst_channels->area.first % 8 == 0 && 44 if (snd_BUG_ON(dst_channels->area.first % 8 ||
44 dst_channels->area.step % 8 == 0, 45 dst_channels->area.step % 8))
45 return -ENXIO); 46 return -ENXIO;
46 if (!src_channels->enabled) { 47 if (!src_channels->enabled) {
47 if (dst_channels->wanted) 48 if (dst_channels->wanted)
48 snd_pcm_area_silence(&dst_channels->area, 0, frames, plugin->dst_format.format); 49 snd_pcm_area_silence(&dst_channels->area, 0, frames, plugin->dst_format.format);
@@ -66,15 +67,20 @@ int snd_pcm_plugin_build_copy(struct snd_pcm_substream *plug,
66 struct snd_pcm_plugin *plugin; 67 struct snd_pcm_plugin *plugin;
67 int width; 68 int width;
68 69
69 snd_assert(r_plugin != NULL, return -ENXIO); 70 if (snd_BUG_ON(!r_plugin))
71 return -ENXIO;
70 *r_plugin = NULL; 72 *r_plugin = NULL;
71 73
72 snd_assert(src_format->format == dst_format->format, return -ENXIO); 74 if (snd_BUG_ON(src_format->format != dst_format->format))
73 snd_assert(src_format->rate == dst_format->rate, return -ENXIO); 75 return -ENXIO;
74 snd_assert(src_format->channels == dst_format->channels, return -ENXIO); 76 if (snd_BUG_ON(src_format->rate != dst_format->rate))
77 return -ENXIO;
78 if (snd_BUG_ON(src_format->channels != dst_format->channels))
79 return -ENXIO;
75 80
76 width = snd_pcm_format_physical_width(src_format->format); 81 width = snd_pcm_format_physical_width(src_format->format);
77 snd_assert(width > 0, return -ENXIO); 82 if (snd_BUG_ON(width <= 0))
83 return -ENXIO;
78 84
79 err = snd_pcm_plugin_build(plug, "copy", src_format, dst_format, 85 err = snd_pcm_plugin_build(plug, "copy", src_format, dst_format,
80 0, &plugin); 86 0, &plugin);
diff --git a/sound/core/oss/io.c b/sound/core/oss/io.c
index f874f6ca365..6faa1d71920 100644
--- a/sound/core/oss/io.c
+++ b/sound/core/oss/io.c
@@ -39,14 +39,17 @@ static snd_pcm_sframes_t io_playback_transfer(struct snd_pcm_plugin *plugin,
39 struct snd_pcm_plugin_channel *dst_channels, 39 struct snd_pcm_plugin_channel *dst_channels,
40 snd_pcm_uframes_t frames) 40 snd_pcm_uframes_t frames)
41{ 41{
42 snd_assert(plugin != NULL, return -ENXIO); 42 if (snd_BUG_ON(!plugin))
43 snd_assert(src_channels != NULL, return -ENXIO); 43 return -ENXIO;
44 if (snd_BUG_ON(!src_channels))
45 return -ENXIO;
44 if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) { 46 if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) {
45 return pcm_write(plugin->plug, src_channels->area.addr, frames); 47 return pcm_write(plugin->plug, src_channels->area.addr, frames);
46 } else { 48 } else {
47 int channel, channels = plugin->dst_format.channels; 49 int channel, channels = plugin->dst_format.channels;
48 void **bufs = (void**)plugin->extra_data; 50 void **bufs = (void**)plugin->extra_data;
49 snd_assert(bufs != NULL, return -ENXIO); 51 if (snd_BUG_ON(!bufs))
52 return -ENXIO;
50 for (channel = 0; channel < channels; channel++) { 53 for (channel = 0; channel < channels; channel++) {
51 if (src_channels[channel].enabled) 54 if (src_channels[channel].enabled)
52 bufs[channel] = src_channels[channel].area.addr; 55 bufs[channel] = src_channels[channel].area.addr;
@@ -62,14 +65,17 @@ static snd_pcm_sframes_t io_capture_transfer(struct snd_pcm_plugin *plugin,
62 struct snd_pcm_plugin_channel *dst_channels, 65 struct snd_pcm_plugin_channel *dst_channels,
63 snd_pcm_uframes_t frames) 66 snd_pcm_uframes_t frames)
64{ 67{
65 snd_assert(plugin != NULL, return -ENXIO); 68 if (snd_BUG_ON(!plugin))
66 snd_assert(dst_channels != NULL, return -ENXIO); 69 return -ENXIO;
70 if (snd_BUG_ON(!dst_channels))
71 return -ENXIO;
67 if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) { 72 if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) {
68 return pcm_read(plugin->plug, dst_channels->area.addr, frames); 73 return pcm_read(plugin->plug, dst_channels->area.addr, frames);
69 } else { 74 } else {
70 int channel, channels = plugin->dst_format.channels; 75 int channel, channels = plugin->dst_format.channels;
71 void **bufs = (void**)plugin->extra_data; 76 void **bufs = (void**)plugin->extra_data;
72 snd_assert(bufs != NULL, return -ENXIO); 77 if (snd_BUG_ON(!bufs))
78 return -ENXIO;
73 for (channel = 0; channel < channels; channel++) { 79 for (channel = 0; channel < channels; channel++) {
74 if (dst_channels[channel].enabled) 80 if (dst_channels[channel].enabled)
75 bufs[channel] = dst_channels[channel].area.addr; 81 bufs[channel] = dst_channels[channel].area.addr;
@@ -107,9 +113,11 @@ int snd_pcm_plugin_build_io(struct snd_pcm_substream *plug,
107 struct snd_pcm_plugin_format format; 113 struct snd_pcm_plugin_format format;
108 struct snd_pcm_plugin *plugin; 114 struct snd_pcm_plugin *plugin;
109 115
110 snd_assert(r_plugin != NULL, return -ENXIO); 116 if (snd_BUG_ON(!r_plugin))
117 return -ENXIO;
111 *r_plugin = NULL; 118 *r_plugin = NULL;
112 snd_assert(plug != NULL && params != NULL, return -ENXIO); 119 if (snd_BUG_ON(!plug || !params))
120 return -ENXIO;
113 format.format = params_format(params); 121 format.format = params_format(params);
114 format.rate = params_rate(params); 122 format.rate = params_rate(params);
115 format.channels = params_channels(params); 123 format.channels = params_channels(params);
diff --git a/sound/core/oss/linear.c b/sound/core/oss/linear.c
index da3dbd41669..4c1d1682719 100644
--- a/sound/core/oss/linear.c
+++ b/sound/core/oss/linear.c
@@ -92,7 +92,8 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin,
92{ 92{
93 struct linear_priv *data; 93 struct linear_priv *data;
94 94
95 snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); 95 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
96 return -ENXIO;
96 data = (struct linear_priv *)plugin->extra_data; 97 data = (struct linear_priv *)plugin->extra_data;
97 if (frames == 0) 98 if (frames == 0)
98 return 0; 99 return 0;
@@ -100,12 +101,12 @@ static snd_pcm_sframes_t linear_transfer(struct snd_pcm_plugin *plugin,
100 { 101 {
101 unsigned int channel; 102 unsigned int channel;
102 for (channel = 0; channel < plugin->src_format.channels; channel++) { 103 for (channel = 0; channel < plugin->src_format.channels; channel++) {
103 snd_assert(src_channels[channel].area.first % 8 == 0 && 104 if (snd_BUG_ON(src_channels[channel].area.first % 8 ||
104 src_channels[channel].area.step % 8 == 0, 105 src_channels[channel].area.step % 8))
105 return -ENXIO); 106 return -ENXIO;
106 snd_assert(dst_channels[channel].area.first % 8 == 0 && 107 if (snd_BUG_ON(dst_channels[channel].area.first % 8 ||
107 dst_channels[channel].area.step % 8 == 0, 108 dst_channels[channel].area.step % 8))
108 return -ENXIO); 109 return -ENXIO;
109 } 110 }
110 } 111 }
111#endif 112#endif
@@ -154,13 +155,17 @@ int snd_pcm_plugin_build_linear(struct snd_pcm_substream *plug,
154 struct linear_priv *data; 155 struct linear_priv *data;
155 struct snd_pcm_plugin *plugin; 156 struct snd_pcm_plugin *plugin;
156 157
157 snd_assert(r_plugin != NULL, return -ENXIO); 158 if (snd_BUG_ON(!r_plugin))
159 return -ENXIO;
158 *r_plugin = NULL; 160 *r_plugin = NULL;
159 161
160 snd_assert(src_format->rate == dst_format->rate, return -ENXIO); 162 if (snd_BUG_ON(src_format->rate != dst_format->rate))
161 snd_assert(src_format->channels == dst_format->channels, return -ENXIO); 163 return -ENXIO;
162 snd_assert(snd_pcm_format_linear(src_format->format) && 164 if (snd_BUG_ON(src_format->channels != dst_format->channels))
163 snd_pcm_format_linear(dst_format->format), return -ENXIO); 165 return -ENXIO;
166 if (snd_BUG_ON(!snd_pcm_format_linear(src_format->format) ||
167 !snd_pcm_format_linear(dst_format->format)))
168 return -ENXIO;
164 169
165 err = snd_pcm_plugin_build(plug, "linear format conversion", 170 err = snd_pcm_plugin_build(plug, "linear format conversion",
166 src_format, dst_format, 171 src_format, dst_format,
diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 581aa2c60e6..4690b8b5681 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -257,8 +257,10 @@ static int snd_mixer_oss_get_volume(struct snd_mixer_oss_file *fmixer, int slot)
257 result = pslot->get_volume(fmixer, pslot, &left, &right); 257 result = pslot->get_volume(fmixer, pslot, &left, &right);
258 if (!pslot->stereo) 258 if (!pslot->stereo)
259 right = left; 259 right = left;
260 snd_assert(left >= 0 && left <= 100, return -EIO); 260 if (snd_BUG_ON(left < 0 || left > 100))
261 snd_assert(right >= 0 && right <= 100, return -EIO); 261 return -EIO;
262 if (snd_BUG_ON(right < 0 || right > 100))
263 return -EIO;
262 if (result >= 0) { 264 if (result >= 0) {
263 pslot->volume[0] = left; 265 pslot->volume[0] = left;
264 pslot->volume[1] = right; 266 pslot->volume[1] = right;
@@ -298,7 +300,8 @@ static int snd_mixer_oss_ioctl1(struct snd_mixer_oss_file *fmixer, unsigned int
298 int __user *p = argp; 300 int __user *p = argp;
299 int tmp; 301 int tmp;
300 302
301 snd_assert(fmixer != NULL, return -ENXIO); 303 if (snd_BUG_ON(!fmixer))
304 return -ENXIO;
302 if (((cmd >> 8) & 0xff) == 'M') { 305 if (((cmd >> 8) & 0xff) == 'M') {
303 switch (cmd) { 306 switch (cmd) {
304 case SOUND_MIXER_INFO: 307 case SOUND_MIXER_INFO:
@@ -368,7 +371,8 @@ int snd_mixer_oss_ioctl_card(struct snd_card *card, unsigned int cmd, unsigned l
368{ 371{
369 struct snd_mixer_oss_file fmixer; 372 struct snd_mixer_oss_file fmixer;
370 373
371 snd_assert(card != NULL, return -ENXIO); 374 if (snd_BUG_ON(!card))
375 return -ENXIO;
372 if (card->mixer_oss == NULL) 376 if (card->mixer_oss == NULL)
373 return -ENXIO; 377 return -ENXIO;
374 memset(&fmixer, 0, sizeof(fmixer)); 378 memset(&fmixer, 0, sizeof(fmixer));
@@ -1284,9 +1288,11 @@ static int snd_mixer_oss_free1(void *private)
1284 struct snd_card *card; 1288 struct snd_card *card;
1285 int idx; 1289 int idx;
1286 1290
1287 snd_assert(mixer != NULL, return -ENXIO); 1291 if (!mixer)
1292 return 0;
1288 card = mixer->card; 1293 card = mixer->card;
1289 snd_assert(mixer == card->mixer_oss, return -ENXIO); 1294 if (snd_BUG_ON(mixer != card->mixer_oss))
1295 return -ENXIO;
1290 card->mixer_oss = NULL; 1296 card->mixer_oss = NULL;
1291 for (idx = 0; idx < SNDRV_OSS_MAX_MIXERS; idx++) { 1297 for (idx = 0; idx < SNDRV_OSS_MAX_MIXERS; idx++) {
1292 struct snd_mixer_oss_slot *chn = &mixer->slots[idx]; 1298 struct snd_mixer_oss_slot *chn = &mixer->slots[idx];
diff --git a/sound/core/oss/mulaw.c b/sound/core/oss/mulaw.c
index 77f96194a0e..f7649d4d950 100644
--- a/sound/core/oss/mulaw.c
+++ b/sound/core/oss/mulaw.c
@@ -252,19 +252,20 @@ static snd_pcm_sframes_t mulaw_transfer(struct snd_pcm_plugin *plugin,
252{ 252{
253 struct mulaw_priv *data; 253 struct mulaw_priv *data;
254 254
255 snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); 255 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
256 return -ENXIO;
256 if (frames == 0) 257 if (frames == 0)
257 return 0; 258 return 0;
258#ifdef CONFIG_SND_DEBUG 259#ifdef CONFIG_SND_DEBUG
259 { 260 {
260 unsigned int channel; 261 unsigned int channel;
261 for (channel = 0; channel < plugin->src_format.channels; channel++) { 262 for (channel = 0; channel < plugin->src_format.channels; channel++) {
262 snd_assert(src_channels[channel].area.first % 8 == 0 && 263 if (snd_BUG_ON(src_channels[channel].area.first % 8 ||
263 src_channels[channel].area.step % 8 == 0, 264 src_channels[channel].area.step % 8))
264 return -ENXIO); 265 return -ENXIO;
265 snd_assert(dst_channels[channel].area.first % 8 == 0 && 266 if (snd_BUG_ON(dst_channels[channel].area.first % 8 ||
266 dst_channels[channel].area.step % 8 == 0, 267 dst_channels[channel].area.step % 8))
267 return -ENXIO); 268 return -ENXIO;
268 } 269 }
269 } 270 }
270#endif 271#endif
@@ -305,11 +306,14 @@ int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug,
305 struct snd_pcm_plugin_format *format; 306 struct snd_pcm_plugin_format *format;
306 mulaw_f func; 307 mulaw_f func;
307 308
308 snd_assert(r_plugin != NULL, return -ENXIO); 309 if (snd_BUG_ON(!r_plugin))
310 return -ENXIO;
309 *r_plugin = NULL; 311 *r_plugin = NULL;
310 312
311 snd_assert(src_format->rate == dst_format->rate, return -ENXIO); 313 if (snd_BUG_ON(src_format->rate != dst_format->rate))
312 snd_assert(src_format->channels == dst_format->channels, return -ENXIO); 314 return -ENXIO;
315 if (snd_BUG_ON(src_format->channels != dst_format->channels))
316 return -ENXIO;
313 317
314 if (dst_format->format == SNDRV_PCM_FORMAT_MU_LAW) { 318 if (dst_format->format == SNDRV_PCM_FORMAT_MU_LAW) {
315 format = src_format; 319 format = src_format;
@@ -323,7 +327,8 @@ int snd_pcm_plugin_build_mulaw(struct snd_pcm_substream *plug,
323 snd_BUG(); 327 snd_BUG();
324 return -EINVAL; 328 return -EINVAL;
325 } 329 }
326 snd_assert(snd_pcm_format_linear(format->format) != 0, return -ENXIO); 330 if (snd_BUG_ON(!snd_pcm_format_linear(format->format)))
331 return -ENXIO;
327 332
328 err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion", 333 err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion",
329 src_format, dst_format, 334 src_format, dst_format,
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 4c601b192dd..1af62b8b86c 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -452,7 +452,8 @@ static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm,
452 } else { 452 } else {
453 *params = *save; 453 *params = *save;
454 max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir); 454 max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir);
455 snd_assert(max >= 0, return -EINVAL); 455 if (max < 0)
456 return max;
456 last = 1; 457 last = 1;
457 } 458 }
458 _end: 459 _end:
@@ -461,7 +462,7 @@ static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm,
461 v = snd_pcm_hw_param_last(pcm, params, var, dir); 462 v = snd_pcm_hw_param_last(pcm, params, var, dir);
462 else 463 else
463 v = snd_pcm_hw_param_first(pcm, params, var, dir); 464 v = snd_pcm_hw_param_first(pcm, params, var, dir);
464 snd_assert(v >= 0, return -EINVAL); 465 snd_BUG_ON(v < 0);
465 return v; 466 return v;
466} 467}
467 468
@@ -778,7 +779,8 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
778 while (oss_period_size * oss_periods > oss_buffer_size) 779 while (oss_period_size * oss_periods > oss_buffer_size)
779 oss_period_size /= 2; 780 oss_period_size /= 2;
780 781
781 snd_assert(oss_period_size >= 16, return -EINVAL); 782 if (oss_period_size < 16)
783 return -EINVAL;
782 runtime->oss.period_bytes = oss_period_size; 784 runtime->oss.period_bytes = oss_period_size;
783 runtime->oss.period_frames = 1; 785 runtime->oss.period_frames = 1;
784 runtime->oss.periods = oss_periods; 786 runtime->oss.periods = oss_periods;
@@ -895,7 +897,8 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
895 } 897 }
896 } 898 }
897 err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0); 899 err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0);
898 snd_assert(err >= 0, goto failure); 900 if (err < 0)
901 goto failure;
899 902
900 if (direct) { 903 if (direct) {
901 memcpy(params, sparams, sizeof(*params)); 904 memcpy(params, sparams, sizeof(*params));
@@ -958,11 +961,13 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
958 961
959 n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size); 962 n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size);
960 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL); 963 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL);
961 snd_assert(err >= 0, goto failure); 964 if (err < 0)
965 goto failure;
962 966
963 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS, 967 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS,
964 runtime->oss.periods, NULL); 968 runtime->oss.periods, NULL);
965 snd_assert(err >= 0, goto failure); 969 if (err < 0)
970 goto failure;
966 971
967 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); 972 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
968 973
@@ -1006,7 +1011,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
1006 1011
1007 runtime->oss.periods = params_periods(sparams); 1012 runtime->oss.periods = params_periods(sparams);
1008 oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams)); 1013 oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams));
1009 snd_assert(oss_period_size >= 0, err = -EINVAL; goto failure); 1014 if (oss_period_size < 0) {
1015 err = -EINVAL;
1016 goto failure;
1017 }
1010#ifdef CONFIG_SND_PCM_OSS_PLUGINS 1018#ifdef CONFIG_SND_PCM_OSS_PLUGINS
1011 if (runtime->oss.plugin_first) { 1019 if (runtime->oss.plugin_first) {
1012 err = snd_pcm_plug_alloc(substream, oss_period_size); 1020 err = snd_pcm_plug_alloc(substream, oss_period_size);
@@ -1017,7 +1025,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
1017 oss_period_size *= oss_frame_size; 1025 oss_period_size *= oss_frame_size;
1018 1026
1019 oss_buffer_size = oss_period_size * runtime->oss.periods; 1027 oss_buffer_size = oss_period_size * runtime->oss.periods;
1020 snd_assert(oss_buffer_size >= 0, err = -EINVAL; goto failure); 1028 if (oss_buffer_size < 0) {
1029 err = -EINVAL;
1030 goto failure;
1031 }
1021 1032
1022 runtime->oss.period_bytes = oss_period_size; 1033 runtime->oss.period_bytes = oss_period_size;
1023 runtime->oss.buffer_bytes = oss_buffer_size; 1034 runtime->oss.buffer_bytes = oss_buffer_size;
@@ -1069,7 +1080,8 @@ static int snd_pcm_oss_get_active_substream(struct snd_pcm_oss_file *pcm_oss_fil
1069 return err; 1080 return err;
1070 } 1081 }
1071 } 1082 }
1072 snd_assert(asubstream != NULL, return -EIO); 1083 if (!asubstream)
1084 return -EIO;
1073 if (r_substream) 1085 if (r_substream)
1074 *r_substream = asubstream; 1086 *r_substream = asubstream;
1075 return 0; 1087 return 0;
@@ -1764,7 +1776,8 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
1764 err = snd_pcm_hw_refine(substream, params); 1776 err = snd_pcm_hw_refine(substream, params);
1765 format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 1777 format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
1766 kfree(params); 1778 kfree(params);
1767 snd_assert(err >= 0, return err); 1779 if (err < 0)
1780 return err;
1768 for (fmt = 0; fmt < 32; ++fmt) { 1781 for (fmt = 0; fmt < 32; ++fmt) {
1769 if (snd_mask_test(&format_mask, fmt)) { 1782 if (snd_mask_test(&format_mask, fmt)) {
1770 int f = snd_pcm_oss_format_to(fmt); 1783 int f = snd_pcm_oss_format_to(fmt);
@@ -2250,7 +2263,8 @@ static void snd_pcm_oss_init_substream(struct snd_pcm_substream *substream,
2250static int snd_pcm_oss_release_file(struct snd_pcm_oss_file *pcm_oss_file) 2263static int snd_pcm_oss_release_file(struct snd_pcm_oss_file *pcm_oss_file)
2251{ 2264{
2252 int cidx; 2265 int cidx;
2253 snd_assert(pcm_oss_file != NULL, return -ENXIO); 2266 if (!pcm_oss_file)
2267 return 0;
2254 for (cidx = 0; cidx < 2; ++cidx) { 2268 for (cidx = 0; cidx < 2; ++cidx) {
2255 struct snd_pcm_substream *substream = pcm_oss_file->streams[cidx]; 2269 struct snd_pcm_substream *substream = pcm_oss_file->streams[cidx];
2256 if (substream) 2270 if (substream)
@@ -2271,8 +2285,8 @@ static int snd_pcm_oss_open_file(struct file *file,
2271 struct snd_pcm_substream *substream; 2285 struct snd_pcm_substream *substream;
2272 unsigned int f_mode = file->f_mode; 2286 unsigned int f_mode = file->f_mode;
2273 2287
2274 snd_assert(rpcm_oss_file != NULL, return -EINVAL); 2288 if (rpcm_oss_file)
2275 *rpcm_oss_file = NULL; 2289 *rpcm_oss_file = NULL;
2276 2290
2277 pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL); 2291 pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL);
2278 if (pcm_oss_file == NULL) 2292 if (pcm_oss_file == NULL)
@@ -2312,7 +2326,8 @@ static int snd_pcm_oss_open_file(struct file *file,
2312 } 2326 }
2313 2327
2314 file->private_data = pcm_oss_file; 2328 file->private_data = pcm_oss_file;
2315 *rpcm_oss_file = pcm_oss_file; 2329 if (rpcm_oss_file)
2330 *rpcm_oss_file = pcm_oss_file;
2316 return 0; 2331 return 0;
2317} 2332}
2318 2333
@@ -2321,7 +2336,8 @@ static int snd_task_name(struct task_struct *task, char *name, size_t size)
2321{ 2336{
2322 unsigned int idx; 2337 unsigned int idx;
2323 2338
2324 snd_assert(task != NULL && name != NULL && size >= 2, return -EINVAL); 2339 if (snd_BUG_ON(!task || !name || size < 2))
2340 return -EINVAL;
2325 for (idx = 0; idx < sizeof(task->comm) && idx + 1 < size; idx++) 2341 for (idx = 0; idx < sizeof(task->comm) && idx + 1 < size; idx++)
2326 name[idx] = task->comm[idx]; 2342 name[idx] = task->comm[idx];
2327 name[idx] = '\0'; 2343 name[idx] = '\0';
@@ -2415,7 +2431,8 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file)
2415 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; 2431 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2416 if (substream == NULL) 2432 if (substream == NULL)
2417 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; 2433 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
2418 snd_assert(substream != NULL, return -ENXIO); 2434 if (snd_BUG_ON(!substream))
2435 return -ENXIO;
2419 pcm = substream->pcm; 2436 pcm = substream->pcm;
2420 if (!pcm->card->shutdown) 2437 if (!pcm->card->shutdown)
2421 snd_pcm_oss_sync(pcm_oss_file); 2438 snd_pcm_oss_sync(pcm_oss_file);
@@ -2448,7 +2465,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long
2448 if (substream != NULL) 2465 if (substream != NULL)
2449 break; 2466 break;
2450 } 2467 }
2451 snd_assert(substream != NULL, return -ENXIO); 2468 if (snd_BUG_ON(idx >= 2))
2469 return -ENXIO;
2452 return snd_mixer_oss_ioctl_card(substream->pcm->card, cmd, arg); 2470 return snd_mixer_oss_ioctl_card(substream->pcm->card, cmd, arg);
2453 } 2471 }
2454#endif 2472#endif
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index bec94138205..6751daa3bb5 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -62,7 +62,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
62 if ((width = snd_pcm_format_physical_width(format->format)) < 0) 62 if ((width = snd_pcm_format_physical_width(format->format)) < 0)
63 return width; 63 return width;
64 size = frames * format->channels * width; 64 size = frames * format->channels * width;
65 snd_assert((size % 8) == 0, return -ENXIO); 65 if (snd_BUG_ON(size % 8))
66 return -ENXIO;
66 size /= 8; 67 size /= 8;
67 if (plugin->buf_frames < frames) { 68 if (plugin->buf_frames < frames) {
68 vfree(plugin->buf); 69 vfree(plugin->buf);
@@ -84,7 +85,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
84 c->area.step = format->channels * width; 85 c->area.step = format->channels * width;
85 } 86 }
86 } else if (plugin->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) { 87 } else if (plugin->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
87 snd_assert((size % format->channels) == 0,); 88 if (snd_BUG_ON(size % format->channels))
89 return -EINVAL;
88 size /= format->channels; 90 size /= format->channels;
89 for (channel = 0; channel < format->channels; channel++, c++) { 91 for (channel = 0; channel < format->channels; channel++, c++) {
90 c->frames = frames; 92 c->frames = frames;
@@ -102,13 +104,15 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
102int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames) 104int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames)
103{ 105{
104 int err; 106 int err;
105 snd_assert(snd_pcm_plug_first(plug) != NULL, return -ENXIO); 107 if (snd_BUG_ON(!snd_pcm_plug_first(plug)))
108 return -ENXIO;
106 if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) { 109 if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) {
107 struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug); 110 struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug);
108 while (plugin->next) { 111 while (plugin->next) {
109 if (plugin->dst_frames) 112 if (plugin->dst_frames)
110 frames = plugin->dst_frames(plugin, frames); 113 frames = plugin->dst_frames(plugin, frames);
111 snd_assert(frames > 0, return -ENXIO); 114 if (snd_BUG_ON(frames <= 0))
115 return -ENXIO;
112 plugin = plugin->next; 116 plugin = plugin->next;
113 err = snd_pcm_plugin_alloc(plugin, frames); 117 err = snd_pcm_plugin_alloc(plugin, frames);
114 if (err < 0) 118 if (err < 0)
@@ -119,7 +123,8 @@ int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames)
119 while (plugin->prev) { 123 while (plugin->prev) {
120 if (plugin->src_frames) 124 if (plugin->src_frames)
121 frames = plugin->src_frames(plugin, frames); 125 frames = plugin->src_frames(plugin, frames);
122 snd_assert(frames > 0, return -ENXIO); 126 if (snd_BUG_ON(frames <= 0))
127 return -ENXIO;
123 plugin = plugin->prev; 128 plugin = plugin->prev;
124 err = snd_pcm_plugin_alloc(plugin, frames); 129 err = snd_pcm_plugin_alloc(plugin, frames);
125 if (err < 0) 130 if (err < 0)
@@ -148,8 +153,10 @@ int snd_pcm_plugin_build(struct snd_pcm_substream *plug,
148 struct snd_pcm_plugin *plugin; 153 struct snd_pcm_plugin *plugin;
149 unsigned int channels; 154 unsigned int channels;
150 155
151 snd_assert(plug != NULL, return -ENXIO); 156 if (snd_BUG_ON(!plug))
152 snd_assert(src_format != NULL && dst_format != NULL, return -ENXIO); 157 return -ENXIO;
158 if (snd_BUG_ON(!src_format || !dst_format))
159 return -ENXIO;
153 plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL); 160 plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL);
154 if (plugin == NULL) 161 if (plugin == NULL)
155 return -ENOMEM; 162 return -ENOMEM;
@@ -159,10 +166,10 @@ int snd_pcm_plugin_build(struct snd_pcm_substream *plug,
159 plugin->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED; 166 plugin->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED;
160 plugin->src_format = *src_format; 167 plugin->src_format = *src_format;
161 plugin->src_width = snd_pcm_format_physical_width(src_format->format); 168 plugin->src_width = snd_pcm_format_physical_width(src_format->format);
162 snd_assert(plugin->src_width > 0, ); 169 snd_BUG_ON(plugin->src_width <= 0);
163 plugin->dst_format = *dst_format; 170 plugin->dst_format = *dst_format;
164 plugin->dst_width = snd_pcm_format_physical_width(dst_format->format); 171 plugin->dst_width = snd_pcm_format_physical_width(dst_format->format);
165 snd_assert(plugin->dst_width > 0, ); 172 snd_BUG_ON(plugin->dst_width <= 0);
166 if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK) 173 if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK)
167 channels = src_format->channels; 174 channels = src_format->channels;
168 else 175 else
@@ -194,7 +201,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_p
194 struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next; 201 struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;
195 int stream = snd_pcm_plug_stream(plug); 202 int stream = snd_pcm_plug_stream(plug);
196 203
197 snd_assert(plug != NULL, return -ENXIO); 204 if (snd_BUG_ON(!plug))
205 return -ENXIO;
198 if (drv_frames == 0) 206 if (drv_frames == 0)
199 return 0; 207 return 0;
200 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 208 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -224,7 +232,8 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc
224 snd_pcm_sframes_t frames; 232 snd_pcm_sframes_t frames;
225 int stream = snd_pcm_plug_stream(plug); 233 int stream = snd_pcm_plug_stream(plug);
226 234
227 snd_assert(plug != NULL, return -ENXIO); 235 if (snd_BUG_ON(!plug))
236 return -ENXIO;
228 if (clt_frames == 0) 237 if (clt_frames == 0)
229 return 0; 238 return 0;
230 frames = clt_frames; 239 frames = clt_frames;
@@ -540,7 +549,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu
540 int width, nchannels, channel; 549 int width, nchannels, channel;
541 int stream = snd_pcm_plug_stream(plug); 550 int stream = snd_pcm_plug_stream(plug);
542 551
543 snd_assert(buf != NULL, return -ENXIO); 552 if (snd_BUG_ON(!buf))
553 return -ENXIO;
544 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 554 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
545 plugin = snd_pcm_plug_first(plug); 555 plugin = snd_pcm_plug_first(plug);
546 format = &plugin->src_format; 556 format = &plugin->src_format;
@@ -553,7 +563,9 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu
553 if ((width = snd_pcm_format_physical_width(format->format)) < 0) 563 if ((width = snd_pcm_format_physical_width(format->format)) < 0)
554 return width; 564 return width;
555 nchannels = format->channels; 565 nchannels = format->channels;
556 snd_assert(plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || format->channels <= 1, return -ENXIO); 566 if (snd_BUG_ON(plugin->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED &&
567 format->channels > 1))
568 return -ENXIO;
557 for (channel = 0; channel < nchannels; channel++, v++) { 569 for (channel = 0; channel < nchannels; channel++, v++) {
558 v->frames = count; 570 v->frames = count;
559 v->enabled = 1; 571 v->enabled = 1;
diff --git a/sound/core/oss/rate.c b/sound/core/oss/rate.c
index 14dfb3175d8..a466443c4a2 100644
--- a/sound/core/oss/rate.c
+++ b/sound/core/oss/rate.c
@@ -185,7 +185,8 @@ static snd_pcm_sframes_t rate_src_frames(struct snd_pcm_plugin *plugin, snd_pcm_
185 struct rate_priv *data; 185 struct rate_priv *data;
186 snd_pcm_sframes_t res; 186 snd_pcm_sframes_t res;
187 187
188 snd_assert(plugin != NULL, return -ENXIO); 188 if (snd_BUG_ON(!plugin))
189 return -ENXIO;
189 if (frames == 0) 190 if (frames == 0)
190 return 0; 191 return 0;
191 data = (struct rate_priv *)plugin->extra_data; 192 data = (struct rate_priv *)plugin->extra_data;
@@ -217,7 +218,8 @@ static snd_pcm_sframes_t rate_dst_frames(struct snd_pcm_plugin *plugin, snd_pcm_
217 struct rate_priv *data; 218 struct rate_priv *data;
218 snd_pcm_sframes_t res; 219 snd_pcm_sframes_t res;
219 220
220 snd_assert(plugin != NULL, return -ENXIO); 221 if (snd_BUG_ON(!plugin))
222 return -ENXIO;
221 if (frames == 0) 223 if (frames == 0)
222 return 0; 224 return 0;
223 data = (struct rate_priv *)plugin->extra_data; 225 data = (struct rate_priv *)plugin->extra_data;
@@ -252,19 +254,20 @@ static snd_pcm_sframes_t rate_transfer(struct snd_pcm_plugin *plugin,
252 snd_pcm_uframes_t dst_frames; 254 snd_pcm_uframes_t dst_frames;
253 struct rate_priv *data; 255 struct rate_priv *data;
254 256
255 snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); 257 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
258 return -ENXIO;
256 if (frames == 0) 259 if (frames == 0)
257 return 0; 260 return 0;
258#ifdef CONFIG_SND_DEBUG 261#ifdef CONFIG_SND_DEBUG
259 { 262 {
260 unsigned int channel; 263 unsigned int channel;
261 for (channel = 0; channel < plugin->src_format.channels; channel++) { 264 for (channel = 0; channel < plugin->src_format.channels; channel++) {
262 snd_assert(src_channels[channel].area.first % 8 == 0 && 265 if (snd_BUG_ON(src_channels[channel].area.first % 8 ||
263 src_channels[channel].area.step % 8 == 0, 266 src_channels[channel].area.step % 8))
264 return -ENXIO); 267 return -ENXIO;
265 snd_assert(dst_channels[channel].area.first % 8 == 0 && 268 if (snd_BUG_ON(dst_channels[channel].area.first % 8 ||
266 dst_channels[channel].area.step % 8 == 0, 269 dst_channels[channel].area.step % 8))
267 return -ENXIO); 270 return -ENXIO;
268 } 271 }
269 } 272 }
270#endif 273#endif
@@ -281,7 +284,8 @@ static int rate_action(struct snd_pcm_plugin *plugin,
281 enum snd_pcm_plugin_action action, 284 enum snd_pcm_plugin_action action,
282 unsigned long udata) 285 unsigned long udata)
283{ 286{
284 snd_assert(plugin != NULL, return -ENXIO); 287 if (snd_BUG_ON(!plugin))
288 return -ENXIO;
285 switch (action) { 289 switch (action) {
286 case INIT: 290 case INIT:
287 case PREPARE: 291 case PREPARE:
@@ -302,14 +306,20 @@ int snd_pcm_plugin_build_rate(struct snd_pcm_substream *plug,
302 struct rate_priv *data; 306 struct rate_priv *data;
303 struct snd_pcm_plugin *plugin; 307 struct snd_pcm_plugin *plugin;
304 308
305 snd_assert(r_plugin != NULL, return -ENXIO); 309 if (snd_BUG_ON(!r_plugin))
310 return -ENXIO;
306 *r_plugin = NULL; 311 *r_plugin = NULL;
307 312
308 snd_assert(src_format->channels == dst_format->channels, return -ENXIO); 313 if (snd_BUG_ON(src_format->channels != dst_format->channels))
309 snd_assert(src_format->channels > 0, return -ENXIO); 314 return -ENXIO;
310 snd_assert(src_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); 315 if (snd_BUG_ON(src_format->channels <= 0))
311 snd_assert(dst_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); 316 return -ENXIO;
312 snd_assert(src_format->rate != dst_format->rate, return -ENXIO); 317 if (snd_BUG_ON(src_format->format != SNDRV_PCM_FORMAT_S16))
318 return -ENXIO;
319 if (snd_BUG_ON(dst_format->format != SNDRV_PCM_FORMAT_S16))
320 return -ENXIO;
321 if (snd_BUG_ON(src_format->rate == dst_format->rate))
322 return -ENXIO;
313 323
314 err = snd_pcm_plugin_build(plug, "rate conversion", 324 err = snd_pcm_plugin_build(plug, "rate conversion",
315 src_format, dst_format, 325 src_format, dst_format,
diff --git a/sound/core/oss/route.c b/sound/core/oss/route.c
index da7ab7a3e82..0dcc2870d53 100644
--- a/sound/core/oss/route.c
+++ b/sound/core/oss/route.c
@@ -54,7 +54,8 @@ static snd_pcm_sframes_t route_transfer(struct snd_pcm_plugin *plugin,
54 struct snd_pcm_plugin_channel *dvp; 54 struct snd_pcm_plugin_channel *dvp;
55 int format; 55 int format;
56 56
57 snd_assert(plugin != NULL && src_channels != NULL && dst_channels != NULL, return -ENXIO); 57 if (snd_BUG_ON(!plugin || !src_channels || !dst_channels))
58 return -ENXIO;
58 if (frames == 0) 59 if (frames == 0)
59 return 0; 60 return 0;
60 61
@@ -90,10 +91,13 @@ int snd_pcm_plugin_build_route(struct snd_pcm_substream *plug,
90 struct snd_pcm_plugin *plugin; 91 struct snd_pcm_plugin *plugin;
91 int err; 92 int err;
92 93
93 snd_assert(r_plugin != NULL, return -ENXIO); 94 if (snd_BUG_ON(!r_plugin))
95 return -ENXIO;
94 *r_plugin = NULL; 96 *r_plugin = NULL;
95 snd_assert(src_format->rate == dst_format->rate, return -ENXIO); 97 if (snd_BUG_ON(src_format->rate != dst_format->rate))
96 snd_assert(src_format->format == dst_format->format, return -ENXIO); 98 return -ENXIO;
99 if (snd_BUG_ON(src_format->format != dst_format->format))
100 return -ENXIO;
97 101
98 err = snd_pcm_plugin_build(plug, "route conversion", 102 err = snd_pcm_plugin_build(plug, "route conversion",
99 src_format, dst_format, 0, &plugin); 103 src_format, dst_format, 0, &plugin);