all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Re: emacs-28 e5a49f44ff: * src/emacs.c (load_pdump): Fix use of xpalloc.
       [not found] ` <20221002103444.EE880C1AB4B@vcs2.savannah.gnu.org>
@ 2022-10-04 13:25   ` Stefan Kangas
  2022-10-04 16:34     ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Kangas @ 2022-10-04 13:25 UTC (permalink / raw)
  To: emacs-devel, Andreas Schwab

Andreas Schwab <schwab@gnu.org> writes:

> diff --git a/src/emacs.c b/src/emacs.c
> index 602fa802e0..92779a8d0d 100644
> --- a/src/emacs.c
> +++ b/src/emacs.c
> @@ -867,9 +867,8 @@ load_pdump (int argc, char **argv)
>      }
>
>    /* Where's our executable?  */
> -  ptrdiff_t bufsize, exec_bufsize;
> -  emacs_executable = load_pdump_find_executable (argv[0], &bufsize);
> -  exec_bufsize = bufsize;
> +  ptrdiff_t exec_bufsize, needed;
> +  emacs_executable = load_pdump_find_executable (argv[0], &exec_bufsize);
>
>    /* If we couldn't find our executable, go straight to looking for
>       the dump in the hardcoded location.  */
> @@ -902,8 +901,8 @@ load_pdump (int argc, char **argv)
>                       strip_suffix_length))
>         exenamelen = prefix_length;
>      }
> -  ptrdiff_t needed = exenamelen + strlen (suffix) + 1;
> -  dump_file = xpalloc (NULL, &bufsize, max (1, needed - bufsize), -1, 1);
> +  ptrdiff_t bufsize = exenamelen + strlen (suffix) + 1;
> +  dump_file = xpalloc (NULL, &bufsize, 1, -1, 1);
>    memcpy (dump_file, emacs_executable, exenamelen);
>    strcpy (dump_file + exenamelen, suffix);
>    result = pdumper_load (dump_file, emacs_executable);

This change leads to the below on macOS 10.13, using Apple LLVM
version 10.0.0 (clang-1000.10.44.4):

emacs.c:899:7: warning: variable 'bufsize' is used uninitialized
whenever 'if' condition is true [-Wsometimes-uninitialized]
  if (!(emacs_executable && *emacs_executable))
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
emacs.c:964:7: note: uninitialized use occurs here
  if (bufsize < needed)
      ^~~~~~~
emacs.c:899:3: note: remove the 'if' if its condition is always false
  if (!(emacs_executable && *emacs_executable))
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
emacs.c:928:3: note: variable 'bufsize' is declared here
  ptrdiff_t bufsize = exenamelen + strlen (suffix) + 1;
  ^
1 warning generated.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emacs-28 e5a49f44ff: * src/emacs.c (load_pdump): Fix use of xpalloc.
  2022-10-04 13:25   ` emacs-28 e5a49f44ff: * src/emacs.c (load_pdump): Fix use of xpalloc Stefan Kangas
@ 2022-10-04 16:34     ` Andreas Schwab
  2022-10-04 18:58       ` Stefan Kangas
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2022-10-04 16:34 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: emacs-devel

On Okt 04 2022, Stefan Kangas wrote:

> This change leads to the below on macOS 10.13, using Apple LLVM
> version 10.0.0 (clang-1000.10.44.4):
>
> emacs.c:899:7: warning: variable 'bufsize' is used uninitialized
> whenever 'if' condition is true [-Wsometimes-uninitialized]
>   if (!(emacs_executable && *emacs_executable))
>       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> emacs.c:964:7: note: uninitialized use occurs here
>   if (bufsize < needed)
>       ^~~~~~~
> emacs.c:899:3: note: remove the 'if' if its condition is always false
>   if (!(emacs_executable && *emacs_executable))
>   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> emacs.c:928:3: note: variable 'bufsize' is declared here
>   ptrdiff_t bufsize = exenamelen + strlen (suffix) + 1;
>   ^
> 1 warning generated.

This was broken even before, since dump_file wasn't heap-allocated
before this point if the jump to hardcoded happend.

Should be fixed now.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: emacs-28 e5a49f44ff: * src/emacs.c (load_pdump): Fix use of xpalloc.
  2022-10-04 16:34     ` Andreas Schwab
@ 2022-10-04 18:58       ` Stefan Kangas
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Kangas @ 2022-10-04 18:58 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: emacs-devel

Andreas Schwab <schwab@linux-m68k.org> writes:

> Should be fixed now.

Thanks, the warning is gone now.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-04 18:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <166470688469.7534.2087297540131700063@vcs2.savannah.gnu.org>
     [not found] ` <20221002103444.EE880C1AB4B@vcs2.savannah.gnu.org>
2022-10-04 13:25   ` emacs-28 e5a49f44ff: * src/emacs.c (load_pdump): Fix use of xpalloc Stefan Kangas
2022-10-04 16:34     ` Andreas Schwab
2022-10-04 18:58       ` Stefan Kangas

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.