Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

wrapper: simplify arg copying

The "-l" processing that was hoisted up in the previous commit made
the "arg" variable effectively a constant. Replace it and the
associated "ofs" variable with inline constants.
  • Loading branch information...
commit 40f94e941a0f0053dc72315e265865598df17001 1 parent 66ffbee
@ChrisJohnsen authored
Showing with 7 additions and 9 deletions.
  1. +7 −9 reattach-to-user-namespace.c
View
16 reattach-to-user-namespace.c
@@ -147,9 +147,8 @@ int main(int argc, char *argv[]) {
break;
}
- int arg = 1;
char **newargs = NULL;
- const char *file = argv[arg];
+ const char *file = argv[1];
if (login) {
/*
* For their argv[0], take the bit of file after the
@@ -166,16 +165,15 @@ int main(int argc, char *argv[]) {
strcpy(arg0+1, file);
/* use the rest of the args as they are */
- int ofs = arg;
- newargs = malloc(sizeof(*newargs) * (argc-ofs+1));
- newargs[arg-ofs] = arg0;
- arg++;
+ newargs = malloc(sizeof(*newargs) * (argc));
+ newargs[0] = arg0;
+ int arg = 2;
for(; arg < argc; arg++)
- newargs[arg-ofs] = argv[arg];
- newargs[arg-ofs] = NULL;
+ newargs[arg-1] = argv[arg];
+ newargs[arg-1] = NULL;
}
- if (execvp(file, newargs ? newargs : argv+arg) < 0)
+ if (execvp(file, newargs ? newargs : argv+1) < 0)
die_errno(3, "execv failed");
if (newargs) {
Please sign in to comment.
Something went wrong with that request. Please try again.