unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
@ 2021-02-14 13:34 Basil L. Contovounesios
  2021-02-14 16:04 ` Eli Zaretskii
  0 siblings, 1 reply; 11+ messages in thread
From: Basil L. Contovounesios @ 2021-02-14 13:34 UTC (permalink / raw)
  To: 46509

Severity: minor

Building --with-x-toolkit=gtk2 gives the following warning:

  xfns.c:4947:1: warning: ‘x_get_monitor_attributes’ defined but not used

Its definition is conditional on !USE_GTK || !HAVE_GTK3, but its use
only on !USE_GTK.  Which one is right?  Or is this too inconsequential
to bother changing anything?

Thanks,

-- 
Basil

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.33, cairo version 1.16.0)
 of 2021-02-14 built on tia
Repository revision: 103039b06c2c9a917fc796d2a4afda8433e37473
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12010000
System Description: Debian GNU/Linux bullseye/sid

Configured using:
 'configure 'CC=ccache gcc' 'CFLAGS=-O2 -march=native' --config-cache
 --prefix=/home/blc/.local --program-suffix=-gtk2
 --enable-checking=structs --with-file-notification=yes
 --with-x-toolkit=gtk2 --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 SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE
XIM XPM GTK2 ZLIB

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





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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-14 13:34 bug#46509: 28.0.50; Unused static function in xfns.c with GTK2 Basil L. Contovounesios
@ 2021-02-14 16:04 ` Eli Zaretskii
  2021-02-14 17:17   ` martin rudalics
  0 siblings, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2021-02-14 16:04 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 46509

> From: "Basil L. Contovounesios" <contovob@tcd.ie>
> Date: Sun, 14 Feb 2021 13:34:45 +0000
> 
> Severity: minor
> 
> Building --with-x-toolkit=gtk2 gives the following warning:
> 
>   xfns.c:4947:1: warning: ‘x_get_monitor_attributes’ defined but not used
> 
> Its definition is conditional on !USE_GTK || !HAVE_GTK3, but its use
> only on !USE_GTK.  Which one is right?

The !USE_GTK one, I think.





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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-14 16:04 ` Eli Zaretskii
@ 2021-02-14 17:17   ` martin rudalics
  2021-02-14 17:44     ` Basil L. Contovounesios
  0 siblings, 1 reply; 11+ messages in thread
From: martin rudalics @ 2021-02-14 17:17 UTC (permalink / raw)
  To: Eli Zaretskii, Basil L. Contovounesios; +Cc: 46509

>> Its definition is conditional on !USE_GTK || !HAVE_GTK3, but its use
>> only on !USE_GTK.  Which one is right?
>
> The !USE_GTK one, I think.

It's a tad more complicated.  You have to do something like the below.

martin

diff --git a/src/xfns.c b/src/xfns.c
index 481ee0e225..82424ae080 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4663,6 +4663,9 @@ x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect)
    return result;
  }

