[2/2] posix: Remove ununsed posix_spawn internal assignment

Message ID 1493038021-16091-2-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show
Series
  • Untitled series #1219
Related show

Commit Message

Adhemerval Zanella April 24, 2017, 12:47 p.m.
The internal 'ret' variable in '__spawni_child' function is not
used after assignment in most cases.

Checked on x86_64-linux-gnu.

	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Remove ununsed
	assignment.
---
 ChangeLog                        |  5 +++++
 sysdeps/unix/sysv/linux/spawni.c | 30 ++++++++++++++----------------
 2 files changed, 19 insertions(+), 16 deletions(-)

-- 
2.7.4

Comments

Andreas Schwab April 24, 2017, 1:01 p.m. | #1
On Apr 24 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Remove ununsed

> 	assignment.


Ok.

> @@ -183,13 +182,13 @@ __spawni_child (void *arguments)

>  

>    /* Set the process group ID.  */

>    if ((attr->__flags & POSIX_SPAWN_SETPGROUP) != 0

> -      && (ret = __setpgid (0, attr->__pgrp)) != 0)

> +      && (__setpgid (0, attr->__pgrp) != 0))

>      goto fail;

>  

>    /* Set the effective user and group IDs.  */

>    if ((attr->__flags & POSIX_SPAWN_RESETIDS) != 0

> -      && ((ret = local_seteuid (__getuid ())) != 0

> -	  || (ret = local_setegid (__getgid ())) != 0))

> +      && ((local_seteuid (__getuid ()) != 0)

> +	  || (local_setegid (__getgid ()) != 0)))

>      goto fail;

>  

>    /* Execute the file actions.  */


The extra pair of parens around the expressions are no longer needed.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Adhemerval Zanella April 24, 2017, 1:29 p.m. | #2
On 24/04/2017 10:01, Andreas Schwab wrote:
> On Apr 24 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 

>> 	* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Remove ununsed

>> 	assignment.

> 

> Ok.

> 

>> @@ -183,13 +182,13 @@ __spawni_child (void *arguments)

>>  

>>    /* Set the process group ID.  */

>>    if ((attr->__flags & POSIX_SPAWN_SETPGROUP) != 0

>> -      && (ret = __setpgid (0, attr->__pgrp)) != 0)

>> +      && (__setpgid (0, attr->__pgrp) != 0))

>>      goto fail;

>>  

>>    /* Set the effective user and group IDs.  */

>>    if ((attr->__flags & POSIX_SPAWN_RESETIDS) != 0

>> -      && ((ret = local_seteuid (__getuid ())) != 0

>> -	  || (ret = local_setegid (__getgid ())) != 0))

>> +      && ((local_seteuid (__getuid ()) != 0)

>> +	  || (local_setegid (__getgid ()) != 0)))

>>      goto fail;

>>  

>>    /* Execute the file actions.  */

> 

> The extra pair of parens around the expressions are no longer needed.

> 

> Andreas.

> 


Right, I will remove then on commit.

Patch hide | download patch | download mbox

diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index fc5d170..f93fbe1 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -124,7 +124,6 @@  __spawni_child (void *arguments)
   struct posix_spawn_args *args = arguments;
   const posix_spawnattr_t *restrict attr = args->attr;
   const posix_spawn_file_actions_t *file_actions = args->fa;
-  int ret;
 
   /* The child must ensure that no signal handler are enabled because it shared
      memory with parent, so the signal disposition must be either SIG_DFL or
@@ -167,12 +166,12 @@  __spawni_child (void *arguments)
   if ((attr->__flags & (POSIX_SPAWN_SETSCHEDPARAM | POSIX_SPAWN_SETSCHEDULER))
       == POSIX_SPAWN_SETSCHEDPARAM)
     {
-      if ((ret = __sched_setparam (0, &attr->__sp)) == -1)
+      if (__sched_setparam (0, &attr->__sp) == -1)
 	goto fail;
     }
   else if ((attr->__flags & POSIX_SPAWN_SETSCHEDULER) != 0)
     {
-      if ((ret = __sched_setscheduler (0, attr->__policy, &attr->__sp)) == -1)
+      if (__sched_setscheduler (0, attr->__policy, &attr->__sp) == -1)
 	goto fail;
     }
 #endif
@@ -183,13 +182,13 @@  __spawni_child (void *arguments)
 
   /* Set the process group ID.  */
   if ((attr->__flags & POSIX_SPAWN_SETPGROUP) != 0
-      && (ret = __setpgid (0, attr->__pgrp)) != 0)
+      && (__setpgid (0, attr->__pgrp) != 0))
     goto fail;
 
   /* Set the effective user and group IDs.  */
   if ((attr->__flags & POSIX_SPAWN_RESETIDS) != 0
-      && ((ret = local_seteuid (__getuid ())) != 0
-	  || (ret = local_setegid (__getgid ())) != 0))
+      && ((local_seteuid (__getuid ()) != 0)
+	  || (local_setegid (__getgid ()) != 0)))
     goto fail;
 
   /* Execute the file actions.  */
@@ -206,8 +205,7 @@  __spawni_child (void *arguments)
 	  switch (action->tag)
 	    {
 	    case spawn_do_close:
-	      if ((ret =
-		   close_not_cancel (action->action.close_action.fd)) != 0)
+	      if (close_not_cancel (action->action.close_action.fd) != 0)
 		{
 		  if (!have_fdlimit)
 		    {
@@ -232,10 +230,10 @@  __spawni_child (void *arguments)
 		   paths (like /dev/watchdog).  */
 		close_not_cancel (action->action.open_action.fd);
 
-		ret = open_not_cancel (action->action.open_action.path,
-				       action->action.
-				       open_action.oflag | O_LARGEFILE,
-				       action->action.open_action.mode);
+		int ret = open_not_cancel (action->action.open_action.path,
+					   action->action.
+					   open_action.oflag | O_LARGEFILE,
+					   action->action.open_action.mode);
 
 		if (ret == -1)
 		  goto fail;
@@ -245,19 +243,19 @@  __spawni_child (void *arguments)
 		/* Make sure the desired file descriptor is used.  */
 		if (ret != action->action.open_action.fd)
 		  {
-		    if ((ret = __dup2 (new_fd, action->action.open_action.fd))
+		    if (__dup2 (new_fd, action->action.open_action.fd)
 			!= action->action.open_action.fd)
 		      goto fail;
 
-		    if ((ret = close_not_cancel (new_fd)) != 0)
+		    if (close_not_cancel (new_fd) != 0)
 		      goto fail;
 		  }
 	      }
 	      break;
 
 	    case spawn_do_dup2:
-	      if ((ret = __dup2 (action->action.dup2_action.fd,
-				 action->action.dup2_action.newfd))
+	      if (__dup2 (action->action.dup2_action.fd,
+			  action->action.dup2_action.newfd)
 		  != action->action.dup2_action.newfd)
 		goto fail;
 	      break;