[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] daemon/ warnings

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

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[] = {

+# define MAYBE_UNUSED /* empty */
 char *
-do_debug (char *subcmd ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
+do_debug (char *subcmd MAYBE_UNUSED, char **argv MAYBE_UNUSED)
   int argc, i;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]