+#endif /* !defined USE_GTK || !defined HAVE_GTK3 */
+#if !defined USE_GTK
+
  /* Return monitor number where F is "most" or closest to.  */
  static int
  x_get_monitor_for_frame (struct frame *f,






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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-14 17:17   ` martin rudalics
@ 2021-02-14 17:44     ` Basil L. Contovounesios
  2021-02-15  8:15       ` martin rudalics
  0 siblings, 1 reply; 11+ messages in thread
From: Basil L. Contovounesios @ 2021-02-14 17:44 UTC (permalink / raw)
  To: martin rudalics; +Cc: 46509

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

martin rudalics <rudalics@gmx.at> writes:

>>> Its definition is conditional on !USE_GTK || !HAVE_GTK3, but its use
>>> only on !USE_GTK.  Which one is right?
>>
>> The !USE_GTK one, I think.
>
> It's a tad more complicated.  You have to do something like the below.
>
> martin
>
> diff --git a/src/xfns.c b/src/xfns.c
> index 481ee0e225..82424ae080 100644
> --- a/src/xfns.c
> +++ b/src/xfns.c
> @@ -4663,6 +4663,9 @@ x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect)
>    return result;
>  }
>
> +#endif /* !defined USE_GTK || !defined HAVE_GTK3 */
> +#if !defined USE_GTK
> +
>  /* Return monitor number where F is "most" or closest to.  */
>  static int
>  x_get_monitor_for_frame (struct frame *f,

What about this?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-unused-function-warning-in-xfns.c-with-GTK2.patch --]
[-- Type: text/x-diff, Size: 1755 bytes --]

From a1761d8afff8b9fd7143fd8e311c6572e1639fbc Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sun, 14 Feb 2021 16:58:06 +0000
Subject: [PATCH] Fix unused function warning in xfns.c with GTK2

* src/xfns.c (x_get_net_workarea): Define only when using GTK other
than GTK3, to match its use in Fx_display_monitor_attributes_list.
(x_get_monitor_for_frame, x_make_monitor_attribute_list)
(x_get_monitor_attributes_fallback, x_get_monitor_attributes_xrandr)
(x_get_monitor_attributes_xinerama, x_get_monitor_attributes):
Condition definitions on !USE_GTK, to match their use in
Fx_display_monitor_attributes_list (bug#46509).
(x_get_monitor_attributes_xrandr): Undefine RANDR13_LIBRARY after
it's been used.
---
 src/xfns.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/xfns.c b/src/xfns.c
index 481ee0e225..f572982ca1 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4599,7 +4599,7 @@ DEFUN ("x-display-save-under", Fx_display_save_under,
     return Qnil;
 }
 
-#if !defined USE_GTK || !defined HAVE_GTK3
+#if defined USE_GTK && !defined HAVE_GTK3
 
 /* Store the geometry of the workarea on display DPYINFO into *RECT.
    Return false if and only if the workarea information cannot be
@@ -4662,6 +4662,9 @@ x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect)
 
   return result;
 }
+#endif /* USE_GTK && !HAVE_GTK3 */
+
+#ifndef USE_GTK
 
 /* Return monitor number where F is "most" or closest to.  */
 static int
@@ -4877,6 +4880,8 @@ #define RANDR13_LIBRARY \
     pxid = XRRGetOutputPrimary (dpy, dpyinfo->root_window);
 #endif
 
+#undef RANDR13_LIBRARY
+
   for (i = 0; i < n_monitors; ++i)
     {
       XRROutputInfo *info = XRRGetOutputInfo (dpy, resources,
-- 
2.30.0


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


Thanks,

-- 
Basil

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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-14 17:44     ` Basil L. Contovounesios
@ 2021-02-15  8:15       ` martin rudalics
  2021-02-15  9:15         ` Basil L. Contovounesios
  0 siblings, 1 reply; 11+ messages in thread
From: martin rudalics @ 2021-02-15  8:15 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 46509

 > What about this?

Don't like it.  Did you test it with a non-GTK toolkit?

martin





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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-15  8:15       ` martin rudalics
@ 2021-02-15  9:15         ` Basil L. Contovounesios
  2021-02-15 10:05           ` martin rudalics
  0 siblings, 1 reply; 11+ messages in thread
From: Basil L. Contovounesios @ 2021-02-15  9:15 UTC (permalink / raw)
  To: martin rudalics; +Cc: 46509

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

martin rudalics <rudalics@gmx.at> writes:

>> What about this?
>
> Don't like it.  Did you test it with a non-GTK toolkit?

No, that would have been far too clever.

What about this instead:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-unused-function-warning-in-xfns.c-with-GTK2.patch --]
[-- Type: text/x-diff, Size: 1782 bytes --]

From 577ac1e3884efb73d3519a68e074911b5befea39 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sun, 14 Feb 2021 16:58:06 +0000
Subject: [PATCH] Fix unused function warning in xfns.c with GTK2

* src/xfns.c (x_get_net_workarea): Define only when using GTK other
than GTK3, or when not using GTK, to match its use in
Fx_display_monitor_attributes_list.
(x_get_monitor_for_frame, x_make_monitor_attribute_list)
(x_get_monitor_attributes_fallback, x_get_monitor_attributes_xrandr)
(x_get_monitor_attributes_xinerama, x_get_monitor_attributes):
Condition definitions on !USE_GTK, to match their use in
Fx_display_monitor_attributes_list (bug#46509).
(x_get_monitor_attributes_xrandr): Undefine RANDR13_LIBRARY after
it's been used.
---
 src/xfns.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/xfns.c b/src/xfns.c
index 481ee0e225..d90644819b 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4599,7 +4599,7 @@ DEFUN ("x-display-save-under", Fx_display_save_under,
     return Qnil;
 }
 
-#if !defined USE_GTK || !defined HAVE_GTK3
+#if !(defined USE_GTK && defined HAVE_GTK3)
 
 /* Store the geometry of the workarea on display DPYINFO into *RECT.
    Return false if and only if the workarea information cannot be
@@ -4662,6 +4662,9 @@ x_get_net_workarea (struct x_display_info *dpyinfo, XRectangle *rect)
 
   return result;
 }
+#endif /* !(USE_GTK && HAVE_GTK3) */
+
+#ifndef USE_GTK
 
 /* Return monitor number where F is "most" or closest to.  */
 static int
@@ -4877,6 +4880,8 @@ #define RANDR13_LIBRARY \
     pxid = XRRGetOutputPrimary (dpy, dpyinfo->root_window);
 #endif
 
+#undef RANDR13_LIBRARY
+
   for (i = 0; i < n_monitors; ++i)
     {
       XRROutputInfo *info = XRRGetOutputInfo (dpy, resources,
-- 
2.30.0


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


Thanks,

-- 
Basil

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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-15  9:15         ` Basil L. Contovounesios
@ 2021-02-15 10:05           ` martin rudalics
  2021-02-15 10:24             ` Robert Pluim
  0 siblings, 1 reply; 11+ messages in thread
From: martin rudalics @ 2021-02-15 10:05 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 46509

 > What about this instead:

Better.  The ChangeLog is slightly excessive.

martin





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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-15 10:05           ` martin rudalics
@ 2021-02-15 10:24             ` Robert Pluim
  2021-02-15 11:42               ` Basil L. Contovounesios
  0 siblings, 1 reply; 11+ messages in thread
From: Robert Pluim @ 2021-02-15 10:24 UTC (permalink / raw)
  To: martin rudalics; +Cc: Basil L. Contovounesios, 46509

>>>>> On Mon, 15 Feb 2021 11:05:59 +0100, martin rudalics <rudalics@gmx.at> said:

    >> What about this instead:
    martin> Better.  The ChangeLog is slightly excessive.

And ChangeLog entries for changes depending on preprocessor directives
are supposed to put the directives in [ ], eg

commit 97226aacfde717ec48fa8931c870497e089da17b
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Jan 4 10:33:43 2021 -0800

    Do not assume Xrender merely because Cairo
    
    Problem reported by Andrea Corallo in:
    https://lists.gnu.org/r/emacs-devel/2021-01/msg00225.html
    * src/xterm.c (x_term_init) [USE_CAIRO && !HAVE_XRENDER]:
    Do not call XRenderQueryExtension.





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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-15 10:24             ` Robert Pluim
@ 2021-02-15 11:42               ` Basil L. Contovounesios
  2021-02-16  9:29                 ` martin rudalics
  0 siblings, 1 reply; 11+ messages in thread
From: Basil L. Contovounesios @ 2021-02-15 11:42 UTC (permalink / raw)
  To: Robert Pluim; +Cc: 46509

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

Robert Pluim <rpluim@gmail.com> writes:

>>>>>> On Mon, 15 Feb 2021 11:05:59 +0100, martin rudalics <rudalics@gmx.at> said:
>
>     >> What about this instead:
>     martin> Better.  The ChangeLog is slightly excessive.
>
> And ChangeLog entries for changes depending on preprocessor directives
> are supposed to put the directives in [ ], eg

I know (although I forgot to indicate this for RANDR13_LIBRARY), but in
this case the relevant directives are being changed, and I didn't know
how best to indicate that.  Here's the last commit in this area, for
example:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-compilation-with-GTK-versions-older-than-3.patch --]
[-- Type: text/x-diff, Size: 935 bytes --]

