]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
cleanup: make unused and const attributes to look the same
authorSami Kerola <kerolasa@iki.fi>
Sun, 4 Sep 2016 08:30:25 +0000 (09:30 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 4 Sep 2016 20:12:49 +0000 (21:12 +0100)
Definition CONST was already reserved in net.h to mean 'const' as a variable
attribute, so function attribute got a ATTRIBUTE_ prefix to separate them.
This change unifies unused to look the same.

curses.c
display.c
dns.c
gtk.c
mtr.h

index c4b7980624a4d908f95ad10d9df5873d929b4526..a071f40c404aadfd5412df45db6535f9417633d1 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -71,7 +71,7 @@ static void pwcenter(char *str)
 {
   int maxx;
   size_t cx;
-  int __unused_int UNUSED;
+  int __unused_int ATTRIBUTE_UNUSED;
 
   getmaxyx(stdscr, __unused_int, maxx);
   cx = (size_t)(maxx - strlen(str)) / 2;
@@ -367,7 +367,7 @@ static void mtr_curses_hosts(struct mtr_ctl *ctl, int startstat)
   int i, j, k;
   int hd_len;
   char buf[1024];
-  int __unused_int UNUSED;
+  int __unused_int ATTRIBUTE_UNUSED;
 
   max = net_max(ctl);
 
@@ -577,7 +577,7 @@ static void mtr_curses_graph(struct mtr_ctl *ctl, int startstat, int cols)
        int max, at, y;
        ip_t * addr;
        char* name;
-       int __unused_int UNUSED;
+       int __unused_int ATTRIBUTE_UNUSED;
 
        max = net_max(ctl);
 
@@ -619,7 +619,7 @@ extern void mtr_curses_redraw(struct mtr_ctl *ctl)
   int startstat;
   int rowstat;
   time_t t;
-  int __unused_int UNUSED;
+  int __unused_int ATTRIBUTE_UNUSED;
 
   int i, j;
   int  hd_len = 0;
index b66cd83c9b0e77296572ff8c010f7eb64757dd10..9a762048d8c8bebdef296001715254508a07ae89 100644 (file)
--- a/display.c
+++ b/display.c
@@ -49,9 +49,9 @@
 #endif
 
 #ifdef HAVE_GTK
-#define UNUSED_IF_NO_GTK
+# define UNUSED_IF_NO_GTK /* empty */
 #else
-#define UNUSED_IF_NO_GTK UNUSED
+# define UNUSED_IF_NO_GTK ATTRIBUTE_UNUSED
 #endif
 
 extern void display_detect(struct mtr_ctl *ctl, int *argc UNUSED_IF_NO_GTK,
diff --git a/dns.c b/dns.c
index ab6324a72e7275650ccaf755f07ff6e85d895a41..92e9fb7c30b373ccfe2801d32142a63f9fc47293 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -63,9 +63,9 @@ extern char *strlongip(struct mtr_ctl *ctl, ip_t * ip)
 
 
 #ifdef ENABLE_IPV6
-#define UNUSED_IF_NO_IPV6
+# define UNUSED_IF_NO_IPV6 /* empty */
 #else
-#define UNUSED_IF_NO_IPV6 UNUSED
+# define UNUSED_IF_NO_IPV6 ATTRIBUTE_UNUSED
 #endif
 
 static int longipstr( char *s, ip_t *dst, int family UNUSED_IF_NO_IPV6)
diff --git a/gtk.c b/gtk.c
index 1d730c3025f76618b8597cf9d68cf4a5f3328503..f196e24b1355428ea457e2ea485e49324e500bdb 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -74,7 +74,7 @@ static void gtk_do_init(int *argc, char ***argv)
 }
 
 
-extern int gtk_detect(UNUSED int *argc, UNUSED char ***argv)
+extern int gtk_detect(ATTRIBUTE_UNUSED int *argc, ATTRIBUTE_UNUSED char ***argv)
 {
   if(getenv("DISPLAY") != NULL) {
     /* If we do this here, gtk_init exits on an error. This happens
@@ -87,7 +87,8 @@ extern int gtk_detect(UNUSED int *argc, UNUSED char ***argv)
 }
 
 
-static gint Window_destroy(UNUSED GtkWidget *Window, UNUSED gpointer data)
+static gint Window_destroy(ATTRIBUTE_UNUSED GtkWidget *Window,
+                          ATTRIBUTE_UNUSED gpointer data)
 {
   gtk_main_quit();
 
@@ -95,7 +96,7 @@ static gint Window_destroy(UNUSED GtkWidget *Window, UNUSED gpointer data)
 }
 
 
-static gint Restart_clicked(UNUSED GtkWidget *Button, gpointer data)
+static gint Restart_clicked(ATTRIBUTE_UNUSED GtkWidget *Button, gpointer data)
 {
   struct mtr_ctl *ctl = (struct mtr_ctl *)data;
 
@@ -106,7 +107,7 @@ static gint Restart_clicked(UNUSED GtkWidget *Button, gpointer data)
 }
 
 
-static gint Pause_clicked(UNUSED GtkWidget *Button, gpointer data)
+static gint Pause_clicked(ATTRIBUTE_UNUSED GtkWidget *Button, gpointer data)
 {
   struct mtr_ctl *ctl = (struct mtr_ctl *)data;
 
@@ -123,7 +124,8 @@ static gint Pause_clicked(UNUSED GtkWidget *Button, gpointer data)
   return FALSE;
 }
 
-static gint About_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data)
+static gint About_clicked(ATTRIBUTE_UNUSED GtkWidget *Button,
+                         ATTRIBUTE_UNUSED gpointer data)
 {
   static const gchar *authors[] = {
         "Matt Kimball <mkimball@xmission.com>",
@@ -198,7 +200,7 @@ static gint About_clicked(UNUSED GtkWidget *Button, UNUSED gpointer data)
  * What's the problem with this? (-> "I don't think so)
  */
 
-static gint WaitTime_changed(UNUSED GtkAdjustment *Adj,
+static gint WaitTime_changed(ATTRIBUTE_UNUSED GtkAdjustment *Adj,
                             GtkWidget *data)
 {
   struct mtr_ctl *ctl = (struct mtr_ctl *)data;
@@ -317,7 +319,7 @@ enum {
 // earlier, so it is ok. Nothing to worry about....
 #define POINTER_TO_INT(p) ((int)(long)(p))
 
-static void  float_formatter(GtkTreeViewColumn *tree_column UNUSED,
+static void  float_formatter(GtkTreeViewColumn *tree_column ATTRIBUTE_UNUSED,
   GtkCellRenderer   *cell, 
   GtkTreeModel      *tree_model,
   GtkTreeIter       *iter, 
@@ -330,7 +332,7 @@ static void  float_formatter(GtkTreeViewColumn *tree_column UNUSED,
   g_object_set(cell, "text", text, NULL);
 }
 
-static void  percent_formatter(GtkTreeViewColumn *tree_column UNUSED,
+static void  percent_formatter(GtkTreeViewColumn *tree_column ATTRIBUTE_UNUSED,
   GtkCellRenderer   *cell, 
   GtkTreeModel      *tree_model,
   GtkTreeIter       *iter, 
@@ -609,7 +611,8 @@ static gint gtk_ping(gpointer data)
 }
 
 
-static gboolean gtk_net_data(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, gpointer data)
+static gboolean gtk_net_data(ATTRIBUTE_UNUSED GIOChannel *channel,
+                            ATTRIBUTE_UNUSED GIOCondition cond, gpointer data)
 {
   struct mtr_ctl *ctl = (struct mtr_ctl *)data;
 
@@ -618,7 +621,8 @@ static gboolean gtk_net_data(UNUSED GIOChannel *channel, UNUSED GIOCondition con
 }
 
 
-static gboolean gtk_dns_data(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, gpointer data)
+static gboolean gtk_dns_data(ATTRIBUTE_UNUSED GIOChannel *channel,
+                            ATTRIBUTE_UNUSED GIOCondition cond, gpointer data)
 {
   struct mtr_ctl *ctl = (struct mtr_ctl *)data;
 
@@ -627,7 +631,8 @@ static gboolean gtk_dns_data(UNUSED GIOChannel *channel, UNUSED GIOCondition con
   return TRUE;
 }
 #ifdef ENABLE_IPV6
-static gboolean gtk_dns_data6(UNUSED GIOChannel *channel, UNUSED GIOCondition cond, gpointer data)
+static gboolean gtk_dns_data6(ATTRIBUTE_UNUSED GIOChannel *channel,
+                             ATTRIBUTE_UNUSED GIOCondition cond, gpointer data)
 {
   struct mtr_ctl *ctl = (struct mtr_ctl *)data;
 
@@ -658,7 +663,8 @@ extern void gtk_loop(struct mtr_ctl *ctl)
   gtk_main();
 }
 
-static gboolean NewDestination_activate(GtkWidget *widget UNUSED, gpointer data)
+static gboolean NewDestination_activate(GtkWidget *widget ATTRIBUTE_UNUSED,
+                                       gpointer data)
 {
   gchar *hostname;
   struct mtr_ctl *ctl = (struct mtr_ctl *)data;
@@ -675,7 +681,7 @@ static gboolean NewDestination_activate(GtkWidget *widget UNUSED, gpointer data)
 }
 
 
-static gboolean Copy_activate(GtkWidget *widget UNUSED, gpointer data)
+static gboolean Copy_activate(GtkWidget *widget ATTRIBUTE_UNUSED, gpointer data)
 {
   gchar *hostname;
   GtkTreePath *path = (GtkTreePath*)data;
@@ -709,7 +715,8 @@ static gchar *getSelectedHost(GtkTreePath *path)
 }
 
 
-static gboolean ReportTreeView_clicked(GtkWidget *Tree UNUSED, GdkEventButton *event, gpointer data)
+static gboolean ReportTreeView_clicked(GtkWidget *Tree ATTRIBUTE_UNUSED,
+                                      GdkEventButton *event, gpointer data)
 {
   GtkWidget* popup_menu; 
   GtkWidget* copy_item; 
diff --git a/mtr.h b/mtr.h
index 494d0eda67081fc34077cb2c6f5d6eec0a86f5f8..b43a80241baf7320d3071d826845014e7059b981 100644 (file)
--- a/mtr.h
+++ b/mtr.h
@@ -31,10 +31,11 @@ typedef struct in6_addr ip_t;
 typedef struct in_addr ip_t;
 #endif
 
-#ifdef __GNUC__
-#define UNUSED __attribute__((__unused__))
+/* The __unused__ attribute was added in gcc 3.2.7.  */
+#if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
+# define ATTRIBUTE_UNUSED __attribute__((__unused__))
 #else
-#define UNUSED
+# define ATTRIBUTE_UNUSED /* empty */
 #endif
 
 /* The __const__ attribute was added in gcc 2.95.  */