public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: bfin: gui: fix -Wunused-but-set-variable warnings
@ 2023-12-08  5:31 Michael Frysinger
  0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2023-12-08  5:31 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=058d0bf5f09a4488b6d7f3d3aa5fa0958e886c3b

commit 058d0bf5f09a4488b6d7f3d3aa5fa0958e886c3b
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Wed Dec 6 06:36:15 2023 -0700

    sim: bfin: gui: fix -Wunused-but-set-variable warnings
    
    Rework the code to use static inline functions when it's disabled
    rather than macros so the compiler knows the various function args
    are always used.  The ifdef macros are a bit ugly, but get the job
    done without duplicating the function prototypes.

Diff:
---
 sim/bfin/gui.h | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/sim/bfin/gui.h b/sim/bfin/gui.h
index ef363b59986..daf4398694b 100644
--- a/sim/bfin/gui.h
+++ b/sim/bfin/gui.h
@@ -21,7 +21,14 @@
 #ifndef BFIN_GUI_H
 #define BFIN_GUI_H
 
+/* These macros are ugly.  */
 #ifdef HAVE_SDL
+# define _BFIN_GUI_INLINE
+# define _BFIN_GUI_STUB(...) ;
+#else
+# define _BFIN_GUI_INLINE ATTRIBUTE_UNUSED static inline
+# define _BFIN_GUI_STUB(val) { return val; }
+#endif
 
 enum gui_color {
   GUI_COLOR_RGB_565,
@@ -30,21 +37,24 @@ enum gui_color {
   GUI_COLOR_BGR_888,
   GUI_COLOR_RGBA_8888,
 };
-enum gui_color bfin_gui_color (const char *color);
-int bfin_gui_color_depth (enum gui_color color);
-
-void *bfin_gui_setup (void *state, int enabled, int height, int width,
-		      enum gui_color color);
+_BFIN_GUI_INLINE
+enum gui_color bfin_gui_color (const char *color)
+  _BFIN_GUI_STUB(GUI_COLOR_RGB_565)
 
-unsigned bfin_gui_update (void *state, const void *source, unsigned nr_bytes);
+_BFIN_GUI_INLINE
+int bfin_gui_color_depth (enum gui_color color)
+  _BFIN_GUI_STUB(0)
 
-#else
+_BFIN_GUI_INLINE
+void *bfin_gui_setup (void *state, int enabled, int height, int width,
+		      enum gui_color color)
+  _BFIN_GUI_STUB(NULL)
 
-# define bfin_gui_color(...)		0
-# define bfin_gui_color_depth(...)	0
-# define bfin_gui_setup(...)		NULL
-# define bfin_gui_update(...)		0
+_BFIN_GUI_INLINE
+unsigned bfin_gui_update (void *state, const void *source, unsigned nr_bytes)
+  _BFIN_GUI_STUB(0)
 
-#endif
+#undef _BFIN_GUI_INLINE
+#undef _BFIN_GUI_STUB
 
 #endif

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-08  5:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-08  5:31 [binutils-gdb] sim: bfin: gui: fix -Wunused-but-set-variable warnings Michael Frysinger

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