[v3] Removing Unneeded Return Value Assignments

Submitted by Mitul Karnik on March 16, 2019, 2:52 p.m.

Details

Message ID 20190316145204.2175-1-mitulkarnik.92@gmail.com
State Accepted
Series "Removing Unneeded Return Value Assignments"
Headers show

Commit Message

Mitul Karnik March 16, 2019, 2:52 p.m.
From: Mitul Karnik <mitulkarnik.92@gmail.com>

Fixes #334: Removing Unneeded Assignments

Patch Description:
Removed return value assignment statements as they are not referenced or used 
anywhere after the assignment is done.

Signed-off-by: Mitul Karnik <mitulkarnik.92@gmail.com>
---
 compel/arch/s390/src/lib/infect.c | 2 +-
 criu/path.c                       | 2 +-
 test/zdtm/static/dumpable02.c     | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/compel/arch/s390/src/lib/infect.c b/compel/arch/s390/src/lib/infect.c
index 940d0441..b690b812 100644
--- a/compel/arch/s390/src/lib/infect.c
+++ b/compel/arch/s390/src/lib/infect.c
@@ -455,7 +455,7 @@  void *remote_mmap(struct parasite_ctl *ctl,
 	if (ptrace_poke_area(pid, &arg_struct, where, sizeof(arg_struct))) {
 		pr_err("Can't restore mmap args (pid: %d)\n", pid);
 		if (map != 0) {
-			err = compel_syscall(ctl, __NR_munmap, NULL, map,
+			compel_syscall(ctl, __NR_munmap, NULL, map,
 					     length, 0, 0, 0, 0);
 			map = 0;
 		}
diff --git a/criu/path.c b/criu/path.c
index 70b0c472..22a89a4a 100644
--- a/criu/path.c
+++ b/criu/path.c
@@ -99,7 +99,7 @@  char *mnt_get_sibling_path(struct mount_info *m,
 		rpath++;
 
 	if (rpath[0] != '\0')
-		off = snprintf(path, len, "/%s", rpath);
+		snprintf(path, len, "/%s", rpath);
 
 	return buf;
 }
diff --git a/test/zdtm/static/dumpable02.c b/test/zdtm/static/dumpable02.c
index bd632e13..024371bd 100644
--- a/test/zdtm/static/dumpable02.c
+++ b/test/zdtm/static/dumpable02.c
@@ -143,8 +143,8 @@  int main(int argc, char **argv)
 			return 1;
 		}
 
-		ret = execl(argv[0], "dumpable_server", NULL);
-		pr_perror("could not execv %s as a dumpable_server", argv[0]);
+		execl(argv[0], "dumpable_server", NULL);
+		pr_perror("could not execv %s as a dumpable_server\nError No: %d", argv[0], errno);
 		return 1;
 	}
 

Comments

Andrei Vagin March 17, 2019, 5:10 a.m.
Applied, thanks!

On Sat, Mar 16, 2019 at 02:52:04PM +0000, mitulkarnik.92@gmail.com wrote:
> From: Mitul Karnik <mitulkarnik.92@gmail.com>
> 
> Fixes #334: Removing Unneeded Assignments
> 
> Patch Description:
> Removed return value assignment statements as they are not referenced or used 
> anywhere after the assignment is done.
> 
> Signed-off-by: Mitul Karnik <mitulkarnik.92@gmail.com>
> ---
>  compel/arch/s390/src/lib/infect.c | 2 +-
>  criu/path.c                       | 2 +-
>  test/zdtm/static/dumpable02.c     | 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/compel/arch/s390/src/lib/infect.c b/compel/arch/s390/src/lib/infect.c
> index 940d0441..b690b812 100644
> --- a/compel/arch/s390/src/lib/infect.c
> +++ b/compel/arch/s390/src/lib/infect.c
> @@ -455,7 +455,7 @@ void *remote_mmap(struct parasite_ctl *ctl,
>  	if (ptrace_poke_area(pid, &arg_struct, where, sizeof(arg_struct))) {
>  		pr_err("Can't restore mmap args (pid: %d)\n", pid);
>  		if (map != 0) {
> -			err = compel_syscall(ctl, __NR_munmap, NULL, map,
> +			compel_syscall(ctl, __NR_munmap, NULL, map,
>  					     length, 0, 0, 0, 0);
>  			map = 0;
>  		}
> diff --git a/criu/path.c b/criu/path.c
> index 70b0c472..22a89a4a 100644
> --- a/criu/path.c
> +++ b/criu/path.c
> @@ -99,7 +99,7 @@ char *mnt_get_sibling_path(struct mount_info *m,
>  		rpath++;
>  
>  	if (rpath[0] != '\0')
> -		off = snprintf(path, len, "/%s", rpath);
> +		snprintf(path, len, "/%s", rpath);
>  
>  	return buf;
>  }
> diff --git a/test/zdtm/static/dumpable02.c b/test/zdtm/static/dumpable02.c
> index bd632e13..024371bd 100644
> --- a/test/zdtm/static/dumpable02.c
> +++ b/test/zdtm/static/dumpable02.c
> @@ -143,8 +143,8 @@ int main(int argc, char **argv)
>  			return 1;
>  		}
>  
> -		ret = execl(argv[0], "dumpable_server", NULL);
> -		pr_perror("could not execv %s as a dumpable_server", argv[0]);
> +		execl(argv[0], "dumpable_server", NULL);
> +		pr_perror("could not execv %s as a dumpable_server\nError No: %d", argv[0], errno);
>  		return 1;
>  	}
>  
> -- 
> 2.17.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
Cyrill Gorcunov March 21, 2019, 11:18 a.m.
On Sat, Mar 16, 2019 at 02:52:04PM +0000, mitulkarnik.92@gmail.com wrote:
> From: Mitul Karnik <mitulkarnik.92@gmail.com>
> 
> Fixes #334: Removing Unneeded Assignments
> 
> Patch Description:
> Removed return value assignment statements as they are not referenced or used 
> anywhere after the assignment is done.
> 
> Signed-off-by: Mitul Karnik <mitulkarnik.92@gmail.com>
> ---
>  compel/arch/s390/src/lib/infect.c | 2 +-
>  criu/path.c                       | 2 +-
>  test/zdtm/static/dumpable02.c     | 4 ++--
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/compel/arch/s390/src/lib/infect.c b/compel/arch/s390/src/lib/infect.c
> index 940d0441..b690b812 100644
> --- a/compel/arch/s390/src/lib/infect.c
> +++ b/compel/arch/s390/src/lib/infect.c
> @@ -455,7 +455,7 @@ void *remote_mmap(struct parasite_ctl *ctl,
>  	if (ptrace_poke_area(pid, &arg_struct, where, sizeof(arg_struct))) {
>  		pr_err("Can't restore mmap args (pid: %d)\n", pid);
>  		if (map != 0) {
> -			err = compel_syscall(ctl, __NR_munmap, NULL, map,
> +			compel_syscall(ctl, __NR_munmap, NULL, map,
>  					     length, 0, 0, 0, 0);
>  			map = 0;
>  		}

This is wrong. You should rather check err and print error message
if __NR_munmap failed.
Mitul Karnik March 21, 2019, 12:39 p.m.
Hi Cyrill,

Sure will do the required changes, my bad I was unaware of
compell_syscall() implementation, I will be more careful  next time.
I will send the patch ASAP.
Thanks for pointing it out.



On Thu, Mar 21, 2019 at 4:48 PM Cyrill Gorcunov <gorcunov@gmail.com> wrote:

> On Sat, Mar 16, 2019 at 02:52:04PM +0000, mitulkarnik.92@gmail.com wrote:
> > From: Mitul Karnik <mitulkarnik.92@gmail.com>
> >
> > Fixes #334: Removing Unneeded Assignments
> >
> > Patch Description:
> > Removed return value assignment statements as they are not referenced or
> used
> > anywhere after the assignment is done.
> >
> > Signed-off-by: Mitul Karnik <mitulkarnik.92@gmail.com>
> > ---
> >  compel/arch/s390/src/lib/infect.c | 2 +-
> >  criu/path.c                       | 2 +-
> >  test/zdtm/static/dumpable02.c     | 4 ++--
> >  3 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/compel/arch/s390/src/lib/infect.c
> b/compel/arch/s390/src/lib/infect.c
> > index 940d0441..b690b812 100644
> > --- a/compel/arch/s390/src/lib/infect.c
> > +++ b/compel/arch/s390/src/lib/infect.c
> > @@ -455,7 +455,7 @@ void *remote_mmap(struct parasite_ctl *ctl,
> >       if (ptrace_poke_area(pid, &arg_struct, where, sizeof(arg_struct)))
> {
> >               pr_err("Can't restore mmap args (pid: %d)\n", pid);
> >               if (map != 0) {
> > -                     err = compel_syscall(ctl, __NR_munmap, NULL, map,
> > +                     compel_syscall(ctl, __NR_munmap, NULL, map,
> >                                            length, 0, 0, 0, 0);
> >                       map = 0;
> >               }
>
> This is wrong. You should rather check err and print error message
> if __NR_munmap failed.
>
Cyrill Gorcunov March 21, 2019, 12:45 p.m.
On Thu, Mar 21, 2019 at 06:09:31PM +0530, Mitul Karnik wrote:
>    Hi Cyrill,
>    Sure will do the required changes, my bad I was unaware of
>    compell_syscall() implementation, I will be more careful  next time. 
>    I will send the patch ASAP.
>    Thanks for pointing it out. 

Hi! Please don't excuse, it is fine. The former issue was there for long
time. Andrew already pushed your commit, just make a fixup on top.
And there is absolutely no rush at all, take your time :)