Skip to contentSkip to conversation

sound/core/control.c: remove dead code

PATCH In review Adrian Bunk 2 participants 5 messages Nov 6, 2006 – Nov 7, 2006 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound/core/control.c: remove dead code

This patch removes some obviously dead code spotted by the Coverity checker.

sound/core/control.c renamed from sound/core/control.c.old +1 -1
@@ -1267,23 +1267,23 @@ static ssize_t snd_ctl_read(struct file 
 			if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {
 				err = -EAGAIN;
 				goto __end_lock;
 			}
 			init_waitqueue_entry(&wait, current);
 			add_wait_queue(&ctl->change_sleep, &wait);
 			set_current_state(TASK_INTERRUPTIBLE);
 			spin_unlock_irq(&ctl->read_lock);
 			schedule();
 			remove_wait_queue(&ctl->change_sleep, &wait);
 			if (signal_pending(current))
-				return result > 0 ? result : -ERESTARTSYS;
+				return -ERESTARTSYS;
 			spin_lock_irq(&ctl->read_lock);
 		}
 		kev = snd_kctl_event(ctl->events.next);
 		ev.type = SNDRV_CTL_EVENT_ELEM;
 		ev.data.elem.mask = kev->mask;
 		ev.data.elem.id = kev->id;
 		list_del(&kev->list);
 		spin_unlock_irq(&ctl->read_lock);
 		kfree(kev);
 		if (copy_to_user(buffer, &ev, sizeof(struct snd_ctl_event))) {
 			err = -EFAULT;
#1 lore raw

At Mon, 6 Nov 2006 19:30:18 +0100,

Quoted 5 lines · Adrian Bunk

This patch removes some obviously dead code spotted by the Coverity checker.

I think it's a wrong fix. result could be > 0 indeed.

Takashi

Quoted 30 lines
sound/core/control.c renamed from sound/core/control.c.old +1 -2
@@ -1267,23 +1267,23 @@ static ssize_t snd_ctl_read(struct file 
 			if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {
 				err = -EAGAIN;
 				goto __end_lock;
 			}
 			init_waitqueue_entry(&wait, current);
 			add_wait_queue(&ctl->change_sleep, &wait);
 			set_current_state(TASK_INTERRUPTIBLE);
 			spin_unlock_irq(&ctl->read_lock);
 			schedule();
 			remove_wait_queue(&ctl->change_sleep, &wait);
 			if (signal_pending(current))
-				return result > 0 ? result : -ERESTARTSYS;
+				return -ERESTARTSYS;
 			spin_lock_irq(&ctl->read_lock);
 		}
 		kev = snd_kctl_event(ctl->events.next);
 		ev.type = SNDRV_CTL_EVENT_ELEM;
 		ev.data.elem.mask = kev->mask;
 		ev.data.elem.id = kev->id;
 		list_del(&kev->list);
 		spin_unlock_irq(&ctl->read_lock);
 		kfree(kev);
 		if (copy_to_user(buffer, &ev, sizeof(struct snd_ctl_event))) {
 			err = -EFAULT;
 
-------------------------------------------------------------------------
Quoted 9 lines

Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

#2 lore raw
Quoted 10 lines · Takashi Iwai

At Mon, 6 Nov 2006 19:30:18 +0100,

Quoted 5 lines · Adrian Bunk

This patch removes some obviously dead code spotted by the Coverity checker.

I think it's a wrong fix. result could be > 0 indeed.

Quoted 7 lines

Takashi

sound/core/control.c static ssize_t snd_ctl_read(struct file · line 1267

Quoted 5 lines
sound/core/control.c renamed from sound/core/control.c.old +0 -0
@@ -1267,23 +1267,23 @@ static ssize_t snd_ctl_read(struct file 
 			if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {

That is already checked here -> ^^^^^^^^^^

And after this point, result is never assigned any value.

Quoted 16 lines
Quoted 16 lines
sound/core/control.c renamed from sound/core/control.c.old +1 -1
 				err = -EAGAIN;
 				goto __end_lock;
 			}
 			init_waitqueue_entry(&wait, current);
 			add_wait_queue(&ctl->change_sleep, &wait);
 			set_current_state(TASK_INTERRUPTIBLE);
 			spin_unlock_irq(&ctl->read_lock);
 			schedule();
 			remove_wait_queue(&ctl->change_sleep, &wait);
 			if (signal_pending(current))
-				return result > 0 ? result : -ERESTARTSYS;
+				return -ERESTARTSYS;
 			spin_lock_irq(&ctl->read_lock);
 		}
 		kev = snd_kctl_event(ctl->events.next);
 		ev.type = SNDRV_CTL_EVENT_ELEM;
Quoted 8 lines

sound/core/control.c static ssize_t snd_ctl_read(struct file · line 1289

Quoted 8 lines
sound/core/control.c renamed from sound/core/control.c.old +0 -0
 		ev.data.elem.mask = kev->mask;
 		ev.data.elem.id = kev->id;
 		list_del(&kev->list);
 		spin_unlock_irq(&ctl->read_lock);
 		kfree(kev);
 		if (copy_to_user(buffer, &ev, sizeof(struct snd_ctl_event))) {
 			err = -EFAULT;

cu
Adrian

Signature · 11 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
#3 lore raw
In reply to Takashi Iwai
Quoted 10 lines · Takashi Iwai

At Mon, 6 Nov 2006 19:30:18 +0100,

Quoted 5 lines · Adrian Bunk

This patch removes some obviously dead code spotted by the Coverity checker.

I think it's a wrong fix. result could be > 0 indeed.

Quoted 7 lines

Takashi

sound/core/control.c static ssize_t snd_ctl_read(struct file · line 1267

Quoted 5 lines
sound/core/control.c renamed from sound/core/control.c.old +0 -0
@@ -1267,23 +1267,23 @@ static ssize_t snd_ctl_read(struct file 
 			if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {

That is already checked here -> ^^^^^^^^^^

And after this point, result is never assigned any value.

Quoted 16 lines
Quoted 16 lines
sound/core/control.c renamed from sound/core/control.c.old +1 -1
 				err = -EAGAIN;
 				goto __end_lock;
 			}
 			init_waitqueue_entry(&wait, current);
 			add_wait_queue(&ctl->change_sleep, &wait);
 			set_current_state(TASK_INTERRUPTIBLE);
 			spin_unlock_irq(&ctl->read_lock);
 			schedule();
 			remove_wait_queue(&ctl->change_sleep, &wait);
 			if (signal_pending(current))
-				return result > 0 ? result : -ERESTARTSYS;
+				return -ERESTARTSYS;
 			spin_lock_irq(&ctl->read_lock);
 		}
 		kev = snd_kctl_event(ctl->events.next);
 		ev.type = SNDRV_CTL_EVENT_ELEM;
Quoted 8 lines

sound/core/control.c static ssize_t snd_ctl_read(struct file · line 1289

Quoted 8 lines
sound/core/control.c renamed from sound/core/control.c.old +0 -0
 		ev.data.elem.mask = kev->mask;
 		ev.data.elem.id = kev->id;
 		list_del(&kev->list);
 		spin_unlock_irq(&ctl->read_lock);
 		kfree(kev);
 		if (copy_to_user(buffer, &ev, sizeof(struct snd_ctl_event))) {
 			err = -EFAULT;

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#4 lore raw

At Tue, 7 Nov 2006 13:38:06 +0100,

Quoted 15 lines · Adrian Bunk
Quoted 13 lines · Takashi Iwai

At Mon, 6 Nov 2006 19:30:18 +0100,

Quoted 5 lines · Adrian Bunk

This patch removes some obviously dead code spotted by the Coverity checker.

I think it's a wrong fix. result could be > 0 indeed.

Takashi

Quoted 1 line
Quoted 8 lines
Quoted 4 lines

sound/core/control.c static ssize_t snd_ctl_read(struct file · line 1267

Quoted 4 lines
sound/core/control.c renamed from sound/core/control.c.old +0 -0
@@ -1267,23 +1267,23 @@ static ssize_t snd_ctl_read(struct file 
 			if ((file->f_flags & O_NONBLOCK) != 0 || result > 0) {

That is already checked here -> ^^^^^^^^^^

And after this point, result is never assigned any value.

Ah, I see. Now applied it to ALSA tree.

Thanks.

Takashi

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642