فهرست منبع

toolchain/toolchain-wrapper.c: slightly simplify cmdline copying

C99 section 5.1.2.2.1p2 mandates that:

- argv[argc] shall be a null pointer.

https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

So we might as well copy the null pointer along in the memcpy() rather than
copy everything up to the null pointer and then add one afterwards for
simplicity.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
(cherry picked from commit 6b8ffbf97b9a5716c6d58758391adc8524c7d7fc)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
Peter Korsgaard 2 ماه پیش
والد
کامیت
5c6a99f242
1فایلهای تغییر یافته به همراه2 افزوده شده و 6 حذف شده
  1. 2 6
      toolchain/toolchain-wrapper.c

+ 2 - 6
toolchain/toolchain-wrapper.c

@@ -497,12 +497,8 @@ int main(int argc, char **argv)
 #endif
 #endif
 	}
 	}
 
 
-	/* append forward args */
-	memcpy(cur, &argv[1], sizeof(char *) * (argc - 1));
-	cur += argc - 1;
-
-	/* finish with NULL termination */
-	*cur = NULL;
+	/* append forward args and terminating NULL */
+	memcpy(cur, &argv[1], sizeof(char *) * argc);
 
 
 	exec_args = args;
 	exec_args = args;
 #ifdef BR_CCACHE
 #ifdef BR_CCACHE