unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57208: 29.0.50; Uninitialized compilation warnings in xterm.c
@ 2022-08-14 15:57 Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-08-15  0:52 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 5+ messages in thread
From: Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-08-14 15:57 UTC (permalink / raw)
  To: 57208; +Cc: Po Lu

[-- Attachment #1: Type: text/plain, Size: 937 bytes --]

Severity: minor
Tags: patch

Compiling with GCC 12 and -Og, I get the following -Wmaybe-uninitialized
warnings:

xterm.c: In function ‘x_dnd_free_toplevels’:
xterm.c:2918:17: warning: ‘dpy’ may be used uninitialized [-Wmaybe-uninitialized]
 2918 |       dpyinfo = x_display_info_for_display (dpy);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
xterm.c:2853:12: note: ‘dpy’ was declared here
 2853 |   Display *dpy;
      |            ^~~

xterm.c: In function ‘xm_setup_dnd_targets’:
xterm.c:2284:21: warning: ‘recs’ may be used uninitialized [-Wmaybe-uninitialized]
 2284 |                 recs[header.target_list_count - 1]->targets[i] = targets_sorted[i];
      |                     ^
xterm.c:2112:26: note: ‘recs’ was declared here
 2112 |   xm_targets_table_rec **recs;
      |                          ^~~~

They're bogus, right?  Is it okay to silence them as follows?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Pacify-maybe-uninitialized-warnings-in-xterm.c.patch --]
[-- Type: text/x-diff, Size: 1177 bytes --]

From d14b6fa375ce7a9eded5d0aeae52c8eac893e4de Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sun, 14 Aug 2022 18:33:45 +0300
Subject: [PATCH] Pacify maybe-uninitialized warnings in xterm.c

* src/xterm.c (xm_setup_dnd_targets, x_dnd_free_toplevels):
Initialize two pointers as NULL early, to pacify GCC 12
-Wmaybe-uninitialized warnings when compiling with -Og.
---
 src/xterm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/xterm.c b/src/xterm.c
index 6cf44e162b..e7ee5fd32e 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -2109,7 +2109,7 @@ xm_setup_dnd_targets (struct x_display_info *dpyinfo,
   int rc, actual_format, idx;
   bool had_errors;
   xm_targets_table_header header;
-  xm_targets_table_rec **recs;
+  xm_targets_table_rec **recs = NULL;
   xm_byte_order byteorder;
   uint8_t *data;
   ptrdiff_t total_bytes, total_items, i;
@@ -2850,7 +2850,7 @@ x_dnd_free_toplevels (bool display_alive)
   Window *destroy_windows UNINIT;
   unsigned long *prev_masks UNINIT;
   specpdl_ref count;
-  Display *dpy;
+  Display *dpy = NULL;
   struct x_display_info *dpyinfo;
 
   if (!x_dnd_toplevels)
-- 
2.35.1


[-- Attachment #3: Type: text/plain, Size: 970 bytes --]


Thanks,

-- 
Basil

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw3d scroll bars)
 of 2022-08-14 built on tia
Repository revision: 1d3fe256907d5e78a4acedd194e55db8ab952952
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure CC=gcc-12 'CFLAGS=-Og -ggdb3' --config-cache
 --prefix=/home/blc/.local --enable-checking=structs
 --with-file-notification=yes --with-x-toolkit=lucid --with-x'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP X11 XAW3D XDBE XIM XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LANG: en_IE.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

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

* bug#57208: 29.0.50; Uninitialized compilation warnings in xterm.c
  2022-08-14 15:57 bug#57208: 29.0.50; Uninitialized compilation warnings in xterm.c Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-08-15  0:52 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-08-15 20:34   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 1 reply; 5+ messages in thread
From: Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-08-15  0:52 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 57208

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> Severity: minor
> Tags: patch
>
> Compiling with GCC 12 and -Og, I get the following -Wmaybe-uninitialized
> warnings:
>
> xterm.c: In function ‘x_dnd_free_toplevels’:
> xterm.c:2918:17: warning: ‘dpy’ may be used uninitialized [-Wmaybe-uninitialized]
>  2918 |       dpyinfo = x_display_info_for_display (dpy);
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> xterm.c:2853:12: note: ‘dpy’ was declared here
>  2853 |   Display *dpy;
>       |            ^~~
>
> xterm.c: In function ‘xm_setup_dnd_targets’:
> xterm.c:2284:21: warning: ‘recs’ may be used uninitialized [-Wmaybe-uninitialized]
>  2284 |                 recs[header.target_list_count - 1]->targets[i] = targets_sorted[i];
>       |                     ^
> xterm.c:2112:26: note: ‘recs’ was declared here
>  2112 |   xm_targets_table_rec **recs;
>       |                          ^~~~
>
> They're bogus, right?  Is it okay to silence them as follows?

Yes, those are all bogus.  I installed something different to pacify
them on master.

Thanks.





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

* bug#57208: 29.0.50; Uninitialized compilation warnings in xterm.c
  2022-08-15  0:52 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-08-15 20:34   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-08-16  2:36     ` Eli Zaretskii
  2022-08-23 15:27     ` Stefan Kangas
  0 siblings, 2 replies; 5+ messages in thread
From: Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-08-15 20:34 UTC (permalink / raw)
  To: Po Lu; +Cc: 57208

Po Lu [2022-08-15 08:52 +0800] wrote:

> Yes, those are all bogus.  I installed something different to pacify
> them on master.

Thanks.  Just curious: what's the advantage of using UNINIT?
When should it or shouldn't it be preferred?

-- 
Basil





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

* bug#57208: 29.0.50; Uninitialized compilation warnings in xterm.c
  2022-08-15 20:34   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-08-16  2:36     ` Eli Zaretskii
  2022-08-23 15:27     ` Stefan Kangas
  1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2022-08-16  2:36 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: luangruo, 57208

> Cc: 57208@debbugs.gnu.org
> Date: Mon, 15 Aug 2022 23:34:19 +0300
> From:  "Basil L. Contovounesios" via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
> 
> Po Lu [2022-08-15 08:52 +0800] wrote:
> 
> > Yes, those are all bogus.  I installed something different to pacify
> > them on master.
> 
> Thanks.  Just curious: what's the advantage of using UNINIT?
> When should it or shouldn't it be preferred?

It should be used when the warning is due to a compiler bug or
misfeature, and our code is fine.  That's what UNINIT says: it says
that it's okay to leave this variable uninitialized.





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

* bug#57208: 29.0.50; Uninitialized compilation warnings in xterm.c
  2022-08-15 20:34   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-08-16  2:36     ` Eli Zaretskii
@ 2022-08-23 15:27     ` Stefan Kangas
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Kangas @ 2022-08-23 15:27 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: Po Lu, 57208-done

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

>
> Po Lu [2022-08-15 08:52 +0800] wrote:
>
>> Yes, those are all bogus.  I installed something different to pacify
>> them on master.
>
> Thanks.

I'm therefore closing this bug report.





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

end of thread, other threads:[~2022-08-23 15:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-14 15:57 bug#57208: 29.0.50; Uninitialized compilation warnings in xterm.c Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-15  0:52 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-15 20:34   ` Basil L. Contovounesios via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-08-16  2:36     ` Eli Zaretskii
2022-08-23 15:27     ` Stefan Kangas

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).