ALSA: seq_oss: Drop superfluous error/debug messages after malloc failures
PATCH 1/3 ALSA: seq_oss: Drop superfluous error/debug messages after malloc failures
The kernel memory allocators already report the errors when the requested allocation fails, thus we don't need to warn it again in each caller side.
Signed-off-by Takashi Iwai <[email protected]>
--- sound/core/seq/oss/seq_oss_init.c | 4 +--- sound/core/seq/oss/seq_oss_midi.c | 5 ++--- sound/core/seq/oss/seq_oss_readq.c | 9 ++++----- sound/core/seq/oss/seq_oss_synth.c | 6 ++---- 4 files changed, 9 insertions(+), 15 deletions(-)
sound/core/seq/oss/seq_oss_init.c +1 -3
@@ -188,10 +188,8 @@ snd_seq_oss_open(struct file *file, int level)struct seq_oss_devinfo *dp; dp =kzalloc (sizeof (*dp),GFP_KERNEL ); -if (!dp) { -pr_err ("ALSA: seq_oss: can't malloc device info\n" ); +if (!dp)return -ENOMEM ; - } dp->cseq = system_client; dp->port =-1 ;
sound/core/seq/oss/seq_oss_midi.c +2 -3
@@ -173,10 +173,9 @@ snd_seq_oss_midi_check_new_port(struct snd_seq_port_info *pinfo)/* * allocate midi info record */ -if ((mdev =kzalloc (sizeof (*mdev),GFP_KERNEL )) ==NULL ) { -pr_err ("ALSA: seq_oss: can't malloc midi info\n" ); + mdev =kzalloc (sizeof (*mdev),GFP_KERNEL ); +if (!mdev)return -ENOMEM ; - }/* copy the port information */ mdev->client = pinfo->addr.client;
sound/core/seq/oss/seq_oss_readq.c +4 -5
@@ -47,13 +47,12 @@ snd_seq_oss_readq_new(struct seq_oss_devinfo *dp, int maxlen) {struct seq_oss_readq *q; -if ((q =kzalloc (sizeof (*q),GFP_KERNEL )) ==NULL ) { -pr_err ("ALSA: seq_oss: can't malloc read queue\n" ); + q =kzalloc (sizeof (*q),GFP_KERNEL ); +if (!q)return NULL ; - } -if ((q->q =kcalloc (maxlen,sizeof (union evrec ),GFP_KERNEL )) ==NULL ) { -pr_err ("ALSA: seq_oss: can't malloc read queue buffer\n" ); + q->q =kcalloc (maxlen,sizeof (union evrec ),GFP_KERNEL ); +if (!q->q) {kfree (q);return NULL ; }
sound/core/seq/oss/seq_oss_synth.c +2 -4
@@ -106,10 +106,9 @@ snd_seq_oss_synth_probe(struct device *_dev)struct snd_seq_oss_reg *reg =SNDRV_SEQ_DEVICE_ARGPTR (dev);unsigned long flags; -if ((rec =kzalloc (sizeof (*rec),GFP_KERNEL )) ==NULL ) { -pr_err ("ALSA: seq_oss: can't malloc synth info\n" ); + rec =kzalloc (sizeof (*rec),GFP_KERNEL ); +if (!rec)return -ENOMEM ; - } rec->seq_device =-1 ; rec->synth_type = reg->type; rec->synth_subtype = reg->subtype;
@@ -249,7 +248,6 @@ snd_seq_oss_synth_setup(struct seq_oss_devinfo *dp)if (info->nr_voices >0 ) { info->ch =kcalloc (info->nr_voices,sizeof (struct seq_oss_chinfo ),GFP_KERNEL );if (!info->ch) { -pr_err ("ALSA: seq_oss: Cannot malloc voices\n" ); rec->oper.close (&info->arg);module_put (rec->oper.owner);snd_use_lock_free (&rec->use_lock);
Signature · 1 line
2.3.2
PATCH 2/3 ALSA: seq: Drop superfluous error/debug messages after malloc failures
The kernel memory allocators already report the errors when the requested allocation fails, thus we don't need to warn it again in each caller side.
Signed-off-by Takashi Iwai <[email protected]>
--- sound/core/seq/seq_fifo.c | 4 +--- sound/core/seq/seq_memory.c | 8 ++------ sound/core/seq/seq_ports.c | 4 +--- sound/core/seq/seq_prioq.c | 4 +--- sound/core/seq/seq_queue.c | 4 +--- sound/core/seq/seq_timer.c | 4 +--- 6 files changed, 7 insertions(+), 21 deletions(-)
sound/core/seq/seq_fifo.c +1 -3
@@ -33,10 +33,8 @@ struct snd_seq_fifo *snd_seq_fifo_new(int poolsize)struct snd_seq_fifo *f; f =kzalloc (sizeof (*f),GFP_KERNEL ); -if (f ==NULL ) { -pr_debug ("ALSA: seq: malloc failed for snd_seq_fifo_new() \n" ); +if (!f)return NULL ; - } f->pool =snd_seq_pool_new (poolsize);if (f->pool ==NULL ) {
sound/core/seq/seq_memory.c +2 -6
@@ -387,10 +387,8 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)return 0 ; pool->ptr =vmalloc (sizeof (struct snd_seq_event_cell ) * pool->size); -if (pool->ptr ==NULL ) { -pr_debug ("ALSA: seq: malloc for sequencer events failed\n" ); +if (!pool->ptr)return -ENOMEM ; - }/* add new cells to the free cell list */ spin_lock_irqsave (&pool->lock, flags);
@@ -463,10 +461,8 @@ struct snd_seq_pool *snd_seq_pool_new(int poolsize)/* create pool block */ pool =kzalloc (sizeof (*pool),GFP_KERNEL ); -if (pool ==NULL ) { -pr_debug ("ALSA: seq: malloc failed for pool\n" ); +if (!pool)return NULL ; - }spin_lock_init (&pool->lock); pool->ptr =NULL ; pool->free =NULL ;
sound/core/seq/seq_ports.c +1 -3
@@ -141,10 +141,8 @@ struct snd_seq_client_port *snd_seq_create_port(struct snd_seq_client *client,/* create a new port */ new_port =kzalloc (sizeof (*new_port),GFP_KERNEL ); -if (! new_port) { -pr_debug ("ALSA: seq: malloc failed for registering client port\n" ); +if (!new_port)return NULL ;/* failure, out of memory */ - }/* init port data */ new_port->addr.client = client->number; new_port->addr.port =-1 ;
sound/core/seq/seq_prioq.c +1 -3
@@ -59,10 +59,8 @@ struct snd_seq_prioq *snd_seq_prioq_new(void)struct snd_seq_prioq *f; f =kzalloc (sizeof (*f),GFP_KERNEL ); -if (f ==NULL ) { -pr_debug ("ALSA: seq: malloc failed for snd_seq_prioq_new()\n" ); +if (!f)return NULL ; - }spin_lock_init (&f->lock); f->head =NULL ;
sound/core/seq/seq_queue.c +1 -3
@@ -111,10 +111,8 @@ static struct snd_seq_queue *queue_new(int owner, int locked)struct snd_seq_queue *q; q =kzalloc (sizeof (*q),GFP_KERNEL ); -if (q ==NULL ) { -pr_debug ("ALSA: seq: malloc failed for snd_seq_queue_new()\n" ); +if (!q)return NULL ; - }spin_lock_init (&q->owner_lock);spin_lock_init (&q->check_lock);
sound/core/seq/seq_timer.c +1 -3
@@ -56,10 +56,8 @@ struct snd_seq_timer *snd_seq_timer_new(void)struct snd_seq_timer *tmr; tmr =kzalloc (sizeof (*tmr),GFP_KERNEL ); -if (tmr ==NULL ) { -pr_debug ("ALSA: seq: malloc failed for snd_seq_timer_new() \n" ); +if (!tmr)return NULL ; - }spin_lock_init (&tmr->lock);/* reset setup to defaults */
Signature · 1 line
2.3.2
PATCH 3/3 ALSA: core: Drop superfluous error/debug messages after malloc failures
In reply to Takashi IwaiThe kernel memory allocators already report the errors when the requested allocation fails, thus we don't need to warn it again in each caller side.
Signed-off-by Takashi Iwai <[email protected]>
--- sound/core/control.c | 4 +--- sound/core/device.c | 4 +--- sound/core/hwdep.c | 4 +--- sound/core/oss/mixer_oss.c | 4 +--- sound/core/oss/pcm_oss.c | 1 - sound/core/pcm.c | 13 +++---------- sound/core/rawmidi.c | 8 ++------ sound/core/timer.c | 4 +--- 8 files changed, 10 insertions(+), 32 deletions(-)
sound/core/control.c +1 -3
@@ -217,10 +217,8 @@ static int snd_ctl_new(struct snd_kcontrol **kctl, unsigned int count, size +=sizeof (struct snd_kcontrol_volatile ) * count; *kctl =kzalloc (size,GFP_KERNEL ); -if (*kctl ==NULL ) { -pr_err ("ALSA: Cannot allocate control instance\n" ); +if (!*kctl)return -ENOMEM ; - }for (idx =0 ; idx < count; idx++) { (*kctl)->vd[idx].access = access;
sound/core/device.c +1 -3
@@ -50,10 +50,8 @@ int snd_device_new(struct snd_card *card, enum snd_device_type type,if (snd_BUG_ON (!card || !device_data || !ops))return -ENXIO ; dev =kzalloc (sizeof (*dev),GFP_KERNEL ); -if (dev ==NULL ) { -dev_err (card->dev,"Cannot allocate device, type=%d\n" , type); +if (!dev)return -ENOMEM ; - }INIT_LIST_HEAD (&dev->list); dev->card = card; dev->type = type;
sound/core/hwdep.c +1 -3
@@ -378,10 +378,8 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,if (rhwdep) *rhwdep =NULL ; hwdep =kzalloc (sizeof (*hwdep),GFP_KERNEL ); -if (hwdep ==NULL ) { -dev_err (card->dev,"hwdep: cannot allocate\n" ); +if (!hwdep)return -ENOMEM ; - }init_waitqueue_head (&hwdep->open_wait);mutex_init (&hwdep->open_mutex);
sound/core/oss/mixer_oss.c +1 -3
@@ -1212,10 +1212,8 @@ static void snd_mixer_oss_proc_write(struct snd_info_entry *entry,/* not changed */ goto __unlock; tbl =kmalloc (sizeof (*tbl),GFP_KERNEL ); -if (! tbl) { -pr_err ("ALSA: mixer_oss: no memory\n" ); +if (!tbl) goto __unlock; - } tbl->oss_id = ch; tbl->name =kstrdup (str,GFP_KERNEL );if (! tbl->name) {
sound/core/oss/pcm_oss.c +0 -1
@@ -854,7 +854,6 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream) params =kmalloc (sizeof (*params),GFP_KERNEL ); sparams =kmalloc (sizeof (*sparams),GFP_KERNEL );if (!sw_params || !params || !sparams) { -pcm_dbg (substream->pcm,"No memory\n" ); err = -ENOMEM ; goto failure; }
sound/core/pcm.c +3 -10
@@ -343,11 +343,8 @@ static void snd_pcm_proc_info_read(struct snd_pcm_substream *substream,return ; info =kmalloc (sizeof (*info),GFP_KERNEL ); -if (! info) { -pcm_dbg (substream->pcm, -"snd_pcm_proc_info_read: cannot malloc\n" ); +if (!info)return ; - } err =snd_pcm_info (substream, info);if (err <0 ) {
@@ -717,10 +714,8 @@ int snd_pcm_new_stream(struct snd_pcm *pcm, int stream, int substream_count) prev =NULL ;for (idx =0 , prev =NULL ; idx < substream_count; idx++) { substream =kzalloc (sizeof (*substream),GFP_KERNEL ); -if (substream ==NULL ) { -pcm_err (pcm,"Cannot allocate PCM substream\n" ); +if (!substream)return -ENOMEM ; - } substream->pcm = pcm; substream->pstr = pstr; substream->number = idx;
@@ -774,10 +769,8 @@ static int _snd_pcm_new(struct snd_card *card, const char *id, int device,if (rpcm) *rpcm =NULL ; pcm =kzalloc (sizeof (*pcm),GFP_KERNEL ); -if (pcm ==NULL ) { -dev_err (card->dev,"Cannot allocate PCM\n" ); +if (!pcm)return -ENOMEM ; - } pcm->card = card; pcm->device = device; pcm->internal = internal;
sound/core/rawmidi.c +2 -6
@@ -1429,10 +1429,8 @@ static int snd_rawmidi_alloc_substreams(struct snd_rawmidi *rmidi,for (idx =0 ; idx < count; idx++) { substream =kzalloc (sizeof (*substream),GFP_KERNEL ); -if (substream ==NULL ) { -rmidi_err (rmidi,"rawmidi: cannot allocate substream\n" ); +if (!substream)return -ENOMEM ; - } substream->stream = direction; substream->number = idx; substream->rmidi = rmidi;
@@ -1479,10 +1477,8 @@ int snd_rawmidi_new(struct snd_card *card, char *id, int device,if (rrawmidi) *rrawmidi =NULL ; rmidi =kzalloc (sizeof (*rmidi),GFP_KERNEL ); -if (rmidi ==NULL ) { -dev_err (card->dev,"rawmidi: cannot allocate\n" ); +if (!rmidi)return -ENOMEM ; - } rmidi->card = card; rmidi->device = device;mutex_init (&rmidi->open_mutex);
sound/core/timer.c +1 -3
@@ -774,10 +774,8 @@ int snd_timer_new(struct snd_card *card, char *id, struct snd_timer_id *tid,if (rtimer) *rtimer =NULL ; timer =kzalloc (sizeof (*timer),GFP_KERNEL ); -if (timer ==NULL ) { -pr_err ("ALSA: timer: cannot allocate\n" ); +if (!timer)return -ENOMEM ; - } timer->tmr_class = tid->dev_class; timer->card = card; timer->tmr_device = tid->device;
Signature · 1 line
2.3.2