Patch 8.2.4992

11 views
Skip to first unread message

Bram Moolenaar

unread,
May 21, 2022, 1:57:31 PM5/21/22
to vim...@googlegroups.com

Patch 8.2.4992 (after 8.2.4989)
Problem: Compiler warning for possibly uninitialized variable. (Tony
Mechelynck)
Solution: Initialize variable in the caller instead of in the function.
Files: src/userfunc.c, src/vim9execute.c


*** ../vim-8.2.4991/src/userfunc.c 2022-05-21 16:28:38.390926796 +0100
--- src/userfunc.c 2022-05-21 18:55:13.355188657 +0100
***************
*** 4999,5004 ****
--- 4999,5005 ----
/*
* Find a function by name, including "<lambda>123".
* Check for "profile" and "debug" arguments and set"compile_type".
+ * Caller should initialize "compile_type" to CT_NONE.
* Return NULL if not found.
*/
ufunc_T *
***************
*** 5009,5015 ****
ufunc_T *ufunc;
int is_global = FALSE;

- *compile_type = CT_NONE;
if (STRNCMP(arg, "profile", 7) == 0 && VIM_ISWHITE(arg[7]))
{
*compile_type = CT_PROFILE;
--- 5010,5015 ----
***************
*** 5069,5075 ****

if (*eap->arg != NUL)
{
! compiletype_T compile_type;

ufunc = find_func_by_name(eap->arg, &compile_type);
if (ufunc != NULL)
--- 5069,5075 ----

if (*eap->arg != NUL)
{
! compiletype_T compile_type = CT_NONE;

ufunc = find_func_by_name(eap->arg, &compile_type);
if (ufunc != NULL)
*** ../vim-8.2.4991/src/vim9execute.c 2022-05-21 15:38:33.090080625 +0100
--- src/vim9execute.c 2022-05-21 18:51:07.963713785 +0100
***************
*** 6281,6287 ****
dfunc_T *dfunc;
isn_T *instr;
int instr_count;
! compiletype_T compile_type;

ufunc = find_func_by_name(arg, &compile_type);
if (ufunc == NULL)
--- 6281,6287 ----
dfunc_T *dfunc;
isn_T *instr;
int instr_count;
! compiletype_T compile_type = CT_NONE;

ufunc = find_func_by_name(arg, &compile_type);
if (ufunc == NULL)
*** ../vim-8.2.4991/src/version.c 2022-05-21 16:34:34.830069398 +0100
--- src/version.c 2022-05-21 18:53:08.027441034 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4992,
/**/

--
hundred-and-one symptoms of being an internet addict:
247. You use www.switchboard.com instead of dialing 411 and 555-12-12
for directory assistance.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Tony Mechelynck

unread,
May 21, 2022, 2:31:56 PM5/21/22
to vim_dev
On Sat, May 21, 2022 at 7:57 PM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
>
> Patch 8.2.4992 (after 8.2.4989)
> Problem: Compiler warning for possibly uninitialized variable. (Tony
> Mechelynck)
> Solution: Initialize variable in the caller instead of in the function.
> Files: src/userfunc.c, src/vim9execute.c

The warning has not disappeared:

gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK
-I/usr/include/gtk-3.0 -I/usr/include/pango-1.0
-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
-I/usr/include/harfbuzz -I/usr/include/freetype2
-I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi
-I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng16
-I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0
-I/usr/include/wayland -I/usr/include/libxkbcommon
-I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0
-I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include
-I/usr/include/at-spi-2.0 -pthread -O2 -fno-strength-reduce -Wall
-Wno-deprecated-declarations -D_REENTRANT -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=1 -o objects/vim9execute.o vim9execute.c
vim9execute.c: In function ‘ex_disassemble’:
vim9execute.c:6319:5: warning: ‘instr_count’ may be used uninitialized
[-Wmaybe-uninitialized]
6319 | list_instructions("", instr, instr_count, ufunc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim9execute.c:6283:17: note: ‘instr_count’ was declared here
6283 | int instr_count;
| ^~~~~~~~~~~
vim9execute.c:6319:5: warning: ‘instr’ may be used uninitialized
[-Wmaybe-uninitialized]
6319 | list_instructions("", instr, instr_count, ufunc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim9execute.c:6282:18: note: ‘instr’ was declared here
6282 | isn_T *instr;
| ^~~~~


Best regards,
Tony.

Bram Moolenaar

unread,
May 21, 2022, 4:52:45 PM5/21/22
to vim...@googlegroups.com, Tony Mechelynck

Tony wrote:

> On Sat, May 21, 2022 at 7:57 PM Bram Moolenaar <Br...@moolenaar.net> wrote:
> >
> >
> > Patch 8.2.4992 (after 8.2.4989)
> > Problem: Compiler warning for possibly uninitialized variable. (Tony
> > Mechelynck)
> > Solution: Initialize variable in the caller instead of in the function.
> > Files: src/userfunc.c, src/vim9execute.c
>
> The warning has not disappeared:
>
> gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK
> -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0
> -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
> -I/usr/include/harfbuzz -I/usr/include/freetype2
> -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi
> -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/libpng16
> -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0
> -I/usr/include/wayland -I/usr/include/libxkbcommon
> -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0
> -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include
> -I/usr/include/at-spi-2.0 -pthread -O2 -fno-strength-reduce -Wall
> -Wno-deprecated-declarations -D_REENTRANT -U_FORTIFY_SOURCE
> -D_FORTIFY_SOURCE=3D1 -o objects/vim9execute.o vim9execute.c
> vim9execute.c: In function =E2=80=98ex_disassemble=E2=80=99:
> vim9execute.c:6319:5: warning: =E2=80=98instr_count=E2=80=99 may be used un=
> initialized
> [-Wmaybe-uninitialized]
> 6319 | list_instructions("", instr, instr_count, ufunc);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> vim9execute.c:6283:17: note: =E2=80=98instr_count=E2=80=99 was declared her=
> e
> 6283 | int instr_count;
> | ^~~~~~~~~~~
> vim9execute.c:6319:5: warning: =E2=80=98instr=E2=80=99 may be used uninitia=
> lized
> [-Wmaybe-uninitialized]
> 6319 | list_instructions("", instr, instr_count, ufunc);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> vim9execute.c:6282:18: note: =E2=80=98instr=E2=80=99 was declared here
> 6282 | isn_T *instr;
> | ^~~~~

Strange, that did not logically change with that patch.
I suppose the compiler has some brain-dead way to detect uninitialized
variables. Perhaps before the patch it was confused, and now it's more
certain about the variables not being initialized.

--
hundred-and-one symptoms of being an internet addict:
250. You've given up the search for the "perfect woman" and instead,
sit in front of the PC until you're just too tired to care.
Reply all
Reply to author
Forward
0 new messages