I'm casting to (char *) because BB_EXECVP expects "char *const argv[]".
This is because BB_EXECVP mimics the signature of execvp, which is: int execvp(const char *file, char *const argv[]); On Wed, Jan 22, 2025 at 09:39:46AM +0100, Csókás Bence wrote: > Hi, > > On 2025. 01. 20. 0:10, Nadav Tasher wrote: > > Signed-off-by: Nadav Tasher <[email protected]> > > --- > > init/bootchartd.c | 19 +++++++++++++++---- > > 1 file changed, 15 insertions(+), 4 deletions(-) > > > > diff --git a/init/bootchartd.c b/init/bootchartd.c > > index 0929890a3..0833e0fe4 100644 > > --- a/init/bootchartd.c > > +++ b/init/bootchartd.c > > @@ -355,6 +355,7 @@ int bootchartd_main(int argc UNUSED_PARAM, char **argv) > > CMD_INIT, > > CMD_PID1, /* used to mark pid 1 case */ > > }; > > + char* exec_argv[2]; > > INIT_G(); > > @@ -446,10 +447,20 @@ int bootchartd_main(int argc UNUSED_PARAM, char > > **argv) > > if (cmd == CMD_PID1) { > > char *bootchart_init = getenv("bootchart_init"); > > - if (bootchart_init) > > - execl(bootchart_init, bootchart_init, NULL); > > - execl("/init", "init", NULL); > > - execl("/sbin/init", "init", NULL); > > + > > + /* make second arg always NULL */ > > + exec_argv[1] = NULL; > > + > > + if (bootchart_init) { > > + exec_argv[0] = bootchart_init; > > + BB_EXECVP(bootchart_init, exec_argv); > > + } > > + > > + /* fallback, we are calling different init binaries */ > > + exec_argv[0] = (char *) "init"; > > Why are you casting to (char *) ? > > > + BB_EXECVP("/init", exec_argv); > > + BB_EXECVP("/sbin/init", exec_argv); > > bb_perror_msg_and_die("can't execute '%s'", "/sbin/init"); > > } > > Bence > _______________________________________________ busybox mailing list [email protected] https://lists.busybox.net/mailman/listinfo/busybox
