From: Paul Floyd Date: Tue, 25 Nov 2025 20:03:35 +0000 (+0100) Subject: FreeBSD startup: do not skip exename if it is not present X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=730f1de48ad109a0bc7046154ff8c5a1a8a93886;p=thirdparty%2Fvalgrind.git FreeBSD startup: do not skip exename if it is not present Don't remember why this code was there. Allowing no exename is a bad idea (argv[0] will be NULL). I don't think there is a need any more for this permissiveness. --- diff --git a/coregrind/m_initimg/initimg-freebsd.c b/coregrind/m_initimg/initimg-freebsd.c index 874d129f6..09f3dda84 100644 --- a/coregrind/m_initimg/initimg-freebsd.c +++ b/coregrind/m_initimg/initimg-freebsd.c @@ -410,7 +410,6 @@ static Addr setup_client_stack(const void* init_sp, Addr client_SP; /* client stack base (initial SP) */ Addr clstack_start; /* client_SP rounded down to nearest page */ Int i; - Bool have_exename; Word client_argv; vg_assert(VG_IS_PAGE_ALIGNED(clstack_end+1)); @@ -431,7 +430,6 @@ static Addr setup_client_stack(const void* init_sp, /* first of all, work out how big the client stack will be */ stringsize = 0; - have_exename = VG_(args_the_exename) != NULL; /* paste on the extra args if the loader needs them (ie, the #! interpreter and its argument) */ @@ -446,9 +444,7 @@ static Addr setup_client_stack(const void* init_sp, } /* now scan the args we're given... */ - if (have_exename) { - stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1; - } + stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1; for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) { argc++; @@ -506,7 +502,7 @@ static Addr setup_client_stack(const void* init_sp, /* OK, now we know how big the client stack is */ used_stacksize = sizeof(Word) + /* argc */ - (have_exename ? sizeof(HChar **) : 0) + /* argc[0] == exename */ + sizeof(HChar **) + /* argc[0] == exename */ sizeof(HChar **)*argc + /* argv */ sizeof(HChar **) + /* terminal NULL */ sizeof(HChar **)*envc + /* envp */ @@ -641,7 +637,7 @@ static Addr setup_client_stack(const void* init_sp, ptr = (Addr*)client_SP; /* --- client argc --- */ - *ptr++ = argc + (have_exename ? 1 : 0); + *ptr++ = argc + 1; /* --- client argv --- */ client_argv = (Word)ptr; @@ -652,9 +648,7 @@ static Addr setup_client_stack(const void* init_sp, *ptr++ = (Addr)copy_str(&strtab, info->interp_args); } - if (have_exename) { - *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename)); - } + *ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename)); for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) { *ptr++ = (Addr)copy_str(