[Libguestfs] daemon/ warnings

Jim Meyering jim at meyering.net
Mon Aug 10 10:20:53 UTC 2009


Richard W.M. Jones wrote:

> On Mon, Aug 10, 2009 at 10:57:13AM +0200, Jim Meyering wrote:
>> Here are a few warning-removal changes for daemon/:
>>  char *
>> -do_debug (char *subcmd, char **argv)
>> +do_debug (char *subcmd ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
>>  {
>>  #if ENABLE_DEBUG_COMMAND
>>    int argc, i;
>
> Is this correct?  Note that the parameters are only unused if
> ENABLE_DEBUG_COMMAND is not defined, but if this symbol is defined
> then they are used.  I'm worried that gcc will try to optimize them or
> something.

How's this?
I nearly added _ATTRIBUTE or ATTRIBUTE_ to the new name,
but that's pretty darn long, and seemed like overkill,
considering it's only used in this one file.

>From 42e83f38b158d05388786a62c3bac80136ec64b9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Mon, 10 Aug 2009 12:17:00 +0200
Subject: [PATCH libguestfs] build: daemon/do_debug: parameters aren't always unused

* daemon/debug.c (MAYBE_UNUSED): Define.
(do_debug): Mark parameters as unused only when they really
are unused.  Spotted by Richard Jones.

SCALAR(0xdd8370)
prefer sizeof *VAR sizeof TYPE (no semantic change)
---
 daemon/debug.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/daemon/debug.c b/daemon/debug.c
index 5b3b5fa..5083398 100644
--- a/daemon/debug.c
+++ b/daemon/debug.c
@@ -60,8 +60,14 @@ static struct cmd cmds[] = {
 };
 #endif

+#if ! ENABLE_DEBUG_COMMAND
+# define MAYBE_UNUSED ATTRIBUTE_UNUSED
+#else
+# define MAYBE_UNUSED /* empty */
+#endif
+
 char *
-do_debug (char *subcmd ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
+do_debug (char *subcmd MAYBE_UNUSED, char **argv MAYBE_UNUSED)
 {
 #if ENABLE_DEBUG_COMMAND
   int argc, i;
--
1.6.4.300.gc9df




More information about the Libguestfs mailing list