From 338154240e05a06a9fedb806940ef671868b4722 Mon Sep 17 00:00:00 2001
From: Eli Zaretskii <eliz@gnu.org>
Date: Wed, 1 Jan 2020 19:55:35 +0200
Subject: [PATCH] Fix compilation with GTK versions older than 3

* src/xfns.c (x_get_net_workarea): Change a recently moved #ifndef
so that GTK builds which need this function will compile it.
Reported by John <jpff@codemist.co.uk>.

(cherry picked from commit d36adb544d984b91c70f6194da01344e4b2b6fc9)
---
 src/xfns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xfns.c b/src/xfns.c
index b94666d554..d0d5d399dc 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -4572,7 +4572,7 @@ DEFUN ("x-display-save-under", Fx_display_save_under,
     return Qnil;
 }
 
-#ifndef USE_GTK
+#if !defined USE_GTK || !defined HAVE_GTK3
 
 /* Store the geometry of the workarea on display DPYINFO into *RECT.
    Return false if and only if the workarea information cannot be
-- 
2.30.0


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


I've come up with this:

  Pacify unused function warning in xfns.c with GTK2

  * src/xfns.c (x_get_net_workarea, x_get_monitor_for_frame)
  (x_make_monitor_attribute_list, x_get_monitor_attributes_fallback):
  [HAVE_XINERAMA] (x_get_monitor_attributes_xinerama)
  [HAVE_XRANDR] (x_get_monitor_attributes_xrandr)
  (x_get_monitor_attributes): Fix #ifdefs around definitions to avoid
  unused function warnings regardless of GTK use (bug#46509).
  [HAVE_XRANDR] (x_get_monitor_attributes_xrandr): Undefine
  RANDR13_LIBRARY after it's been used.

But I'm not sure this pacifies Martin, so please suggest the best way of
writing this.

Thanks,

-- 
Basil

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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-15 11:42               ` Basil L. Contovounesios
@ 2021-02-16  9:29                 ` martin rudalics
  2021-02-16 16:51                   ` Basil L. Contovounesios
  0 siblings, 1 reply; 11+ messages in thread
From: martin rudalics @ 2021-02-16  9:29 UTC (permalink / raw)
  To: Basil L. Contovounesios, Robert Pluim; +Cc: 46509

 > But I'm not sure this pacifies Martin, so please suggest the best way of
 > writing this.

Don't worry about him and proceed.

Thanks, martin





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

* bug#46509: 28.0.50; Unused static function in xfns.c with GTK2
  2021-02-16  9:29                 ` martin rudalics
@ 2021-02-16 16:51                   ` Basil L. Contovounesios
  0 siblings, 0 replies; 11+ messages in thread
From: Basil L. Contovounesios @ 2021-02-16 16:51 UTC (permalink / raw)
  To: martin rudalics; +Cc: Robert Pluim, 46509-done

tags 46509 fixed
close 46509 28.1
quit

martin rudalics <rudalics@gmx.at> writes:

>> But I'm not sure this pacifies Martin, so please suggest the best way of
>> writing this.
>
> Don't worry about him and proceed.

Hm, does one Martin always say the truth and the other only lies?

Thanks, pushed.

Pacify unused function warning in xfns.c with GTK2
1abf3ae854 2021-02-16 16:46:53 +0000
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=1abf3ae854dbf8405e81680225517bbfac648964

-- 
Basil





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

end of thread, other threads:[~2021-02-16 16:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-14 13:34 bug#46509: 28.0.50; Unused static function in xfns.c with GTK2 Basil L. Contovounesios
2021-02-14 16:04 ` Eli Zaretskii
2021-02-14 17:17   ` martin rudalics
2021-02-14 17:44     ` Basil L. Contovounesios
2021-02-15  8:15       ` martin rudalics
2021-02-15  9:15         ` Basil L. Contovounesios
2021-02-15 10:05           ` martin rudalics
2021-02-15 10:24             ` Robert Pluim
2021-02-15 11:42               ` Basil L. Contovounesios
2021-02-16  9:29                 ` martin rudalics
2021-02-16 16:51                   ` Basil L. Contovounesios

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).