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

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>

authored by

Takashi Iwai and committed by
Jaroslav Kysela
7eaa943c 5ef03460

+583 -388
+2
include/sound/pcm.h
··· 1015 1015 (IEC958_AES1_CON_PCM_CODER<<8)|\ 1016 1016 (IEC958_AES3_CON_FS_48000<<24)) 1017 1017 1018 + #define PCM_RUNTIME_CHECK(sub) snd_BUG_ON(!(sub) || !(sub)->runtime) 1019 + 1018 1020 #endif /* __SOUND_PCM_H */
+31 -19
sound/core/control.c
··· 139 139 struct snd_ctl_file *ctl; 140 140 struct snd_kctl_event *ev; 141 141 142 - snd_assert(card != NULL && id != NULL, return); 142 + if (snd_BUG_ON(!card || !id)) 143 + return; 143 144 read_lock(&card->ctl_files_rwlock); 144 145 #if defined(CONFIG_SND_MIXER_OSS) || defined(CONFIG_SND_MIXER_OSS_MODULE) 145 146 card->mixer_oss_change_count++; ··· 189 188 struct snd_kcontrol *kctl; 190 189 unsigned int idx; 191 190 192 - snd_assert(control != NULL, return NULL); 193 - snd_assert(control->count > 0, return NULL); 191 + if (snd_BUG_ON(!control || !control->count)) 192 + return NULL; 194 193 kctl = kzalloc(sizeof(*kctl) + sizeof(struct snd_kcontrol_volatile) * control->count, GFP_KERNEL); 195 194 if (kctl == NULL) { 196 195 snd_printk(KERN_ERR "Cannot allocate control instance\n"); ··· 219 218 struct snd_kcontrol kctl; 220 219 unsigned int access; 221 220 222 - snd_assert(ncontrol != NULL, return NULL); 223 - snd_assert(ncontrol->info != NULL, return NULL); 221 + if (snd_BUG_ON(!ncontrol || !ncontrol->info)) 222 + return NULL; 224 223 memset(&kctl, 0, sizeof(kctl)); 225 224 kctl.id.iface = ncontrol->iface; 226 225 kctl.id.device = ncontrol->device; ··· 316 315 317 316 if (! kcontrol) 318 317 return err; 319 - snd_assert(card != NULL, goto error); 320 - snd_assert(kcontrol->info != NULL, goto error); 318 + if (snd_BUG_ON(!card || !kcontrol->info)) 319 + goto error; 321 320 id = kcontrol->id; 322 321 down_write(&card->controls_rwsem); 323 322 if (snd_ctl_find_id(card, &id)) { ··· 368 367 struct snd_ctl_elem_id id; 369 368 unsigned int idx; 370 369 371 - snd_assert(card != NULL && kcontrol != NULL, return -EINVAL); 370 + if (snd_BUG_ON(!card || !kcontrol)) 371 + return -EINVAL; 372 372 list_del(&kcontrol->list); 373 373 card->controls_count -= kcontrol->count; 374 374 id = kcontrol->id; ··· 489 487 { 490 488 struct snd_kcontrol *kctl; 491 489 492 - snd_assert(card != NULL && numid != 0, return NULL); 490 + if (snd_BUG_ON(!card || !numid)) 491 + return NULL; 493 492 list_for_each_entry(kctl, &card->controls, list) { 494 493 if (kctl->id.numid <= numid && kctl->id.numid + kctl->count > numid) 495 494 return kctl; ··· 517 514 { 518 515 struct snd_kcontrol *kctl; 519 516 520 - snd_assert(card != NULL && id != NULL, return NULL); 517 + if (snd_BUG_ON(!card || !id)) 518 + return NULL; 521 519 if (id->numid != 0) 522 520 return snd_ctl_find_numid(card, id->numid); 523 521 list_for_each_entry(kctl, &card->controls, list) { ··· 651 647 #endif 652 648 result = kctl->info(kctl, info); 653 649 if (result >= 0) { 654 - snd_assert(info->access == 0, ); 650 + snd_BUG_ON(info->access); 655 651 index_offset = snd_ctl_get_ioff(kctl, &info->id); 656 652 vd = &kctl->vd[index_offset]; 657 653 snd_ctl_build_ioff(&info->id, kctl, index_offset); ··· 1164 1160 1165 1161 ctl = file->private_data; 1166 1162 card = ctl->card; 1167 - snd_assert(card != NULL, return -ENXIO); 1163 + if (snd_BUG_ON(!card)) 1164 + return -ENXIO; 1168 1165 switch (cmd) { 1169 1166 case SNDRV_CTL_IOCTL_PVERSION: 1170 1167 return put_user(SNDRV_CTL_VERSION, ip) ? -EFAULT : 0; ··· 1227 1222 ssize_t result = 0; 1228 1223 1229 1224 ctl = file->private_data; 1230 - snd_assert(ctl != NULL && ctl->card != NULL, return -ENXIO); 1225 + if (snd_BUG_ON(!ctl || !ctl->card)) 1226 + return -ENXIO; 1231 1227 if (!ctl->subscribed) 1232 1228 return -EBADFD; 1233 1229 if (count < sizeof(struct snd_ctl_event)) ··· 1334 1328 { 1335 1329 struct snd_kctl_ioctl *p; 1336 1330 1337 - snd_assert(fcn != NULL, return -EINVAL); 1331 + if (snd_BUG_ON(!fcn)) 1332 + return -EINVAL; 1338 1333 down_write(&snd_ioctl_rwsem); 1339 1334 list_for_each_entry(p, lists, list) { 1340 1335 if (p->fioctl == fcn) { ··· 1411 1404 int err, cardnum; 1412 1405 char name[16]; 1413 1406 1414 - snd_assert(card != NULL, return -ENXIO); 1407 + if (snd_BUG_ON(!card)) 1408 + return -ENXIO; 1415 1409 cardnum = card->number; 1416 - snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); 1410 + if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS)) 1411 + return -ENXIO; 1417 1412 sprintf(name, "controlC%i", cardnum); 1418 1413 if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL, card, -1, 1419 1414 &snd_ctl_f_ops, card, name)) < 0) ··· 1432 1423 struct snd_ctl_file *ctl; 1433 1424 int err, cardnum; 1434 1425 1435 - snd_assert(card != NULL, return -ENXIO); 1426 + if (snd_BUG_ON(!card)) 1427 + return -ENXIO; 1436 1428 cardnum = card->number; 1437 - snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO); 1429 + if (snd_BUG_ON(cardnum < 0 || cardnum >= SNDRV_CARDS)) 1430 + return -ENXIO; 1438 1431 1439 1432 down_read(&card->controls_rwsem); 1440 1433 list_for_each_entry(ctl, &card->ctl_files, list) { ··· 1480 1469 .dev_disconnect = snd_ctl_dev_disconnect, 1481 1470 }; 1482 1471 1483 - snd_assert(card != NULL, return -ENXIO); 1472 + if (snd_BUG_ON(!card)) 1473 + return -ENXIO; 1484 1474 return snd_device_new(card, SNDRV_DEV_CONTROL, card, &ops); 1485 1475 } 1486 1476
+2 -1
sound/core/control_compat.c
··· 398 398 int err; 399 399 400 400 ctl = file->private_data; 401 - snd_assert(ctl && ctl->card, return -ENXIO); 401 + if (snd_BUG_ON(!ctl || !ctl->card)) 402 + return -ENXIO; 402 403 403 404 switch (cmd) { 404 405 case SNDRV_CTL_IOCTL_PVERSION:
+14 -12
sound/core/device.c
··· 45 45 { 46 46 struct snd_device *dev; 47 47 48 - snd_assert(card != NULL, return -ENXIO); 49 - snd_assert(device_data != NULL, return -ENXIO); 50 - snd_assert(ops != NULL, return -ENXIO); 48 + if (snd_BUG_ON(!card || !device_data || !ops)) 49 + return -ENXIO; 51 50 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 52 51 if (dev == NULL) { 53 52 snd_printk(KERN_ERR "Cannot allocate device\n"); ··· 79 80 { 80 81 struct snd_device *dev; 81 82 82 - snd_assert(card != NULL, return -ENXIO); 83 - snd_assert(device_data != NULL, return -ENXIO); 83 + if (snd_BUG_ON(!card || !device_data)) 84 + return -ENXIO; 84 85 list_for_each_entry(dev, &card->devices, list) { 85 86 if (dev->device_data != device_data) 86 87 continue; ··· 122 123 { 123 124 struct snd_device *dev; 124 125 125 - snd_assert(card != NULL, return -ENXIO); 126 - snd_assert(device_data != NULL, return -ENXIO); 126 + if (snd_BUG_ON(!card || !device_data)) 127 + return -ENXIO; 127 128 list_for_each_entry(dev, &card->devices, list) { 128 129 if (dev->device_data != device_data) 129 130 continue; ··· 158 159 struct snd_device *dev; 159 160 int err; 160 161 161 - snd_assert(card != NULL, return -ENXIO); 162 - snd_assert(device_data != NULL, return -ENXIO); 162 + if (snd_BUG_ON(!card || !device_data)) 163 + return -ENXIO; 163 164 list_for_each_entry(dev, &card->devices, list) { 164 165 if (dev->device_data != device_data) 165 166 continue; ··· 187 188 struct snd_device *dev; 188 189 int err; 189 190 190 - snd_assert(card != NULL, return -ENXIO); 191 + if (snd_BUG_ON(!card)) 192 + return -ENXIO; 191 193 list_for_each_entry(dev, &card->devices, list) { 192 194 if (dev->state == SNDRV_DEV_BUILD && dev->ops->dev_register) { 193 195 if ((err = dev->ops->dev_register(dev)) < 0) ··· 208 208 struct snd_device *dev; 209 209 int err = 0; 210 210 211 - snd_assert(card != NULL, return -ENXIO); 211 + if (snd_BUG_ON(!card)) 212 + return -ENXIO; 212 213 list_for_each_entry(dev, &card->devices, list) { 213 214 if (snd_device_disconnect(card, dev->device_data) < 0) 214 215 err = -ENXIO; ··· 227 226 int err; 228 227 unsigned int range_low, range_high; 229 228 230 - snd_assert(card != NULL, return -ENXIO); 229 + if (snd_BUG_ON(!card)) 230 + return -ENXIO; 231 231 range_low = cmd * SNDRV_DEV_TYPE_RANGE_SIZE; 232 232 range_high = range_low + SNDRV_DEV_TYPE_RANGE_SIZE - 1; 233 233 __again:
+10 -6
sound/core/hwdep.c
··· 353 353 .dev_disconnect = snd_hwdep_dev_disconnect, 354 354 }; 355 355 356 - snd_assert(rhwdep != NULL, return -EINVAL); 357 - *rhwdep = NULL; 358 - snd_assert(card != NULL, return -ENXIO); 356 + if (snd_BUG_ON(!card)) 357 + return -ENXIO; 358 + if (rhwdep) 359 + *rhwdep = NULL; 359 360 hwdep = kzalloc(sizeof(*hwdep), GFP_KERNEL); 360 361 if (hwdep == NULL) { 361 362 snd_printk(KERN_ERR "hwdep: cannot allocate\n"); ··· 375 374 } 376 375 init_waitqueue_head(&hwdep->open_wait); 377 376 mutex_init(&hwdep->open_mutex); 378 - *rhwdep = hwdep; 377 + if (rhwdep) 378 + *rhwdep = hwdep; 379 379 return 0; 380 380 } 381 381 382 382 static int snd_hwdep_free(struct snd_hwdep *hwdep) 383 383 { 384 - snd_assert(hwdep != NULL, return -ENXIO); 384 + if (!hwdep) 385 + return 0; 385 386 if (hwdep->private_free) 386 387 hwdep->private_free(hwdep); 387 388 kfree(hwdep); ··· 443 440 { 444 441 struct snd_hwdep *hwdep = device->device_data; 445 442 446 - snd_assert(hwdep != NULL, return -ENXIO); 443 + if (snd_BUG_ON(!hwdep)) 444 + return -ENXIO; 447 445 mutex_lock(&register_mutex); 448 446 if (snd_hwdep_search(hwdep->card, hwdep->device) != hwdep) { 449 447 mutex_unlock(&register_mutex);
+15 -8
sound/core/info.c
··· 217 217 loff_t pos; 218 218 219 219 data = file->private_data; 220 - snd_assert(data != NULL, return -ENXIO); 220 + if (snd_BUG_ON(!data)) 221 + return -ENXIO; 221 222 pos = *offset; 222 223 if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) 223 224 return -EIO; ··· 259 258 loff_t pos; 260 259 261 260 data = file->private_data; 262 - snd_assert(data != NULL, return -ENXIO); 261 + if (snd_BUG_ON(!data)) 262 + return -ENXIO; 263 263 entry = data->entry; 264 264 pos = *offset; 265 265 if (pos < 0 || (long) pos != pos || (ssize_t) count < 0) ··· 616 614 char str[8]; 617 615 struct snd_info_entry *entry; 618 616 619 - snd_assert(card != NULL, return -ENXIO); 617 + if (snd_BUG_ON(!card)) 618 + return -ENXIO; 620 619 621 620 sprintf(str, "card%i", card->number); 622 621 if ((entry = snd_info_create_module_entry(card->module, str, NULL)) == NULL) ··· 639 636 { 640 637 struct proc_dir_entry *p; 641 638 642 - snd_assert(card != NULL, return -ENXIO); 639 + if (snd_BUG_ON(!card)) 640 + return -ENXIO; 643 641 644 642 if (!strcmp(card->id, card->proc_root->name)) 645 643 return 0; ··· 658 654 */ 659 655 void snd_info_card_disconnect(struct snd_card *card) 660 656 { 661 - snd_assert(card != NULL, return); 657 + if (!card) 658 + return; 662 659 mutex_lock(&info_mutex); 663 660 if (card->proc_root_link) { 664 661 snd_remove_proc_entry(snd_proc_root, card->proc_root_link); ··· 676 671 */ 677 672 int snd_info_card_free(struct snd_card *card) 678 673 { 679 - snd_assert(card != NULL, return -ENXIO); 674 + if (!card) 675 + return 0; 680 676 snd_info_free_entry(card->proc_root); 681 677 card->proc_root = NULL; 682 678 return 0; ··· 855 849 return; 856 850 list_del_init(&entry->list); 857 851 root = entry->parent == NULL ? snd_proc_root : entry->parent->p; 858 - snd_assert(root, return); 852 + snd_BUG_ON(!root); 859 853 snd_remove_proc_entry(root, entry->p); 860 854 entry->p = NULL; 861 855 } ··· 953 947 { 954 948 struct proc_dir_entry *root, *p = NULL; 955 949 956 - snd_assert(entry != NULL, return -ENXIO); 950 + if (snd_BUG_ON(!entry)) 951 + return -ENXIO; 957 952 root = entry->parent == NULL ? snd_proc_root : entry->parent->p; 958 953 mutex_lock(&info_mutex); 959 954 p = snd_create_proc_entry(entry->name, entry->mode, root);
+4 -2
sound/core/info_oss.c
··· 43 43 { 44 44 char *x; 45 45 46 - snd_assert(dev >= 0 && dev < SNDRV_OSS_INFO_DEV_COUNT, return -ENXIO); 47 - snd_assert(num >= 0 && num < SNDRV_CARDS, return -ENXIO); 46 + if (snd_BUG_ON(dev < 0 || dev >= SNDRV_OSS_INFO_DEV_COUNT)) 47 + return -ENXIO; 48 + if (snd_BUG_ON(num < 0 || num >= SNDRV_CARDS)) 49 + return -ENXIO; 48 50 mutex_lock(&strings); 49 51 if (string == NULL) { 50 52 if ((x = snd_sndstat_strings[num][dev]) != NULL) {
+2 -1
sound/core/init.c
··· 545 545 { 546 546 int err; 547 547 548 - snd_assert(card != NULL, return -EINVAL); 548 + if (snd_BUG_ON(!card)) 549 + return -EINVAL; 549 550 #ifndef CONFIG_SYSFS_DEPRECATED 550 551 if (!card->card_dev) { 551 552 card->card_dev = device_create_drvdata(sound_class, card->dev,
+16 -25
sound/core/memalloc.c
··· 67 67 /* id for pre-allocated buffers */ 68 68 #define SNDRV_DMA_DEVICE_UNUSED (unsigned int)-1 69 69 70 - #ifdef CONFIG_SND_DEBUG 71 - #define __ASTRING__(x) #x 72 - #define snd_assert(expr, args...) do {\ 73 - if (!(expr)) {\ 74 - printk(KERN_ERR "snd-malloc: BUG? (%s) (called from %p)\n", __ASTRING__(expr), __builtin_return_address(0));\ 75 - args;\ 76 - }\ 77 - } while (0) 78 - #else 79 - #define snd_assert(expr, args...) /**/ 80 - #endif 81 - 82 70 /* 83 71 * 84 72 * Generic memory allocators ··· 99 111 int pg; 100 112 void *res; 101 113 102 - snd_assert(size > 0, return NULL); 103 - snd_assert(gfp_flags != 0, return NULL); 114 + if (WARN_ON(!size)) 115 + return NULL; 116 + if (WARN_ON(!gfp_flags)) 117 + return NULL; 104 118 gfp_flags |= __GFP_COMP; /* compound page lets parts be mapped */ 105 119 pg = get_order(size); 106 120 if ((res = (void *) __get_free_pages(gfp_flags, pg)) != NULL) ··· 142 152 void *res; 143 153 gfp_t gfp_flags; 144 154 145 - snd_assert(size > 0, return NULL); 146 - snd_assert(dma != NULL, return NULL); 155 + if (WARN_ON(!dma)) 156 + return NULL; 147 157 pg = get_order(size); 148 158 gfp_flags = GFP_KERNEL 149 159 | __GFP_COMP /* compound page lets parts be mapped */ ··· 179 189 int pg; 180 190 void *res; 181 191 182 - snd_assert(size > 0, return NULL); 183 - snd_assert(dma_addr != NULL, return NULL); 192 + if (WARN_ON(!dma_addr)) 193 + return NULL; 184 194 pg = get_order(size); 185 195 res = sbus_alloc_consistent(sdev, PAGE_SIZE * (1 << pg), dma_addr); 186 196 if (res != NULL) ··· 226 236 int snd_dma_alloc_pages(int type, struct device *device, size_t size, 227 237 struct snd_dma_buffer *dmab) 228 238 { 229 - snd_assert(size > 0, return -ENXIO); 230 - snd_assert(dmab != NULL, return -ENXIO); 239 + if (WARN_ON(!size)) 240 + return -ENXIO; 241 + if (WARN_ON(!dmab)) 242 + return -ENXIO; 231 243 232 244 dmab->dev.type = type; 233 245 dmab->dev.dev = device; ··· 283 291 struct snd_dma_buffer *dmab) 284 292 { 285 293 int err; 286 - 287 - snd_assert(size > 0, return -ENXIO); 288 - snd_assert(dmab != NULL, return -ENXIO); 289 294 290 295 while ((err = snd_dma_alloc_pages(type, device, size, dmab)) < 0) { 291 296 if (err != -ENOMEM) ··· 342 353 { 343 354 struct snd_mem_list *mem; 344 355 345 - snd_assert(dmab, return 0); 356 + if (WARN_ON(!dmab)) 357 + return 0; 346 358 347 359 mutex_lock(&list_mutex); 348 360 list_for_each_entry(mem, &mem_list_head, list) { ··· 377 387 { 378 388 struct snd_mem_list *mem; 379 389 380 - snd_assert(dmab, return -EINVAL); 390 + if (WARN_ON(!dmab)) 391 + return -EINVAL; 381 392 mem = kmalloc(sizeof(*mem), GFP_KERNEL); 382 393 if (! mem) 383 394 return -ENOMEM;
+18 -12
sound/core/oss/copy.c
··· 32 32 unsigned int channel; 33 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 37 if (frames == 0) 37 38 return 0; 38 39 nchannels = plugin->src_format.channels; 39 40 for (channel = 0; channel < nchannels; channel++) { 40 - snd_assert(src_channels->area.first % 8 == 0 && 41 - src_channels->area.step % 8 == 0, 42 - return -ENXIO); 43 - snd_assert(dst_channels->area.first % 8 == 0 && 44 - dst_channels->area.step % 8 == 0, 45 - return -ENXIO); 41 + if (snd_BUG_ON(src_channels->area.first % 8 || 42 + src_channels->area.step % 8)) 43 + return -ENXIO; 44 + if (snd_BUG_ON(dst_channels->area.first % 8 || 45 + dst_channels->area.step % 8)) 46 + return -ENXIO; 46 47 if (!src_channels->enabled) { 47 48 if (dst_channels->wanted) 48 49 snd_pcm_area_silence(&dst_channels->area, 0, frames, plugin->dst_format.format); ··· 67 66 struct snd_pcm_plugin *plugin; 68 67 int width; 69 68 70 - snd_assert(r_plugin != NULL, return -ENXIO); 69 + if (snd_BUG_ON(!r_plugin)) 70 + return -ENXIO; 71 71 *r_plugin = NULL; 72 72 73 - snd_assert(src_format->format == dst_format->format, return -ENXIO); 74 - snd_assert(src_format->rate == dst_format->rate, return -ENXIO); 75 - snd_assert(src_format->channels == dst_format->channels, return -ENXIO); 73 + if (snd_BUG_ON(src_format->format != dst_format->format)) 74 + return -ENXIO; 75 + if (snd_BUG_ON(src_format->rate != dst_format->rate)) 76 + return -ENXIO; 77 + if (snd_BUG_ON(src_format->channels != dst_format->channels)) 78 + return -ENXIO; 76 79 77 80 width = snd_pcm_format_physical_width(src_format->format); 78 - snd_assert(width > 0, return -ENXIO); 81 + if (snd_BUG_ON(width <= 0)) 82 + return -ENXIO; 79 83 80 84 err = snd_pcm_plugin_build(plug, "copy", src_format, dst_format, 81 85 0, &plugin);
+16 -8
sound/core/oss/io.c
··· 39 39 struct snd_pcm_plugin_channel *dst_channels, 40 40 snd_pcm_uframes_t frames) 41 41 { 42 - snd_assert(plugin != NULL, return -ENXIO); 43 - snd_assert(src_channels != NULL, return -ENXIO); 42 + if (snd_BUG_ON(!plugin)) 43 + return -ENXIO; 44 + if (snd_BUG_ON(!src_channels)) 45 + return -ENXIO; 44 46 if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) { 45 47 return pcm_write(plugin->plug, src_channels->area.addr, frames); 46 48 } else { 47 49 int channel, channels = plugin->dst_format.channels; 48 50 void **bufs = (void**)plugin->extra_data; 49 - snd_assert(bufs != NULL, return -ENXIO); 51 + if (snd_BUG_ON(!bufs)) 52 + return -ENXIO; 50 53 for (channel = 0; channel < channels; channel++) { 51 54 if (src_channels[channel].enabled) 52 55 bufs[channel] = src_channels[channel].area.addr; ··· 65 62 struct snd_pcm_plugin_channel *dst_channels, 66 63 snd_pcm_uframes_t frames) 67 64 { 68 - snd_assert(plugin != NULL, return -ENXIO); 69 - snd_assert(dst_channels != NULL, return -ENXIO); 65 + if (snd_BUG_ON(!plugin)) 66 + return -ENXIO; 67 + if (snd_BUG_ON(!dst_channels)) 68 + return -ENXIO; 70 69 if (plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED) { 71 70 return pcm_read(plugin->plug, dst_channels->area.addr, frames); 72 71 } else { 73 72 int channel, channels = plugin->dst_format.channels; 74 73 void **bufs = (void**)plugin->extra_data; 75 - snd_assert(bufs != NULL, return -ENXIO); 74 + if (snd_BUG_ON(!bufs)) 75 + return -ENXIO; 76 76 for (channel = 0; channel < channels; channel++) { 77 77 if (dst_channels[channel].enabled) 78 78 bufs[channel] = dst_channels[channel].area.addr; ··· 113 107 struct snd_pcm_plugin_format format; 114 108 struct snd_pcm_plugin *plugin; 115 109 116 - snd_assert(r_plugin != NULL, return -ENXIO); 110 + if (snd_BUG_ON(!r_plugin)) 111 + return -ENXIO; 117 112 *r_plugin = NULL; 118 - snd_assert(plug != NULL && params != NULL, return -ENXIO); 113 + if (snd_BUG_ON(!plug || !params)) 114 + return -ENXIO; 119 115 format.format = params_format(params); 120 116 format.rate = params_rate(params); 121 117 format.channels = params_channels(params);
+17 -12
sound/core/oss/linear.c
··· 92 92 { 93 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 97 data = (struct linear_priv *)plugin->extra_data; 97 98 if (frames == 0) 98 99 return 0; ··· 101 100 { 102 101 unsigned int channel; 103 102 for (channel = 0; channel < plugin->src_format.channels; channel++) { 104 - snd_assert(src_channels[channel].area.first % 8 == 0 && 105 - src_channels[channel].area.step % 8 == 0, 106 - return -ENXIO); 107 - snd_assert(dst_channels[channel].area.first % 8 == 0 && 108 - dst_channels[channel].area.step % 8 == 0, 109 - return -ENXIO); 103 + if (snd_BUG_ON(src_channels[channel].area.first % 8 || 104 + src_channels[channel].area.step % 8)) 105 + return -ENXIO; 106 + if (snd_BUG_ON(dst_channels[channel].area.first % 8 || 107 + dst_channels[channel].area.step % 8)) 108 + return -ENXIO; 110 109 } 111 110 } 112 111 #endif ··· 155 154 struct linear_priv *data; 156 155 struct snd_pcm_plugin *plugin; 157 156 158 - snd_assert(r_plugin != NULL, return -ENXIO); 157 + if (snd_BUG_ON(!r_plugin)) 158 + return -ENXIO; 159 159 *r_plugin = NULL; 160 160 161 - snd_assert(src_format->rate == dst_format->rate, return -ENXIO); 162 - snd_assert(src_format->channels == dst_format->channels, return -ENXIO); 163 - snd_assert(snd_pcm_format_linear(src_format->format) && 164 - snd_pcm_format_linear(dst_format->format), return -ENXIO); 161 + if (snd_BUG_ON(src_format->rate != dst_format->rate)) 162 + return -ENXIO; 163 + if (snd_BUG_ON(src_format->channels != dst_format->channels)) 164 + return -ENXIO; 165 + if (snd_BUG_ON(!snd_pcm_format_linear(src_format->format) || 166 + !snd_pcm_format_linear(dst_format->format))) 167 + return -ENXIO; 165 168 166 169 err = snd_pcm_plugin_build(plug, "linear format conversion", 167 170 src_format, dst_format,
+12 -6
sound/core/oss/mixer_oss.c
··· 257 257 result = pslot->get_volume(fmixer, pslot, &left, &right); 258 258 if (!pslot->stereo) 259 259 right = left; 260 - snd_assert(left >= 0 && left <= 100, return -EIO); 261 - snd_assert(right >= 0 && right <= 100, return -EIO); 260 + if (snd_BUG_ON(left < 0 || left > 100)) 261 + return -EIO; 262 + if (snd_BUG_ON(right < 0 || right > 100)) 263 + return -EIO; 262 264 if (result >= 0) { 263 265 pslot->volume[0] = left; 264 266 pslot->volume[1] = right; ··· 300 298 int __user *p = argp; 301 299 int tmp; 302 300 303 - snd_assert(fmixer != NULL, return -ENXIO); 301 + if (snd_BUG_ON(!fmixer)) 302 + return -ENXIO; 304 303 if (((cmd >> 8) & 0xff) == 'M') { 305 304 switch (cmd) { 306 305 case SOUND_MIXER_INFO: ··· 371 368 { 372 369 struct snd_mixer_oss_file fmixer; 373 370 374 - snd_assert(card != NULL, return -ENXIO); 371 + if (snd_BUG_ON(!card)) 372 + return -ENXIO; 375 373 if (card->mixer_oss == NULL) 376 374 return -ENXIO; 377 375 memset(&fmixer, 0, sizeof(fmixer)); ··· 1288 1284 struct snd_card *card; 1289 1285 int idx; 1290 1286 1291 - snd_assert(mixer != NULL, return -ENXIO); 1287 + if (!mixer) 1288 + return 0; 1292 1289 card = mixer->card; 1293 - snd_assert(mixer == card->mixer_oss, return -ENXIO); 1290 + if (snd_BUG_ON(mixer != card->mixer_oss)) 1291 + return -ENXIO; 1294 1292 card->mixer_oss = NULL; 1295 1293 for (idx = 0; idx < SNDRV_OSS_MAX_MIXERS; idx++) { 1296 1294 struct snd_mixer_oss_slot *chn = &mixer->slots[idx];
+16 -11
sound/core/oss/mulaw.c
··· 252 252 { 253 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 257 if (frames == 0) 257 258 return 0; 258 259 #ifdef CONFIG_SND_DEBUG 259 260 { 260 261 unsigned int channel; 261 262 for (channel = 0; channel < plugin->src_format.channels; channel++) { 262 - snd_assert(src_channels[channel].area.first % 8 == 0 && 263 - src_channels[channel].area.step % 8 == 0, 264 - return -ENXIO); 265 - snd_assert(dst_channels[channel].area.first % 8 == 0 && 266 - dst_channels[channel].area.step % 8 == 0, 267 - return -ENXIO); 263 + if (snd_BUG_ON(src_channels[channel].area.first % 8 || 264 + src_channels[channel].area.step % 8)) 265 + return -ENXIO; 266 + if (snd_BUG_ON(dst_channels[channel].area.first % 8 || 267 + dst_channels[channel].area.step % 8)) 268 + return -ENXIO; 268 269 } 269 270 } 270 271 #endif ··· 306 305 struct snd_pcm_plugin_format *format; 307 306 mulaw_f func; 308 307 309 - snd_assert(r_plugin != NULL, return -ENXIO); 308 + if (snd_BUG_ON(!r_plugin)) 309 + return -ENXIO; 310 310 *r_plugin = NULL; 311 311 312 - snd_assert(src_format->rate == dst_format->rate, return -ENXIO); 313 - snd_assert(src_format->channels == dst_format->channels, return -ENXIO); 312 + if (snd_BUG_ON(src_format->rate != dst_format->rate)) 313 + return -ENXIO; 314 + if (snd_BUG_ON(src_format->channels != dst_format->channels)) 315 + return -ENXIO; 314 316 315 317 if (dst_format->format == SNDRV_PCM_FORMAT_MU_LAW) { 316 318 format = src_format; ··· 327 323 snd_BUG(); 328 324 return -EINVAL; 329 325 } 330 - snd_assert(snd_pcm_format_linear(format->format) != 0, return -ENXIO); 326 + if (snd_BUG_ON(!snd_pcm_format_linear(format->format))) 327 + return -ENXIO; 331 328 332 329 err = snd_pcm_plugin_build(plug, "Mu-Law<->linear conversion", 333 330 src_format, dst_format,
+35 -17
sound/core/oss/pcm_oss.c
··· 452 452 } else { 453 453 *params = *save; 454 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 457 last = 1; 457 458 } 458 459 _end: ··· 462 461 v = snd_pcm_hw_param_last(pcm, params, var, dir); 463 462 else 464 463 v = snd_pcm_hw_param_first(pcm, params, var, dir); 465 - snd_assert(v >= 0, return -EINVAL); 464 + snd_BUG_ON(v < 0); 466 465 return v; 467 466 } 468 467 ··· 779 778 while (oss_period_size * oss_periods > oss_buffer_size) 780 779 oss_period_size /= 2; 781 780 782 - snd_assert(oss_period_size >= 16, return -EINVAL); 781 + if (oss_period_size < 16) 782 + return -EINVAL; 783 783 runtime->oss.period_bytes = oss_period_size; 784 784 runtime->oss.period_frames = 1; 785 785 runtime->oss.periods = oss_periods; ··· 897 895 } 898 896 } 899 897 err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0); 900 - snd_assert(err >= 0, goto failure); 898 + if (err < 0) 899 + goto failure; 901 900 902 901 if (direct) { 903 902 memcpy(params, sparams, sizeof(*params)); ··· 961 958 962 959 n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size); 963 960 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL); 964 - snd_assert(err >= 0, goto failure); 961 + if (err < 0) 962 + goto failure; 965 963 966 964 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS, 967 965 runtime->oss.periods, NULL); 968 - snd_assert(err >= 0, goto failure); 966 + if (err < 0) 967 + goto failure; 969 968 970 969 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); 971 970 ··· 1011 1006 1012 1007 runtime->oss.periods = params_periods(sparams); 1013 1008 oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams)); 1014 - snd_assert(oss_period_size >= 0, err = -EINVAL; goto failure); 1009 + if (oss_period_size < 0) { 1010 + err = -EINVAL; 1011 + goto failure; 1012 + } 1015 1013 #ifdef CONFIG_SND_PCM_OSS_PLUGINS 1016 1014 if (runtime->oss.plugin_first) { 1017 1015 err = snd_pcm_plug_alloc(substream, oss_period_size); ··· 1025 1017 oss_period_size *= oss_frame_size; 1026 1018 1027 1019 oss_buffer_size = oss_period_size * runtime->oss.periods; 1028 - snd_assert(oss_buffer_size >= 0, err = -EINVAL; goto failure); 1020 + if (oss_buffer_size < 0) { 1021 + err = -EINVAL; 1022 + goto failure; 1023 + } 1029 1024 1030 1025 runtime->oss.period_bytes = oss_period_size; 1031 1026 runtime->oss.buffer_bytes = oss_buffer_size; ··· 1080 1069 return err; 1081 1070 } 1082 1071 } 1083 - snd_assert(asubstream != NULL, return -EIO); 1072 + if (!asubstream) 1073 + return -EIO; 1084 1074 if (r_substream) 1085 1075 *r_substream = asubstream; 1086 1076 return 0; ··· 1776 1764 err = snd_pcm_hw_refine(substream, params); 1777 1765 format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 1778 1766 kfree(params); 1779 - snd_assert(err >= 0, return err); 1767 + if (err < 0) 1768 + return err; 1780 1769 for (fmt = 0; fmt < 32; ++fmt) { 1781 1770 if (snd_mask_test(&format_mask, fmt)) { 1782 1771 int f = snd_pcm_oss_format_to(fmt); ··· 2263 2250 static int snd_pcm_oss_release_file(struct snd_pcm_oss_file *pcm_oss_file) 2264 2251 { 2265 2252 int cidx; 2266 - snd_assert(pcm_oss_file != NULL, return -ENXIO); 2253 + if (!pcm_oss_file) 2254 + return 0; 2267 2255 for (cidx = 0; cidx < 2; ++cidx) { 2268 2256 struct snd_pcm_substream *substream = pcm_oss_file->streams[cidx]; 2269 2257 if (substream) ··· 2285 2271 struct snd_pcm_substream *substream; 2286 2272 unsigned int f_mode = file->f_mode; 2287 2273 2288 - snd_assert(rpcm_oss_file != NULL, return -EINVAL); 2289 - *rpcm_oss_file = NULL; 2274 + if (rpcm_oss_file) 2275 + *rpcm_oss_file = NULL; 2290 2276 2291 2277 pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL); 2292 2278 if (pcm_oss_file == NULL) ··· 2326 2312 } 2327 2313 2328 2314 file->private_data = pcm_oss_file; 2329 - *rpcm_oss_file = pcm_oss_file; 2315 + if (rpcm_oss_file) 2316 + *rpcm_oss_file = pcm_oss_file; 2330 2317 return 0; 2331 2318 } 2332 2319 ··· 2336 2321 { 2337 2322 unsigned int idx; 2338 2323 2339 - snd_assert(task != NULL && name != NULL && size >= 2, return -EINVAL); 2324 + if (snd_BUG_ON(!task || !name || size < 2)) 2325 + return -EINVAL; 2340 2326 for (idx = 0; idx < sizeof(task->comm) && idx + 1 < size; idx++) 2341 2327 name[idx] = task->comm[idx]; 2342 2328 name[idx] = '\0'; ··· 2431 2415 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; 2432 2416 if (substream == NULL) 2433 2417 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; 2434 - snd_assert(substream != NULL, return -ENXIO); 2418 + if (snd_BUG_ON(!substream)) 2419 + return -ENXIO; 2435 2420 pcm = substream->pcm; 2436 2421 if (!pcm->card->shutdown) 2437 2422 snd_pcm_oss_sync(pcm_oss_file); ··· 2465 2448 if (substream != NULL) 2466 2449 break; 2467 2450 } 2468 - snd_assert(substream != NULL, return -ENXIO); 2451 + if (snd_BUG_ON(idx >= 2)) 2452 + return -ENXIO; 2469 2453 return snd_mixer_oss_ioctl_card(substream->pcm->card, cmd, arg); 2470 2454 } 2471 2455 #endif
+25 -13
sound/core/oss/pcm_plugin.c
··· 62 62 if ((width = snd_pcm_format_physical_width(format->format)) < 0) 63 63 return width; 64 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 67 size /= 8; 67 68 if (plugin->buf_frames < frames) { 68 69 vfree(plugin->buf); ··· 85 84 c->area.step = format->channels * width; 86 85 } 87 86 } else if (plugin->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) { 88 - snd_assert((size % format->channels) == 0,); 87 + if (snd_BUG_ON(size % format->channels)) 88 + return -EINVAL; 89 89 size /= format->channels; 90 90 for (channel = 0; channel < format->channels; channel++, c++) { 91 91 c->frames = frames; ··· 104 102 int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames) 105 103 { 106 104 int err; 107 - snd_assert(snd_pcm_plug_first(plug) != NULL, return -ENXIO); 105 + if (snd_BUG_ON(!snd_pcm_plug_first(plug))) 106 + return -ENXIO; 108 107 if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) { 109 108 struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug); 110 109 while (plugin->next) { 111 110 if (plugin->dst_frames) 112 111 frames = plugin->dst_frames(plugin, frames); 113 - snd_assert(frames > 0, return -ENXIO); 112 + if (snd_BUG_ON(frames <= 0)) 113 + return -ENXIO; 114 114 plugin = plugin->next; 115 115 err = snd_pcm_plugin_alloc(plugin, frames); 116 116 if (err < 0) ··· 123 119 while (plugin->prev) { 124 120 if (plugin->src_frames) 125 121 frames = plugin->src_frames(plugin, frames); 126 - snd_assert(frames > 0, return -ENXIO); 122 + if (snd_BUG_ON(frames <= 0)) 123 + return -ENXIO; 127 124 plugin = plugin->prev; 128 125 err = snd_pcm_plugin_alloc(plugin, frames); 129 126 if (err < 0) ··· 153 148 struct snd_pcm_plugin *plugin; 154 149 unsigned int channels; 155 150 156 - snd_assert(plug != NULL, return -ENXIO); 157 - snd_assert(src_format != NULL && dst_format != NULL, return -ENXIO); 151 + if (snd_BUG_ON(!plug)) 152 + return -ENXIO; 153 + if (snd_BUG_ON(!src_format || !dst_format)) 154 + return -ENXIO; 158 155 plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL); 159 156 if (plugin == NULL) 160 157 return -ENOMEM; ··· 166 159 plugin->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED; 167 160 plugin->src_format = *src_format; 168 161 plugin->src_width = snd_pcm_format_physical_width(src_format->format); 169 - snd_assert(plugin->src_width > 0, ); 162 + snd_BUG_ON(plugin->src_width <= 0); 170 163 plugin->dst_format = *dst_format; 171 164 plugin->dst_width = snd_pcm_format_physical_width(dst_format->format); 172 - snd_assert(plugin->dst_width > 0, ); 165 + snd_BUG_ON(plugin->dst_width <= 0); 173 166 if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK) 174 167 channels = src_format->channels; 175 168 else ··· 201 194 struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next; 202 195 int stream = snd_pcm_plug_stream(plug); 203 196 204 - snd_assert(plug != NULL, return -ENXIO); 197 + if (snd_BUG_ON(!plug)) 198 + return -ENXIO; 205 199 if (drv_frames == 0) 206 200 return 0; 207 201 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { ··· 232 224 snd_pcm_sframes_t frames; 233 225 int stream = snd_pcm_plug_stream(plug); 234 226 235 - snd_assert(plug != NULL, return -ENXIO); 227 + if (snd_BUG_ON(!plug)) 228 + return -ENXIO; 236 229 if (clt_frames == 0) 237 230 return 0; 238 231 frames = clt_frames; ··· 549 540 int width, nchannels, channel; 550 541 int stream = snd_pcm_plug_stream(plug); 551 542 552 - snd_assert(buf != NULL, return -ENXIO); 543 + if (snd_BUG_ON(!buf)) 544 + return -ENXIO; 553 545 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 554 546 plugin = snd_pcm_plug_first(plug); 555 547 format = &plugin->src_format; ··· 563 553 if ((width = snd_pcm_format_physical_width(format->format)) < 0) 564 554 return width; 565 555 nchannels = format->channels; 566 - snd_assert(plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || format->channels <= 1, return -ENXIO); 556 + if (snd_BUG_ON(plugin->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && 557 + format->channels > 1)) 558 + return -ENXIO; 567 559 for (channel = 0; channel < nchannels; channel++, v++) { 568 560 v->frames = count; 569 561 v->enabled = 1;
+26 -16
sound/core/oss/rate.c
··· 185 185 struct rate_priv *data; 186 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 190 if (frames == 0) 190 191 return 0; 191 192 data = (struct rate_priv *)plugin->extra_data; ··· 218 217 struct rate_priv *data; 219 218 snd_pcm_sframes_t res; 220 219 221 - snd_assert(plugin != NULL, return -ENXIO); 220 + if (snd_BUG_ON(!plugin)) 221 + return -ENXIO; 222 222 if (frames == 0) 223 223 return 0; 224 224 data = (struct rate_priv *)plugin->extra_data; ··· 254 252 snd_pcm_uframes_t dst_frames; 255 253 struct rate_priv *data; 256 254 257 - 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; 258 257 if (frames == 0) 259 258 return 0; 260 259 #ifdef CONFIG_SND_DEBUG 261 260 { 262 261 unsigned int channel; 263 262 for (channel = 0; channel < plugin->src_format.channels; channel++) { 264 - snd_assert(src_channels[channel].area.first % 8 == 0 && 265 - src_channels[channel].area.step % 8 == 0, 266 - return -ENXIO); 267 - snd_assert(dst_channels[channel].area.first % 8 == 0 && 268 - dst_channels[channel].area.step % 8 == 0, 269 - return -ENXIO); 263 + if (snd_BUG_ON(src_channels[channel].area.first % 8 || 264 + src_channels[channel].area.step % 8)) 265 + return -ENXIO; 266 + if (snd_BUG_ON(dst_channels[channel].area.first % 8 || 267 + dst_channels[channel].area.step % 8)) 268 + return -ENXIO; 270 269 } 271 270 } 272 271 #endif ··· 284 281 enum snd_pcm_plugin_action action, 285 282 unsigned long udata) 286 283 { 287 - snd_assert(plugin != NULL, return -ENXIO); 284 + if (snd_BUG_ON(!plugin)) 285 + return -ENXIO; 288 286 switch (action) { 289 287 case INIT: 290 288 case PREPARE: ··· 306 302 struct rate_priv *data; 307 303 struct snd_pcm_plugin *plugin; 308 304 309 - snd_assert(r_plugin != NULL, return -ENXIO); 305 + if (snd_BUG_ON(!r_plugin)) 306 + return -ENXIO; 310 307 *r_plugin = NULL; 311 308 312 - snd_assert(src_format->channels == dst_format->channels, return -ENXIO); 313 - snd_assert(src_format->channels > 0, return -ENXIO); 314 - snd_assert(src_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); 315 - snd_assert(dst_format->format == SNDRV_PCM_FORMAT_S16, return -ENXIO); 316 - snd_assert(src_format->rate != dst_format->rate, return -ENXIO); 309 + if (snd_BUG_ON(src_format->channels != dst_format->channels)) 310 + return -ENXIO; 311 + if (snd_BUG_ON(src_format->channels <= 0)) 312 + return -ENXIO; 313 + if (snd_BUG_ON(src_format->format != SNDRV_PCM_FORMAT_S16)) 314 + return -ENXIO; 315 + if (snd_BUG_ON(dst_format->format != SNDRV_PCM_FORMAT_S16)) 316 + return -ENXIO; 317 + if (snd_BUG_ON(src_format->rate == dst_format->rate)) 318 + return -ENXIO; 317 319 318 320 err = snd_pcm_plugin_build(plug, "rate conversion", 319 321 src_format, dst_format,
+8 -4
sound/core/oss/route.c
··· 54 54 struct snd_pcm_plugin_channel *dvp; 55 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 59 if (frames == 0) 59 60 return 0; 60 61 ··· 91 90 struct snd_pcm_plugin *plugin; 92 91 int err; 93 92 94 - snd_assert(r_plugin != NULL, return -ENXIO); 93 + if (snd_BUG_ON(!r_plugin)) 94 + return -ENXIO; 95 95 *r_plugin = NULL; 96 - snd_assert(src_format->rate == dst_format->rate, return -ENXIO); 97 - snd_assert(src_format->format == dst_format->format, return -ENXIO); 96 + if (snd_BUG_ON(src_format->rate != dst_format->rate)) 97 + return -ENXIO; 98 + if (snd_BUG_ON(src_format->format != dst_format->format)) 99 + return -ENXIO; 98 100 99 101 err = snd_pcm_plugin_build(plug, "route conversion", 100 102 src_format, dst_format, 0, &plugin);
+19 -15
sound/core/pcm.c
··· 256 256 257 257 static const char *snd_pcm_stream_name(int stream) 258 258 { 259 - snd_assert(stream <= SNDRV_PCM_STREAM_LAST, return NULL); 260 259 return snd_pcm_stream_names[stream]; 261 260 } 262 261 ··· 271 272 272 273 static const char *snd_pcm_tstamp_mode_name(int mode) 273 274 { 274 - snd_assert(mode <= SNDRV_PCM_TSTAMP_LAST, return NULL); 275 275 return snd_pcm_tstamp_mode_names[mode]; 276 276 } 277 277 ··· 704 706 .dev_disconnect = snd_pcm_dev_disconnect, 705 707 }; 706 708 707 - snd_assert(rpcm != NULL, return -EINVAL); 708 - *rpcm = NULL; 709 - snd_assert(card != NULL, return -ENXIO); 709 + if (snd_BUG_ON(!card)) 710 + return -ENXIO; 711 + if (rpcm) 712 + *rpcm = NULL; 710 713 pcm = kzalloc(sizeof(*pcm), GFP_KERNEL); 711 714 if (pcm == NULL) { 712 715 snd_printk(KERN_ERR "Cannot allocate PCM\n"); ··· 731 732 snd_pcm_free(pcm); 732 733 return err; 733 734 } 734 - *rpcm = pcm; 735 + if (rpcm) 736 + *rpcm = pcm; 735 737 return 0; 736 738 } 737 739 ··· 766 766 { 767 767 struct snd_pcm_notify *notify; 768 768 769 - snd_assert(pcm != NULL, return -ENXIO); 769 + if (!pcm) 770 + return 0; 770 771 list_for_each_entry(notify, &snd_pcm_notify_list, list) { 771 772 notify->n_unregister(pcm); 772 773 } ··· 798 797 int prefer_subdevice = -1; 799 798 size_t size; 800 799 801 - snd_assert(rsubstream != NULL, return -EINVAL); 800 + if (snd_BUG_ON(!pcm || !rsubstream)) 801 + return -ENXIO; 802 802 *rsubstream = NULL; 803 - snd_assert(pcm != NULL, return -ENXIO); 804 803 pstr = &pcm->streams[stream]; 805 804 if (pstr->substream == NULL || pstr->substream_count == 0) 806 805 return -ENODEV; ··· 908 907 { 909 908 struct snd_pcm_runtime *runtime; 910 909 910 + if (PCM_RUNTIME_CHECK(substream)) 911 + return; 911 912 runtime = substream->runtime; 912 - snd_assert(runtime != NULL, return); 913 913 if (runtime->private_free != NULL) 914 914 runtime->private_free(runtime); 915 915 snd_free_pages((void*)runtime->status, ··· 955 953 struct snd_pcm *pcm = device->device_data; 956 954 struct device *dev; 957 955 958 - snd_assert(pcm != NULL && device != NULL, return -ENXIO); 956 + if (snd_BUG_ON(!pcm || !device)) 957 + return -ENXIO; 959 958 mutex_lock(&register_mutex); 960 959 err = snd_pcm_add(pcm); 961 960 if (err) { ··· 1046 1043 { 1047 1044 struct snd_pcm *pcm; 1048 1045 1049 - snd_assert(notify != NULL && 1050 - notify->n_register != NULL && 1051 - notify->n_unregister != NULL && 1052 - notify->n_disconnect, return -EINVAL); 1046 + if (snd_BUG_ON(!notify || 1047 + !notify->n_register || 1048 + !notify->n_unregister || 1049 + !notify->n_disconnect)) 1050 + return -EINVAL; 1053 1051 mutex_lock(&register_mutex); 1054 1052 if (nfree) { 1055 1053 list_del(&notify->list);
+2 -1
sound/core/pcm_compat.c
··· 397 397 snd_pcm_uframes_t boundary; 398 398 int err; 399 399 400 - snd_assert(runtime, return -EINVAL); 400 + if (snd_BUG_ON(!runtime)) 401 + return -EINVAL; 401 402 402 403 if (get_user(sflags, &src->flags) || 403 404 get_user(scontrol.appl_ptr, &src->c.control.appl_ptr) ||
+61 -41
sound/core/pcm_lib.c
··· 85 85 } 86 86 frames = runtime->buffer_size - runtime->silence_filled; 87 87 } 88 - snd_assert(frames <= runtime->buffer_size, return); 88 + if (snd_BUG_ON(frames > runtime->buffer_size)) 89 + return; 89 90 if (frames == 0) 90 91 return; 91 92 ofs = runtime->silence_start % runtime->buffer_size; ··· 97 96 if (substream->ops->silence) { 98 97 int err; 99 98 err = substream->ops->silence(substream, -1, ofs, transfer); 100 - snd_assert(err >= 0, ); 99 + snd_BUG_ON(err < 0); 101 100 } else { 102 101 char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, ofs); 103 102 snd_pcm_format_set_silence(runtime->format, hwbuf, transfer * runtime->channels); ··· 109 108 for (c = 0; c < channels; ++c) { 110 109 int err; 111 110 err = substream->ops->silence(substream, c, ofs, transfer); 112 - snd_assert(err >= 0, ); 111 + snd_BUG_ON(err < 0); 113 112 } 114 113 } else { 115 114 size_t dma_csize = runtime->dma_bytes / channels; ··· 355 354 { 356 355 u_int64_t n = (u_int64_t) a * b; 357 356 if (c == 0) { 358 - snd_assert(n > 0, ); 357 + snd_BUG_ON(!n); 359 358 *r = 0; 360 359 return UINT_MAX; 361 360 } ··· 381 380 int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v) 382 381 { 383 382 int changed = 0; 384 - snd_assert(!snd_interval_empty(i), return -EINVAL); 383 + if (snd_BUG_ON(snd_interval_empty(i))) 384 + return -EINVAL; 385 385 if (i->min < v->min) { 386 386 i->min = v->min; 387 387 i->openmin = v->openmin; ··· 425 423 426 424 static int snd_interval_refine_first(struct snd_interval *i) 427 425 { 428 - snd_assert(!snd_interval_empty(i), return -EINVAL); 426 + if (snd_BUG_ON(snd_interval_empty(i))) 427 + return -EINVAL; 429 428 if (snd_interval_single(i)) 430 429 return 0; 431 430 i->max = i->min; ··· 438 435 439 436 static int snd_interval_refine_last(struct snd_interval *i) 440 437 { 441 - snd_assert(!snd_interval_empty(i), return -EINVAL); 438 + if (snd_BUG_ON(snd_interval_empty(i))) 439 + return -EINVAL; 442 440 if (snd_interval_single(i)) 443 441 return 0; 444 442 i->min = i->max; ··· 893 889 c->private = private; 894 890 k = 0; 895 891 while (1) { 896 - snd_assert(k < ARRAY_SIZE(c->deps), return -EINVAL); 892 + if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) 893 + return -EINVAL; 897 894 c->deps[k++] = dep; 898 895 if (dep < 0) 899 896 break; ··· 1290 1285 return changed; 1291 1286 if (params->rmask) { 1292 1287 int err = snd_pcm_hw_refine(pcm, params); 1293 - snd_assert(err >= 0, return err); 1288 + if (snd_BUG_ON(err < 0)) 1289 + return err; 1294 1290 } 1295 1291 return snd_pcm_hw_param_value(params, var, dir); 1296 1292 } ··· 1336 1330 return changed; 1337 1331 if (params->rmask) { 1338 1332 int err = snd_pcm_hw_refine(pcm, params); 1339 - snd_assert(err >= 0, return err); 1333 + if (snd_BUG_ON(err < 0)) 1334 + return err; 1340 1335 } 1341 1336 return snd_pcm_hw_param_value(params, var, dir); 1342 1337 } ··· 1375 1368 err = snd_pcm_hw_param_first(pcm, params, *v, NULL); 1376 1369 else 1377 1370 err = snd_pcm_hw_param_last(pcm, params, *v, NULL); 1378 - snd_assert(err >= 0, return err); 1371 + if (snd_BUG_ON(err < 0)) 1372 + return err; 1379 1373 } 1380 1374 return 0; 1381 1375 } ··· 1474 1466 struct snd_pcm_runtime *runtime; 1475 1467 unsigned long flags; 1476 1468 1477 - snd_assert(substream != NULL, return); 1469 + if (PCM_RUNTIME_CHECK(substream)) 1470 + return; 1478 1471 runtime = substream->runtime; 1479 - snd_assert(runtime != NULL, return); 1480 1472 1481 1473 if (runtime->transfer_ack_begin) 1482 1474 runtime->transfer_ack_begin(substream); ··· 1575 1567 return err; 1576 1568 } else { 1577 1569 char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff); 1578 - snd_assert(runtime->dma_area, return -EFAULT); 1579 1570 if (copy_from_user(hwbuf, buf, frames_to_bytes(runtime, frames))) 1580 1571 return -EFAULT; 1581 1572 } ··· 1636 1629 cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; 1637 1630 if (frames > cont) 1638 1631 frames = cont; 1639 - snd_assert(frames != 0, snd_pcm_stream_unlock_irq(substream); return -EINVAL); 1632 + if (snd_BUG_ON(!frames)) { 1633 + snd_pcm_stream_unlock_irq(substream); 1634 + return -EINVAL; 1635 + } 1640 1636 appl_ptr = runtime->control->appl_ptr; 1641 1637 appl_ofs = appl_ptr % runtime->buffer_size; 1642 1638 snd_pcm_stream_unlock_irq(substream); ··· 1679 1669 return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; 1680 1670 } 1681 1671 1672 + /* sanity-check for read/write methods */ 1673 + static int pcm_sanity_check(struct snd_pcm_substream *substream) 1674 + { 1675 + struct snd_pcm_runtime *runtime; 1676 + if (PCM_RUNTIME_CHECK(substream)) 1677 + return -ENXIO; 1678 + runtime = substream->runtime; 1679 + if (snd_BUG_ON(!substream->ops->copy && !runtime->dma_area)) 1680 + return -EINVAL; 1681 + if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 1682 + return -EBADFD; 1683 + return 0; 1684 + } 1685 + 1682 1686 snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const void __user *buf, snd_pcm_uframes_t size) 1683 1687 { 1684 1688 struct snd_pcm_runtime *runtime; 1685 1689 int nonblock; 1690 + int err; 1686 1691 1687 - snd_assert(substream != NULL, return -ENXIO); 1692 + err = pcm_sanity_check(substream); 1693 + if (err < 0) 1694 + return err; 1688 1695 runtime = substream->runtime; 1689 - snd_assert(runtime != NULL, return -ENXIO); 1690 - snd_assert(substream->ops->copy != NULL || runtime->dma_area != NULL, return -EINVAL); 1691 - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 1692 - return -EBADFD; 1693 - 1694 1696 nonblock = !!(substream->f_flags & O_NONBLOCK); 1695 1697 1696 1698 if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && ··· 1725 1703 int channels = runtime->channels; 1726 1704 int c; 1727 1705 if (substream->ops->copy) { 1728 - snd_assert(substream->ops->silence != NULL, return -EINVAL); 1706 + if (snd_BUG_ON(!substream->ops->silence)) 1707 + return -EINVAL; 1729 1708 for (c = 0; c < channels; ++c, ++bufs) { 1730 1709 if (*bufs == NULL) { 1731 1710 if ((err = substream->ops->silence(substream, c, hwoff, frames)) < 0) ··· 1740 1717 } else { 1741 1718 /* default transfer behaviour */ 1742 1719 size_t dma_csize = runtime->dma_bytes / channels; 1743 - snd_assert(runtime->dma_area, return -EFAULT); 1744 1720 for (c = 0; c < channels; ++c, ++bufs) { 1745 1721 char *hwbuf = runtime->dma_area + (c * dma_csize) + samples_to_bytes(runtime, hwoff); 1746 1722 if (*bufs == NULL) { ··· 1760 1738 { 1761 1739 struct snd_pcm_runtime *runtime; 1762 1740 int nonblock; 1741 + int err; 1763 1742 1764 - snd_assert(substream != NULL, return -ENXIO); 1743 + err = pcm_sanity_check(substream); 1744 + if (err < 0) 1745 + return err; 1765 1746 runtime = substream->runtime; 1766 - snd_assert(runtime != NULL, return -ENXIO); 1767 - snd_assert(substream->ops->copy != NULL || runtime->dma_area != NULL, return -EINVAL); 1768 - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 1769 - return -EBADFD; 1770 - 1771 1747 nonblock = !!(substream->f_flags & O_NONBLOCK); 1772 1748 1773 1749 if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) ··· 1789 1769 return err; 1790 1770 } else { 1791 1771 char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff); 1792 - snd_assert(runtime->dma_area, return -EFAULT); 1793 1772 if (copy_to_user(buf, hwbuf, frames_to_bytes(runtime, frames))) 1794 1773 return -EFAULT; 1795 1774 } ··· 1860 1841 cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; 1861 1842 if (frames > cont) 1862 1843 frames = cont; 1863 - snd_assert(frames != 0, snd_pcm_stream_unlock_irq(substream); return -EINVAL); 1844 + if (snd_BUG_ON(!frames)) { 1845 + snd_pcm_stream_unlock_irq(substream); 1846 + return -EINVAL; 1847 + } 1864 1848 appl_ptr = runtime->control->appl_ptr; 1865 1849 appl_ofs = appl_ptr % runtime->buffer_size; 1866 1850 snd_pcm_stream_unlock_irq(substream); ··· 1901 1879 { 1902 1880 struct snd_pcm_runtime *runtime; 1903 1881 int nonblock; 1882 + int err; 1904 1883 1905 - snd_assert(substream != NULL, return -ENXIO); 1884 + err = pcm_sanity_check(substream); 1885 + if (err < 0) 1886 + return err; 1906 1887 runtime = substream->runtime; 1907 - snd_assert(runtime != NULL, return -ENXIO); 1908 - snd_assert(substream->ops->copy != NULL || runtime->dma_area != NULL, return -EINVAL); 1909 - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 1910 - return -EBADFD; 1911 - 1912 1888 nonblock = !!(substream->f_flags & O_NONBLOCK); 1913 1889 if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED) 1914 1890 return -EINVAL; ··· 1936 1916 } 1937 1917 } else { 1938 1918 snd_pcm_uframes_t dma_csize = runtime->dma_bytes / channels; 1939 - snd_assert(runtime->dma_area, return -EFAULT); 1940 1919 for (c = 0; c < channels; ++c, ++bufs) { 1941 1920 char *hwbuf; 1942 1921 char __user *buf; ··· 1957 1938 { 1958 1939 struct snd_pcm_runtime *runtime; 1959 1940 int nonblock; 1941 + int err; 1960 1942 1961 - snd_assert(substream != NULL, return -ENXIO); 1943 + err = pcm_sanity_check(substream); 1944 + if (err < 0) 1945 + return err; 1962 1946 runtime = substream->runtime; 1963 - snd_assert(runtime != NULL, return -ENXIO); 1964 - snd_assert(substream->ops->copy != NULL || runtime->dma_area != NULL, return -EINVAL); 1965 1947 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 1966 1948 return -EBADFD; 1967 1949
+7 -7
sound/core/pcm_memory.c
··· 50 50 struct snd_dma_buffer *dmab = &substream->dma_buffer; 51 51 int err; 52 52 53 - snd_assert(size > 0, return -EINVAL); 54 - 55 53 /* already reserved? */ 56 54 if (snd_dma_get_reserved_buf(dmab, substream->dma_buf_id) > 0) { 57 55 if (dmab->bytes >= size) ··· 340 342 struct snd_pcm_runtime *runtime; 341 343 struct snd_dma_buffer *dmab = NULL; 342 344 343 - snd_assert(substream->dma_buffer.dev.type != SNDRV_DMA_TYPE_UNKNOWN, return -EINVAL); 344 - snd_assert(substream != NULL, return -EINVAL); 345 + if (PCM_RUNTIME_CHECK(substream)) 346 + return -EINVAL; 347 + if (snd_BUG_ON(substream->dma_buffer.dev.type == 348 + SNDRV_DMA_TYPE_UNKNOWN)) 349 + return -EINVAL; 345 350 runtime = substream->runtime; 346 - snd_assert(runtime != NULL, return -EINVAL); 347 351 348 352 if (runtime->dma_buffer_p) { 349 353 /* perphaps, we might free the large DMA memory region ··· 391 391 { 392 392 struct snd_pcm_runtime *runtime; 393 393 394 - snd_assert(substream != NULL, return -EINVAL); 394 + if (PCM_RUNTIME_CHECK(substream)) 395 + return -EINVAL; 395 396 runtime = substream->runtime; 396 - snd_assert(runtime != NULL, return -EINVAL); 397 397 if (runtime->dma_area == NULL) 398 398 return 0; 399 399 if (runtime->dma_buffer_p != &substream->dma_buffer) {
+64 -63
sound/core/pcm_native.c
··· 95 95 struct snd_pcm *pcm = substream->pcm; 96 96 struct snd_pcm_str *pstr = substream->pstr; 97 97 98 - snd_assert(substream != NULL, return -ENXIO); 99 98 memset(info, 0, sizeof(*info)); 100 99 info->card = pcm->card->number; 101 100 info->device = pcm->device; ··· 369 370 unsigned int bits; 370 371 snd_pcm_uframes_t frames; 371 372 372 - snd_assert(substream != NULL, return -ENXIO); 373 + if (PCM_RUNTIME_CHECK(substream)) 374 + return -ENXIO; 373 375 runtime = substream->runtime; 374 - snd_assert(runtime != NULL, return -ENXIO); 375 376 snd_pcm_stream_lock_irq(substream); 376 377 switch (runtime->status->state) { 377 378 case SNDRV_PCM_STATE_OPEN: ··· 489 490 struct snd_pcm_runtime *runtime; 490 491 int result = 0; 491 492 492 - snd_assert(substream != NULL, return -ENXIO); 493 + if (PCM_RUNTIME_CHECK(substream)) 494 + return -ENXIO; 493 495 runtime = substream->runtime; 494 - snd_assert(runtime != NULL, return -ENXIO); 495 496 snd_pcm_stream_lock_irq(substream); 496 497 switch (runtime->status->state) { 497 498 case SNDRV_PCM_STATE_SETUP: ··· 517 518 { 518 519 struct snd_pcm_runtime *runtime; 519 520 520 - snd_assert(substream != NULL, return -ENXIO); 521 + if (PCM_RUNTIME_CHECK(substream)) 522 + return -ENXIO; 521 523 runtime = substream->runtime; 522 - snd_assert(runtime != NULL, return -ENXIO); 523 524 snd_pcm_stream_lock_irq(substream); 524 525 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { 525 526 snd_pcm_stream_unlock_irq(substream); ··· 621 622 struct snd_pcm_status __user * _status) 622 623 { 623 624 struct snd_pcm_status status; 624 - struct snd_pcm_runtime *runtime; 625 625 int res; 626 626 627 - snd_assert(substream != NULL, return -ENXIO); 628 - runtime = substream->runtime; 629 627 memset(&status, 0, sizeof(status)); 630 628 res = snd_pcm_status(substream, &status); 631 629 if (res < 0) ··· 638 642 struct snd_pcm_runtime *runtime; 639 643 unsigned int channel; 640 644 641 - snd_assert(substream != NULL, return -ENXIO); 642 645 channel = info->channel; 643 646 runtime = substream->runtime; 644 647 snd_pcm_stream_lock_irq(substream); ··· 1245 1250 int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); 1246 1251 if (err < 0) 1247 1252 return err; 1248 - // snd_assert(runtime->status->hw_ptr < runtime->buffer_size, ); 1249 1253 runtime->hw_ptr_base = 0; 1250 1254 runtime->hw_ptr_interrupt = runtime->status->hw_ptr - 1251 1255 runtime->status->hw_ptr % runtime->period_size; ··· 1415 1421 int i, num_drecs; 1416 1422 struct drain_rec *drec, drec_tmp, *d; 1417 1423 1418 - snd_assert(substream != NULL, return -ENXIO); 1419 1424 card = substream->pcm->card; 1420 1425 runtime = substream->runtime; 1421 1426 ··· 1534 1541 struct snd_card *card; 1535 1542 int result = 0; 1536 1543 1537 - snd_assert(substream != NULL, return -ENXIO); 1544 + if (PCM_RUNTIME_CHECK(substream)) 1545 + return -ENXIO; 1538 1546 runtime = substream->runtime; 1539 1547 card = substream->pcm->card; 1540 1548 ··· 1928 1934 mask |= 1 << SNDRV_PCM_ACCESS_MMAP_COMPLEX; 1929 1935 } 1930 1936 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); 1931 - snd_assert(err >= 0, return -EINVAL); 1937 + if (err < 0) 1938 + return err; 1932 1939 1933 1940 err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); 1934 - snd_assert(err >= 0, return -EINVAL); 1941 + if (err < 0) 1942 + return err; 1935 1943 1936 1944 err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, 1 << SNDRV_PCM_SUBFORMAT_STD); 1937 - snd_assert(err >= 0, return -EINVAL); 1945 + if (err < 0) 1946 + return err; 1938 1947 1939 1948 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 1940 1949 hw->channels_min, hw->channels_max); 1941 - snd_assert(err >= 0, return -EINVAL); 1950 + if (err < 0) 1951 + return err; 1942 1952 1943 1953 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, 1944 1954 hw->rate_min, hw->rate_max); 1945 - snd_assert(err >= 0, return -EINVAL); 1955 + if (err < 0) 1956 + return err; 1946 1957 1947 1958 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 1948 1959 hw->period_bytes_min, hw->period_bytes_max); 1949 - snd_assert(err >= 0, return -EINVAL); 1960 + if (err < 0) 1961 + return err; 1950 1962 1951 1963 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, 1952 1964 hw->periods_min, hw->periods_max); 1953 - snd_assert(err >= 0, return -EINVAL); 1965 + if (err < 0) 1966 + return err; 1954 1967 1955 1968 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1956 1969 hw->period_bytes_min, hw->buffer_bytes_max); 1957 - snd_assert(err >= 0, return -EINVAL); 1970 + if (err < 0) 1971 + return err; 1958 1972 1959 1973 err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 1960 1974 snd_pcm_hw_rule_buffer_bytes_max, substream, ··· 1973 1971 /* FIXME: remove */ 1974 1972 if (runtime->dma_bytes) { 1975 1973 err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes); 1976 - snd_assert(err >= 0, return -EINVAL); 1974 + if (err < 0) 1975 + return -EINVAL; 1977 1976 } 1978 1977 1979 1978 if (!(hw->rates & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))) { ··· 2070 2067 struct snd_pcm_str *str; 2071 2068 int err; 2072 2069 2073 - snd_assert(rpcm_file != NULL, return -EINVAL); 2074 - *rpcm_file = NULL; 2070 + if (rpcm_file) 2071 + *rpcm_file = NULL; 2075 2072 2076 2073 err = snd_pcm_open_substream(pcm, stream, file, &substream); 2077 2074 if (err < 0) ··· 2089 2086 substream->pcm_release = pcm_release_private; 2090 2087 } 2091 2088 file->private_data = pcm_file; 2092 - *rpcm_file = pcm_file; 2089 + if (rpcm_file) 2090 + *rpcm_file = pcm_file; 2093 2091 return 0; 2094 2092 } 2095 2093 ··· 2174 2170 2175 2171 pcm_file = file->private_data; 2176 2172 substream = pcm_file->substream; 2177 - snd_assert(substream != NULL, return -ENXIO); 2173 + if (snd_BUG_ON(!substream)) 2174 + return -ENXIO; 2178 2175 pcm = substream->pcm; 2179 2176 fasync_helper(-1, file, 0, &substream->runtime->fasync); 2180 2177 mutex_lock(&pcm->open_mutex); ··· 2498 2493 struct snd_pcm_substream *substream, 2499 2494 unsigned int cmd, void __user *arg) 2500 2495 { 2501 - snd_assert(substream != NULL, return -ENXIO); 2502 - 2503 2496 switch (cmd) { 2504 2497 case SNDRV_PCM_IOCTL_PVERSION: 2505 2498 return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0; ··· 2566 2563 struct snd_pcm_substream *substream, 2567 2564 unsigned int cmd, void __user *arg) 2568 2565 { 2569 - snd_assert(substream != NULL, return -ENXIO); 2570 - snd_assert(substream->stream == SNDRV_PCM_STREAM_PLAYBACK, return -EINVAL); 2566 + if (snd_BUG_ON(!substream)) 2567 + return -ENXIO; 2568 + if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) 2569 + return -EINVAL; 2571 2570 switch (cmd) { 2572 2571 case SNDRV_PCM_IOCTL_WRITEI_FRAMES: 2573 2572 { ··· 2648 2643 struct snd_pcm_substream *substream, 2649 2644 unsigned int cmd, void __user *arg) 2650 2645 { 2651 - snd_assert(substream != NULL, return -ENXIO); 2652 - snd_assert(substream->stream == SNDRV_PCM_STREAM_CAPTURE, return -EINVAL); 2646 + if (snd_BUG_ON(!substream)) 2647 + return -ENXIO; 2648 + if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_CAPTURE)) 2649 + return -EINVAL; 2653 2650 switch (cmd) { 2654 2651 case SNDRV_PCM_IOCTL_READI_FRAMES: 2655 2652 { ··· 2790 2783 2791 2784 pcm_file = file->private_data; 2792 2785 substream = pcm_file->substream; 2793 - snd_assert(substream != NULL, return -ENXIO); 2786 + if (PCM_RUNTIME_CHECK(substream)) 2787 + return -ENXIO; 2794 2788 runtime = substream->runtime; 2795 2789 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 2796 2790 return -EBADFD; ··· 2814 2806 2815 2807 pcm_file = file->private_data; 2816 2808 substream = pcm_file->substream; 2817 - snd_assert(substream != NULL, result = -ENXIO; goto end); 2809 + if (PCM_RUNTIME_CHECK(substream)) 2810 + return -ENXIO; 2818 2811 runtime = substream->runtime; 2819 - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { 2820 - result = -EBADFD; 2821 - goto end; 2822 - } 2823 - if (!frame_aligned(runtime, count)) { 2824 - result = -EINVAL; 2825 - goto end; 2826 - } 2812 + if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 2813 + return -EBADFD; 2814 + if (!frame_aligned(runtime, count)) 2815 + return -EINVAL; 2827 2816 count = bytes_to_frames(runtime, count); 2828 2817 result = snd_pcm_lib_write(substream, buf, count); 2829 2818 if (result > 0) 2830 2819 result = frames_to_bytes(runtime, result); 2831 - end: 2832 2820 return result; 2833 2821 } 2834 2822 ··· 2842 2838 2843 2839 pcm_file = iocb->ki_filp->private_data; 2844 2840 substream = pcm_file->substream; 2845 - snd_assert(substream != NULL, return -ENXIO); 2841 + if (PCM_RUNTIME_CHECK(substream)) 2842 + return -ENXIO; 2846 2843 runtime = substream->runtime; 2847 2844 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 2848 2845 return -EBADFD; ··· 2877 2872 2878 2873 pcm_file = iocb->ki_filp->private_data; 2879 2874 substream = pcm_file->substream; 2880 - snd_assert(substream != NULL, result = -ENXIO; goto end); 2875 + if (PCM_RUNTIME_CHECK(substream)) 2876 + return -ENXIO; 2881 2877 runtime = substream->runtime; 2882 - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { 2883 - result = -EBADFD; 2884 - goto end; 2885 - } 2878 + if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 2879 + return -EBADFD; 2886 2880 if (nr_segs > 128 || nr_segs != runtime->channels || 2887 - !frame_aligned(runtime, iov->iov_len)) { 2888 - result = -EINVAL; 2889 - goto end; 2890 - } 2881 + !frame_aligned(runtime, iov->iov_len)) 2882 + return -EINVAL; 2891 2883 frames = bytes_to_samples(runtime, iov->iov_len); 2892 2884 bufs = kmalloc(sizeof(void *) * nr_segs, GFP_KERNEL); 2893 2885 if (bufs == NULL) ··· 2895 2893 if (result > 0) 2896 2894 result = frames_to_bytes(runtime, result); 2897 2895 kfree(bufs); 2898 - end: 2899 2896 return result; 2900 2897 } 2901 2898 ··· 2909 2908 pcm_file = file->private_data; 2910 2909 2911 2910 substream = pcm_file->substream; 2912 - snd_assert(substream != NULL, return -ENXIO); 2911 + if (PCM_RUNTIME_CHECK(substream)) 2912 + return -ENXIO; 2913 2913 runtime = substream->runtime; 2914 2914 2915 2915 poll_wait(file, &runtime->sleep, wait); ··· 2948 2946 pcm_file = file->private_data; 2949 2947 2950 2948 substream = pcm_file->substream; 2951 - snd_assert(substream != NULL, return -ENXIO); 2949 + if (PCM_RUNTIME_CHECK(substream)) 2950 + return -ENXIO; 2952 2951 runtime = substream->runtime; 2953 2952 2954 2953 poll_wait(file, &runtime->sleep, wait); ··· 3019 3016 if (!(area->vm_flags & VM_READ)) 3020 3017 return -EINVAL; 3021 3018 runtime = substream->runtime; 3022 - snd_assert(runtime != NULL, return -EAGAIN); 3023 3019 size = area->vm_end - area->vm_start; 3024 3020 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) 3025 3021 return -EINVAL; ··· 3058 3056 if (!(area->vm_flags & VM_READ)) 3059 3057 return -EINVAL; 3060 3058 runtime = substream->runtime; 3061 - snd_assert(runtime != NULL, return -EAGAIN); 3062 3059 size = area->vm_end - area->vm_start; 3063 3060 if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))) 3064 3061 return -EINVAL; ··· 3189 3188 return -EINVAL; 3190 3189 } 3191 3190 runtime = substream->runtime; 3192 - snd_assert(runtime != NULL, return -EAGAIN); 3193 3191 if (runtime->status->state == SNDRV_PCM_STATE_OPEN) 3194 3192 return -EBADFD; 3195 3193 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) ··· 3220 3220 3221 3221 pcm_file = file->private_data; 3222 3222 substream = pcm_file->substream; 3223 - snd_assert(substream != NULL, return -ENXIO); 3223 + if (PCM_RUNTIME_CHECK(substream)) 3224 + return -ENXIO; 3224 3225 3225 3226 offset = area->vm_pgoff << PAGE_SHIFT; 3226 3227 switch (offset) { ··· 3249 3248 lock_kernel(); 3250 3249 pcm_file = file->private_data; 3251 3250 substream = pcm_file->substream; 3252 - snd_assert(substream != NULL, goto out); 3251 + if (PCM_RUNTIME_CHECK(substream)) 3252 + goto out; 3253 3253 runtime = substream->runtime; 3254 - 3255 3254 err = fasync_helper(fd, file, on, &runtime->fasync); 3256 3255 out: 3257 3256 unlock_kernel();
+4 -2
sound/core/pcm_timer.c
··· 51 51 52 52 mult = 1000000000; 53 53 rate = runtime->rate; 54 - snd_assert(rate != 0, return); 54 + if (snd_BUG_ON(!rate)) 55 + return; 55 56 l = gcd(mult, rate); 56 57 mult /= l; 57 58 rate /= l; 58 59 fsize = runtime->period_size; 59 - snd_assert(fsize != 0, return); 60 + if (snd_BUG_ON(!fsize)) 61 + return; 60 62 l = gcd(rate, fsize); 61 63 rate /= l; 62 64 fsize /= l;
+15 -10
sound/core/rawmidi.c
··· 470 470 struct snd_rawmidi_substream *substream; 471 471 struct snd_rawmidi_runtime *runtime; 472 472 473 - snd_assert(rfile != NULL, return -ENXIO); 474 - snd_assert(rfile->input != NULL || rfile->output != NULL, return -ENXIO); 473 + if (snd_BUG_ON(!rfile)) 474 + return -ENXIO; 475 475 rmidi = rfile->rmidi; 476 476 mutex_lock(&rmidi->open_mutex); 477 477 if (rfile->input != NULL) { ··· 1100 1100 return -EINVAL; 1101 1101 } 1102 1102 spin_lock_irqsave(&runtime->lock, flags); 1103 - snd_assert(runtime->avail + count <= runtime->buffer_size, ); 1103 + snd_BUG_ON(runtime->avail + count > runtime->buffer_size); 1104 1104 runtime->hw_ptr += count; 1105 1105 runtime->hw_ptr %= runtime->buffer_size; 1106 1106 runtime->avail += count; ··· 1141 1141 long count1, result; 1142 1142 struct snd_rawmidi_runtime *runtime = substream->runtime; 1143 1143 1144 - snd_assert(kernelbuf != NULL || userbuf != NULL, return -EINVAL); 1145 - snd_assert(runtime->buffer != NULL, return -EINVAL); 1144 + if (snd_BUG_ON(!kernelbuf && !userbuf)) 1145 + return -EINVAL; 1146 + if (snd_BUG_ON(!runtime->buffer)) 1147 + return -EINVAL; 1146 1148 1147 1149 result = 0; 1148 1150 spin_lock_irqsave(&runtime->lock, flags); ··· 1422 1420 .dev_disconnect = snd_rawmidi_dev_disconnect, 1423 1421 }; 1424 1422 1425 - snd_assert(rrawmidi != NULL, return -EINVAL); 1426 - *rrawmidi = NULL; 1427 - snd_assert(card != NULL, return -ENXIO); 1423 + if (snd_BUG_ON(!card)) 1424 + return -ENXIO; 1425 + if (rrawmidi) 1426 + *rrawmidi = NULL; 1428 1427 rmidi = kzalloc(sizeof(*rmidi), GFP_KERNEL); 1429 1428 if (rmidi == NULL) { 1430 1429 snd_printk(KERN_ERR "rawmidi: cannot allocate\n"); ··· 1458 1455 snd_rawmidi_free(rmidi); 1459 1456 return err; 1460 1457 } 1461 - *rrawmidi = rmidi; 1458 + if (rrawmidi) 1459 + *rrawmidi = rmidi; 1462 1460 return 0; 1463 1461 } 1464 1462 ··· 1476 1472 1477 1473 static int snd_rawmidi_free(struct snd_rawmidi *rmidi) 1478 1474 { 1479 - snd_assert(rmidi != NULL, return -ENXIO); 1475 + if (!rmidi) 1476 + return 0; 1480 1477 1481 1478 snd_info_free_entry(rmidi->proc_entry); 1482 1479 rmidi->proc_entry = NULL;
+4 -2
sound/core/rtctimer.c
··· 91 91 rtctimer_start(struct snd_timer *timer) 92 92 { 93 93 rtc_task_t *rtc = timer->private_data; 94 - snd_assert(rtc != NULL, return -EINVAL); 94 + if (snd_BUG_ON(!rtc)) 95 + return -EINVAL; 95 96 rtc_control(rtc, RTC_IRQP_SET, rtctimer_freq); 96 97 rtc_control(rtc, RTC_PIE_ON, 0); 97 98 return 0; ··· 102 101 rtctimer_stop(struct snd_timer *timer) 103 102 { 104 103 rtc_task_t *rtc = timer->private_data; 105 - snd_assert(rtc != NULL, return -EINVAL); 104 + if (snd_BUG_ON(!rtc)) 105 + return -EINVAL; 106 106 rtc_control(rtc, RTC_PIE_OFF, 0); 107 107 return 0; 108 108 }
+8 -4
sound/core/seq/oss/seq_oss.c
··· 164 164 { 165 165 struct seq_oss_devinfo *dp; 166 166 dp = file->private_data; 167 - snd_assert(dp != NULL, return -EIO); 167 + if (snd_BUG_ON(!dp)) 168 + return -ENXIO; 168 169 return snd_seq_oss_read(dp, buf, count); 169 170 } 170 171 ··· 175 174 { 176 175 struct seq_oss_devinfo *dp; 177 176 dp = file->private_data; 178 - snd_assert(dp != NULL, return -EIO); 177 + if (snd_BUG_ON(!dp)) 178 + return -ENXIO; 179 179 return snd_seq_oss_write(dp, buf, count, file); 180 180 } 181 181 ··· 185 183 { 186 184 struct seq_oss_devinfo *dp; 187 185 dp = file->private_data; 188 - snd_assert(dp != NULL, return -EIO); 186 + if (snd_BUG_ON(!dp)) 187 + return -ENXIO; 189 188 return snd_seq_oss_ioctl(dp, cmd, arg); 190 189 } 191 190 ··· 201 198 { 202 199 struct seq_oss_devinfo *dp; 203 200 dp = file->private_data; 204 - snd_assert(dp != NULL, return 0); 201 + if (snd_BUG_ON(!dp)) 202 + return -ENXIO; 205 203 return snd_seq_oss_poll(dp, file, wait); 206 204 } 207 205
+4 -2
sound/core/seq/oss/seq_oss_synth.c
··· 308 308 struct seq_oss_synth *rec; 309 309 struct seq_oss_synthinfo *info; 310 310 311 - snd_assert(dp->max_synthdev <= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS, return); 311 + if (snd_BUG_ON(dp->max_synthdev >= SNDRV_SEQ_OSS_MAX_SYNTH_DEVS)) 312 + return; 312 313 for (i = 0; i < dp->max_synthdev; i++) { 313 314 info = &dp->synths[i]; 314 315 if (! info->opened) ··· 403 402 struct seq_oss_synth *rec; 404 403 struct seq_oss_synthinfo *info; 405 404 406 - snd_assert(dev >= 0 && dev < dp->max_synthdev, return); 405 + if (snd_BUG_ON(dev < 0 || dev >= dp->max_synthdev)) 406 + return; 407 407 info = &dp->synths[dev]; 408 408 if (! info->opened) 409 409 return;
+20 -10
sound/core/seq/seq_clientmgr.c
··· 266 266 { 267 267 unsigned long flags; 268 268 269 - snd_assert(client != NULL, return -EINVAL); 269 + if (!client) 270 + return 0; 270 271 snd_seq_delete_all_ports(client); 271 272 snd_seq_queue_client_leave(client->number); 272 273 spin_lock_irqsave(&clients_lock, flags); ··· 404 403 return -EFAULT; 405 404 406 405 /* check client structures are in place */ 407 - snd_assert(client != NULL, return -ENXIO); 406 + if (snd_BUG_ON(!client)) 407 + return -ENXIO; 408 408 409 409 if (!client->accept_input || (fifo = client->data.user.fifo) == NULL) 410 410 return -ENXIO; ··· 827 825 struct snd_seq_client *client; 828 826 int result; 829 827 830 - snd_assert(cell != NULL, return -EINVAL); 828 + if (snd_BUG_ON(!cell)) 829 + return -EINVAL; 831 830 832 831 client = snd_seq_client_use_ptr(cell->event.source.client); 833 832 if (client == NULL) { ··· 997 994 return -ENXIO; 998 995 999 996 /* check client structures are in place */ 1000 - snd_assert(client != NULL, return -ENXIO); 997 + if (snd_BUG_ON(!client)) 998 + return -ENXIO; 1001 999 1002 1000 if (!client->accept_output || client->pool == NULL) 1003 1001 return -ENXIO; ··· 1080 1076 unsigned int mask = 0; 1081 1077 1082 1078 /* check client structures are in place */ 1083 - snd_assert(client != NULL, return -ENXIO); 1079 + if (snd_BUG_ON(!client)) 1080 + return -ENXIO; 1084 1081 1085 1082 if ((snd_seq_file_flags(file) & SNDRV_SEQ_LFLG_INPUT) && 1086 1083 client->data.user.fifo) { ··· 2200 2195 { 2201 2196 struct snd_seq_client *client = file->private_data; 2202 2197 2203 - snd_assert(client != NULL, return -ENXIO); 2198 + if (snd_BUG_ON(!client)) 2199 + return -ENXIO; 2204 2200 2205 2201 return snd_seq_do_ioctl(client, cmd, (void __user *) arg); 2206 2202 } ··· 2222 2216 struct snd_seq_client *client; 2223 2217 va_list args; 2224 2218 2225 - snd_assert(! in_interrupt(), return -EBUSY); 2219 + if (snd_BUG_ON(in_interrupt())) 2220 + return -EBUSY; 2226 2221 2227 2222 if (card && client_index >= SNDRV_SEQ_CLIENTS_PER_CARD) 2228 2223 return -EINVAL; ··· 2272 2265 { 2273 2266 struct snd_seq_client *ptr; 2274 2267 2275 - snd_assert(! in_interrupt(), return -EBUSY); 2268 + if (snd_BUG_ON(in_interrupt())) 2269 + return -EBUSY; 2276 2270 2277 2271 ptr = clientptr(client); 2278 2272 if (ptr == NULL) ··· 2296 2288 struct snd_seq_client *cptr; 2297 2289 int result; 2298 2290 2299 - snd_assert(ev != NULL, return -EINVAL); 2291 + if (snd_BUG_ON(!ev)) 2292 + return -EINVAL; 2300 2293 2301 2294 if (ev->type == SNDRV_SEQ_EVENT_NONE) 2302 2295 return 0; /* ignore this */ ··· 2363 2354 struct snd_seq_client *cptr; 2364 2355 int result; 2365 2356 2366 - snd_assert(ev != NULL, return -EINVAL); 2357 + if (snd_BUG_ON(!ev)) 2358 + return -EINVAL; 2367 2359 2368 2360 /* fill in client number */ 2369 2361 ev->queue = SNDRV_SEQ_QUEUE_DIRECT;
+2 -1
sound/core/seq/seq_compat.c
··· 92 92 struct snd_seq_client *client = file->private_data; 93 93 void __user *argp = compat_ptr(arg); 94 94 95 - snd_assert(client != NULL, return -ENXIO); 95 + if (snd_BUG_ON(!client)) 96 + return -ENXIO; 96 97 97 98 switch (cmd) { 98 99 case SNDRV_SEQ_IOCTL_PVERSION:
+4 -2
sound/core/seq/seq_device.c
··· 187 187 if (result) 188 188 *result = NULL; 189 189 190 - snd_assert(id != NULL, return -EINVAL); 190 + if (snd_BUG_ON(!id)) 191 + return -EINVAL; 191 192 192 193 ops = find_driver(id, 1); 193 194 if (ops == NULL) ··· 233 232 { 234 233 struct ops_list *ops; 235 234 236 - snd_assert(dev != NULL, return -EINVAL); 235 + if (snd_BUG_ON(!dev)) 236 + return -EINVAL; 237 237 238 238 ops = find_driver(dev->id, 0); 239 239 if (ops == NULL)
+10 -5
sound/core/seq/seq_fifo.c
··· 65 65 { 66 66 struct snd_seq_fifo *f; 67 67 68 - snd_assert(fifo != NULL, return); 68 + if (snd_BUG_ON(!fifo)) 69 + return; 69 70 f = *fifo; 70 - snd_assert(f != NULL, return); 71 + if (snd_BUG_ON(!f)) 72 + return; 71 73 *fifo = NULL; 72 74 73 75 snd_seq_fifo_clear(f); ··· 118 116 unsigned long flags; 119 117 int err; 120 118 121 - snd_assert(f != NULL, return -EINVAL); 119 + if (snd_BUG_ON(!f)) 120 + return -EINVAL; 122 121 123 122 snd_use_lock_use(&f->use_lock); 124 123 err = snd_seq_event_dup(f->pool, event, &cell, 1, NULL); /* always non-blocking */ ··· 177 174 unsigned long flags; 178 175 wait_queue_t wait; 179 176 180 - snd_assert(f != NULL, return -EINVAL); 177 + if (snd_BUG_ON(!f)) 178 + return -EINVAL; 181 179 182 180 *cellp = NULL; 183 181 init_waitqueue_entry(&wait, current); ··· 237 233 struct snd_seq_pool *newpool, *oldpool; 238 234 struct snd_seq_event_cell *cell, *next, *oldhead; 239 235 240 - snd_assert(f != NULL && f->pool != NULL, return -EINVAL); 236 + if (snd_BUG_ON(!f || !f->pool)) 237 + return -EINVAL; 241 238 242 239 /* allocate new pool */ 243 240 newpool = snd_seq_pool_new(poolsize);
+8 -4
sound/core/seq/seq_memory.c
··· 187 187 unsigned long flags; 188 188 struct snd_seq_pool *pool; 189 189 190 - snd_assert(cell != NULL, return); 190 + if (snd_BUG_ON(!cell)) 191 + return; 191 192 pool = cell->pool; 192 - snd_assert(pool != NULL, return); 193 + if (snd_BUG_ON(!pool)) 194 + return; 193 195 194 196 spin_lock_irqsave(&pool->lock, flags); 195 197 free_cell(pool, cell); ··· 380 378 struct snd_seq_event_cell *cellptr; 381 379 unsigned long flags; 382 380 383 - snd_assert(pool != NULL, return -EINVAL); 381 + if (snd_BUG_ON(!pool)) 382 + return -EINVAL; 384 383 if (pool->ptr) /* should be atomic? */ 385 384 return 0; 386 385 ··· 417 414 struct snd_seq_event_cell *ptr; 418 415 int max_count = 5 * HZ; 419 416 420 - snd_assert(pool != NULL, return -EINVAL); 417 + if (snd_BUG_ON(!pool)) 418 + return -EINVAL; 421 419 422 420 /* wait for closing all threads */ 423 421 spin_lock_irqsave(&pool->lock, flags);
+10 -5
sound/core/seq/seq_midi.c
··· 116 116 struct snd_rawmidi_runtime *runtime; 117 117 int tmp; 118 118 119 - snd_assert(substream != NULL || buf != NULL, return -EINVAL); 119 + if (snd_BUG_ON(!substream || !buf)) 120 + return -EINVAL; 120 121 runtime = substream->runtime; 121 122 if ((tmp = runtime->avail) < count) { 122 123 snd_printd("warning, output event was lost (count = %i, available = %i)\n", count, tmp); ··· 136 135 struct snd_rawmidi_substream *substream; 137 136 int len; 138 137 139 - snd_assert(msynth != NULL, return -EINVAL); 138 + if (snd_BUG_ON(!msynth)) 139 + return -EINVAL; 140 140 substream = msynth->output_rfile.output; 141 141 if (substream == NULL) 142 142 return -ENODEV; ··· 212 210 int err; 213 211 struct seq_midisynth *msynth = private_data; 214 212 215 - snd_assert(msynth->input_rfile.input != NULL, return -EINVAL); 213 + if (snd_BUG_ON(!msynth->input_rfile.input)) 214 + return -EINVAL; 216 215 err = snd_rawmidi_kernel_release(&msynth->input_rfile); 217 216 return err; 218 217 } ··· 250 247 struct seq_midisynth *msynth = private_data; 251 248 unsigned char buf = 0xff; /* MIDI reset */ 252 249 253 - snd_assert(msynth->output_rfile.output != NULL, return -EINVAL); 250 + if (snd_BUG_ON(!msynth->output_rfile.output)) 251 + return -EINVAL; 254 252 /* sending single MIDI reset message to shut the device up */ 255 253 snd_rawmidi_kernel_write(msynth->output_rfile.output, &buf, 1); 256 254 snd_rawmidi_drain_output(msynth->output_rfile.output); ··· 289 285 int device = dev->device; 290 286 unsigned int input_count = 0, output_count = 0; 291 287 292 - snd_assert(card != NULL && device >= 0 && device < SNDRV_RAWMIDI_DEVICES, return -EINVAL); 288 + if (snd_BUG_ON(!card || device < 0 || device >= SNDRV_RAWMIDI_DEVICES)) 289 + return -EINVAL; 293 290 info = kmalloc(sizeof(*info), GFP_KERNEL); 294 291 if (! info) 295 292 return -ENOMEM;
+8 -5
sound/core/seq/seq_ports.c
··· 130 130 int num = -1; 131 131 132 132 /* sanity check */ 133 - snd_assert(client, return NULL); 133 + if (snd_BUG_ON(!client)) 134 + return NULL; 134 135 135 136 if (client->num_ports >= SNDRV_SEQ_MAX_PORTS - 1) { 136 137 snd_printk(KERN_WARNING "too many ports for client %d\n", client->number); ··· 269 268 if (port->private_free) 270 269 port->private_free(port->private_data); 271 270 272 - snd_assert(port->c_src.count == 0,); 273 - snd_assert(port->c_dest.count == 0,); 271 + snd_BUG_ON(port->c_src.count != 0); 272 + snd_BUG_ON(port->c_dest.count != 0); 274 273 275 274 kfree(port); 276 275 return 0; ··· 337 336 int snd_seq_set_port_info(struct snd_seq_client_port * port, 338 337 struct snd_seq_port_info * info) 339 338 { 340 - snd_assert(port && info, return -EINVAL); 339 + if (snd_BUG_ON(!port || !info)) 340 + return -EINVAL; 341 341 342 342 /* set port name */ 343 343 if (info->name[0]) ··· 367 365 int snd_seq_get_port_info(struct snd_seq_client_port * port, 368 366 struct snd_seq_port_info * info) 369 367 { 370 - snd_assert(port && info, return -EINVAL); 368 + if (snd_BUG_ON(!port || !info)) 369 + return -EINVAL; 371 370 372 371 /* get port name */ 373 372 strlcpy(info->name, port->name, sizeof(info->name));
+2 -2
sound/core/seq/seq_prioq.c
··· 153 153 int count; 154 154 int prior; 155 155 156 - snd_assert(f, return -EINVAL); 157 - snd_assert(cell, return -EINVAL); 156 + if (snd_BUG_ON(!f || !cell)) 157 + return -EINVAL; 158 158 159 159 /* check flags */ 160 160 prior = (cell->event.flags & SNDRV_SEQ_PRIORITY_MASK);
+4 -2
sound/core/seq/seq_queue.c
··· 315 315 int dest, err; 316 316 struct snd_seq_queue *q; 317 317 318 - snd_assert(cell != NULL, return -EINVAL); 318 + if (snd_BUG_ON(!cell)) 319 + return -EINVAL; 319 320 dest = cell->event.queue; /* destination queue */ 320 321 q = queueptr(dest); 321 322 if (q == NULL) ··· 735 734 { 736 735 struct snd_seq_queue *q; 737 736 738 - snd_assert(ev != NULL, return -EINVAL); 737 + if (snd_BUG_ON(!ev)) 738 + return -EINVAL; 739 739 q = queueptr(ev->data.queue.queue); 740 740 741 741 if (q == NULL)
+16 -8
sound/core/seq/seq_timer.c
··· 173 173 { 174 174 unsigned long flags; 175 175 176 - snd_assert(tmr, return -EINVAL); 176 + if (snd_BUG_ON(!tmr)) 177 + return -EINVAL; 177 178 if (tempo <= 0) 178 179 return -EINVAL; 179 180 spin_lock_irqsave(&tmr->lock, flags); ··· 191 190 { 192 191 unsigned long flags; 193 192 194 - snd_assert(tmr, return -EINVAL); 193 + if (snd_BUG_ON(!tmr)) 194 + return -EINVAL; 195 195 if (ppq <= 0) 196 196 return -EINVAL; 197 197 spin_lock_irqsave(&tmr->lock, flags); ··· 216 214 { 217 215 unsigned long flags; 218 216 219 - snd_assert(tmr, return -EINVAL); 217 + if (snd_BUG_ON(!tmr)) 218 + return -EINVAL; 220 219 221 220 spin_lock_irqsave(&tmr->lock, flags); 222 221 tmr->tick.cur_tick = position; ··· 232 229 { 233 230 unsigned long flags; 234 231 235 - snd_assert(tmr, return -EINVAL); 232 + if (snd_BUG_ON(!tmr)) 233 + return -EINVAL; 236 234 237 235 snd_seq_sanity_real_time(&position); 238 236 spin_lock_irqsave(&tmr->lock, flags); ··· 248 244 { 249 245 unsigned long flags; 250 246 251 - snd_assert(tmr, return -EINVAL); 247 + if (snd_BUG_ON(!tmr)) 248 + return -EINVAL; 252 249 253 250 /* FIXME */ 254 251 if (base != SKEW_BASE) { ··· 270 265 int err; 271 266 272 267 tmr = q->timer; 273 - snd_assert(tmr != NULL, return -EINVAL); 268 + if (snd_BUG_ON(!tmr)) 269 + return -EINVAL; 274 270 if (tmr->timeri) 275 271 return -EBUSY; 276 272 sprintf(str, "sequencer queue %i", q->queue); ··· 308 302 struct snd_seq_timer *tmr; 309 303 310 304 tmr = q->timer; 311 - snd_assert(tmr != NULL, return -EINVAL); 305 + if (snd_BUG_ON(!tmr)) 306 + return -EINVAL; 312 307 if (tmr->timeri) { 313 308 snd_timer_stop(tmr->timeri); 314 309 snd_timer_close(tmr->timeri); ··· 335 328 unsigned long freq; 336 329 337 330 t = tmr->timeri->timer; 338 - snd_assert(t, return -EINVAL); 331 + if (snd_BUG_ON(!t)) 332 + return -EINVAL; 339 333 340 334 freq = tmr->preferred_resolution; 341 335 if (!freq)
+8 -4
sound/core/sound.c
··· 206 206 minor = type; 207 207 break; 208 208 case SNDRV_DEVICE_TYPE_CONTROL: 209 - snd_assert(card != NULL, return -EINVAL); 209 + if (snd_BUG_ON(!card)) 210 + return -EINVAL; 210 211 minor = SNDRV_MINOR(card->number, type); 211 212 break; 212 213 case SNDRV_DEVICE_TYPE_HWDEP: 213 214 case SNDRV_DEVICE_TYPE_RAWMIDI: 214 215 case SNDRV_DEVICE_TYPE_PCM_PLAYBACK: 215 216 case SNDRV_DEVICE_TYPE_PCM_CAPTURE: 216 - snd_assert(card != NULL, return -EINVAL); 217 + if (snd_BUG_ON(!card)) 218 + return -EINVAL; 217 219 minor = SNDRV_MINOR(card->number, type + dev); 218 220 break; 219 221 default: 220 222 return -EINVAL; 221 223 } 222 - snd_assert(minor >= 0 && minor < SNDRV_OS_MINORS, return -EINVAL); 224 + if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OS_MINORS)) 225 + return -EINVAL; 223 226 return minor; 224 227 } 225 228 #endif ··· 250 247 int minor; 251 248 struct snd_minor *preg; 252 249 253 - snd_assert(name, return -EINVAL); 250 + if (snd_BUG_ON(!name)) 251 + return -EINVAL; 254 252 preg = kmalloc(sizeof *preg, GFP_KERNEL); 255 253 if (preg == NULL) 256 254 return -ENOMEM;
+8 -4
sound/core/sound_oss.c
··· 64 64 65 65 switch (type) { 66 66 case SNDRV_OSS_DEVICE_TYPE_MIXER: 67 - snd_assert(card != NULL && dev <= 1, return -EINVAL); 67 + if (snd_BUG_ON(!card || dev < 0 || dev > 1)) 68 + return -EINVAL; 68 69 minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_MIXER1 : SNDRV_MINOR_OSS_MIXER)); 69 70 break; 70 71 case SNDRV_OSS_DEVICE_TYPE_SEQUENCER: ··· 75 74 minor = SNDRV_MINOR_OSS_MUSIC; 76 75 break; 77 76 case SNDRV_OSS_DEVICE_TYPE_PCM: 78 - snd_assert(card != NULL && dev <= 1, return -EINVAL); 77 + if (snd_BUG_ON(!card || dev < 0 || dev > 1)) 78 + return -EINVAL; 79 79 minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_PCM1 : SNDRV_MINOR_OSS_PCM)); 80 80 break; 81 81 case SNDRV_OSS_DEVICE_TYPE_MIDI: 82 - snd_assert(card != NULL && dev <= 1, return -EINVAL); 82 + if (snd_BUG_ON(!card || dev < 0 || dev > 1)) 83 + return -EINVAL; 83 84 minor = SNDRV_MINOR_OSS(card->number, (dev ? SNDRV_MINOR_OSS_MIDI1 : SNDRV_MINOR_OSS_MIDI)); 84 85 break; 85 86 case SNDRV_OSS_DEVICE_TYPE_DMFM: ··· 93 90 default: 94 91 return -EINVAL; 95 92 } 96 - snd_assert(minor >= 0 && minor < SNDRV_OSS_MINORS, return -EINVAL); 93 + if (snd_BUG_ON(minor < 0 || minor >= SNDRV_OSS_MINORS)) 94 + return -EINVAL; 97 95 return minor; 98 96 } 99 97
+20 -13
sound/core/timer.c
··· 306 306 struct snd_timer *timer = NULL; 307 307 struct snd_timer_instance *slave, *tmp; 308 308 309 - snd_assert(timeri != NULL, return -ENXIO); 309 + if (snd_BUG_ON(!timer)) 310 + return -ENXIO; 310 311 311 312 /* force to stop the timer */ 312 313 snd_timer_stop(timeri); ··· 386 385 do_posix_clock_monotonic_gettime(&tstamp); 387 386 else 388 387 getnstimeofday(&tstamp); 389 - snd_assert(event >= SNDRV_TIMER_EVENT_START && 390 - event <= SNDRV_TIMER_EVENT_PAUSE, return); 388 + if (snd_BUG_ON(event < SNDRV_TIMER_EVENT_START || 389 + event > SNDRV_TIMER_EVENT_PAUSE)) 390 + return; 391 391 if (event == SNDRV_TIMER_EVENT_START || 392 392 event == SNDRV_TIMER_EVENT_CONTINUE) 393 393 resolution = snd_timer_resolution(ti); ··· 476 474 struct snd_timer *timer; 477 475 unsigned long flags; 478 476 479 - snd_assert(timeri != NULL, return -ENXIO); 477 + if (snd_BUG_ON(!timeri)) 478 + return -ENXIO; 480 479 481 480 if (timeri->flags & SNDRV_TIMER_IFLG_SLAVE) { 482 481 if (!keep_flag) { ··· 761 758 .dev_disconnect = snd_timer_dev_disconnect, 762 759 }; 763 760 764 - snd_assert(tid != NULL, return -EINVAL); 765 - snd_assert(rtimer != NULL, return -EINVAL); 766 - *rtimer = NULL; 761 + if (snd_BUG_ON(!tid)) 762 + return -EINVAL; 763 + if (rtimer) 764 + *rtimer = NULL; 767 765 timer = kzalloc(sizeof(*timer), GFP_KERNEL); 768 766 if (timer == NULL) { 769 767 snd_printk(KERN_ERR "timer: cannot allocate\n"); ··· 792 788 return err; 793 789 } 794 790 } 795 - *rtimer = timer; 791 + if (rtimer) 792 + *rtimer = timer; 796 793 return 0; 797 794 } 798 795 799 796 static int snd_timer_free(struct snd_timer *timer) 800 797 { 801 - snd_assert(timer != NULL, return -ENXIO); 798 + if (!timer) 799 + return 0; 802 800 803 801 mutex_lock(&register_mutex); 804 802 if (! list_empty(&timer->open_list_head)) { ··· 833 827 struct snd_timer *timer = dev->device_data; 834 828 struct snd_timer *timer1; 835 829 836 - snd_assert(timer != NULL && timer->hw.start != NULL && 837 - timer->hw.stop != NULL, return -ENXIO); 830 + if (snd_BUG_ON(!timer || !timer->hw.start || !timer->hw.stop)) 831 + return -ENXIO; 838 832 if (!(timer->hw.flags & SNDRV_TIMER_HW_SLAVE) && 839 833 !timer->hw.resolution && timer->hw.c_resolution == NULL) 840 834 return -EINVAL; ··· 885 879 886 880 if (! (timer->hw.flags & SNDRV_TIMER_HW_SLAVE)) 887 881 return; 888 - snd_assert(event >= SNDRV_TIMER_EVENT_MSTART && 889 - event <= SNDRV_TIMER_EVENT_MRESUME, return); 882 + if (snd_BUG_ON(event < SNDRV_TIMER_EVENT_MSTART || 883 + event > SNDRV_TIMER_EVENT_MRESUME)) 884 + return; 890 885 spin_lock_irqsave(&timer->lock, flags); 891 886 if (event == SNDRV_TIMER_EVENT_MSTART || 892 887 event == SNDRV_TIMER_EVENT_MCONTINUE ||
+6 -3
sound/core/timer_compat.c
··· 40 40 struct snd_timer *t; 41 41 42 42 tu = file->private_data; 43 - snd_assert(tu->timeri != NULL, return -ENXIO); 43 + if (snd_BUG_ON(!tu->timeri)) 44 + return -ENXIO; 44 45 t = tu->timeri->timer; 45 - snd_assert(t != NULL, return -ENXIO); 46 + if (snd_BUG_ON(!t)) 47 + return -ENXIO; 46 48 memset(&info, 0, sizeof(info)); 47 49 info.card = t->card ? t->card->number : -1; 48 50 if (t->hw.flags & SNDRV_TIMER_HW_SLAVE) ··· 73 71 struct snd_timer_status status; 74 72 75 73 tu = file->private_data; 76 - snd_assert(tu->timeri != NULL, return -ENXIO); 74 + if (snd_BUG_ON(!tu->timeri)) 75 + return -ENXIO; 77 76 memset(&status, 0, sizeof(status)); 78 77 status.tstamp = tu->tstamp; 79 78 status.resolution = snd_timer_resolution(tu->timeri);