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

Re: [Libguestfs] daemon/ warnings



On 10/08/09 09:57, Jim Meyering wrote:
Here are a few warning-removal changes for daemon/:

From eea38a1937ccd396603ed899d829d2982755ea4a Mon Sep 17 00:00:00 2001
From: Jim Meyering<meyering redhat com>
Date: Thu, 6 Aug 2009 15:25:03 +0200
Subject: [PATCH 1/4] define ATTRIBUTE_UNUSED

* daemon/daemon.h (__attribute__, ATTRIBUTE_UNUSED): Define.
---
  daemon/daemon.h |   10 ++++++++++
  1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/daemon/daemon.h b/daemon/daemon.h
index 70a2351..a6bbb73 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -213,4 +213,14 @@ extern void reply (xdrproc_t xdrp, char *ret);
    }									\
    while (0)

+#ifndef __attribute__
+# if __GNUC__<  2 || (__GNUC__ == 2&&  __GNUC_MINOR__<  8)
+#  define __attribute__(x) /* empty */
+# endif
+#endif
+
+#ifndef ATTRIBUTE_UNUSED
+# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+#endif
+
  #endif /* GUESTFSD_DAEMON_H */
--
1.6.4.174.gc193a


From af4e98c3371f6008188fb3ef7136c1ebda008933 Mon Sep 17 00:00:00 2001
From: Jim Meyering<meyering redhat com>
Date: Thu, 6 Aug 2009 15:26:13 +0200
Subject: [PATCH 2/4] build: avoid warnings in daemon/debug.c

* daemon/debug.c (do_debug): Mark parameters as unused.
---
  daemon/debug.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/daemon/debug.c b/daemon/debug.c
index 13b7240..5b3b5fa 100644
--- a/daemon/debug.c
+++ b/daemon/debug.c
@@ -61,7 +61,7 @@ static struct cmd cmds[] = {
  #endif

  char *
-do_debug (char *subcmd, char **argv)
+do_debug (char *subcmd ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
  {
  #if ENABLE_DEBUG_COMMAND
    int argc, i;
--
1.6.4.174.gc193a

What warnings are you turning on? I normally compile with -Wall, and I don't get warning for unused function arguments:

[mbooth mbooth daemon]$ make CFLAGS="-g -Wall" debug.o
gcc -DHAVE_CONFIG_H -I. -I./lib -Ilib -g -Wall -MT debug.o -MD -MP -MF .deps/debug.Tpo -c -o debug.o debug.c
mv -f .deps/debug.Tpo .deps/debug.Po

From a174e20227e5299a172934d9f60023ac55530a1f Mon Sep 17 00:00:00 2001
From: Jim Meyering<meyering redhat com>
Date: Thu, 6 Aug 2009 15:28:48 +0200
Subject: [PATCH 3/4] build: avoid warnings in daemon/guestfsd.c

* daemon/guestfsd.c (print_arginfo, print_shell_quote): Mark each
"info" parameter as unused.
---
  daemon/guestfsd.c |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 07a1c5e..07a952f 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -718,7 +718,7 @@ split_lines (char *str)
   */
  static int
  print_shell_quote (FILE *stream,
-                   const struct printf_info *info,
+                   const struct printf_info *info ATTRIBUTE_UNUSED,
                     const void *const *args)
  {
  #define SAFE(c) (isalnum((c)) ||					\
@@ -751,7 +751,7 @@ print_sysroot_shell_quote (FILE *stream,

  #ifdef HAVE_REGISTER_PRINTF_SPECIFIER
  static int
-print_arginfo (const struct printf_info *info,
+print_arginfo (const struct printf_info *info ATTRIBUTE_UNUSED,
                 size_t n, int *argtypes, int *size)
  {
    if (n>  0) {
--
1.6.4.174.gc193a


From b9842a2ca010bf89b11b4b640bbdee5df58f8341 Mon Sep 17 00:00:00 2001
From: Jim Meyering<meyering redhat com>
Date: Thu, 6 Aug 2009 16:05:44 +0200
Subject: [PATCH 4/4] build: avoid warnings in daemon/inotify.c

Avoid "comparison between signed and unsigned integer expressions"
warnings.  If it's at all hard or risky to avoid this type of warning,
then it's not worthwhile.  Here, it's easy and safe.
* daemon/inotify.c (inotify_posn): Declare local to be of unsigned type.
(do_inotify_read, do_inotify_files): Likewise.
---
  daemon/inotify.c |    7 ++++---
  1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/daemon/inotify.c b/daemon/inotify.c
index 1b90f2b..8bb8ed2 100644
--- a/daemon/inotify.c
+++ b/daemon/inotify.c
@@ -33,7 +33,7 @@
  static int inotify_fd = -1;

  static char inotify_buf[64*1024*1024];	/* Event buffer, [0..posn-1] is valid */
-static int inotify_posn = 0;
+static size_t inotify_posn = 0;

  /* Because inotify_init does NEED_ROOT, NEED_INOTIFY implies NEED_ROOT. */
  #define NEED_INOTIFY(errcode)						\
@@ -184,7 +184,8 @@ do_inotify_read (void)

    while (space>  0) {
      struct inotify_event *event;
-    int n, r;
+    int r;
+    size_t n;

      r = read (inotify_fd, inotify_buf + inotify_posn,
                sizeof (inotify_buf) - inotify_posn);
@@ -274,7 +275,7 @@ do_inotify_files (void)
  {
    char **ret = NULL;
    int size = 0, alloc = 0;
-  int i;
+  unsigned int i;
    FILE *fp;
    guestfs_int_inotify_event_list *events;
    char buf[PATH_MAX];
--
1.6.4.174.gc193a

Same here, I don't get any warnings.

In general, I would like to get down to no compiler warnings. The biggest culprit in daemon, though, is rpcgen generated stuff.

Matt
--
Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:       +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490


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