From: Sami Kerola Date: Sun, 4 Sep 2016 08:30:25 +0000 (+0100) Subject: cleanup: make unused and const attributes to look the same X-Git-Tag: v0.88~26^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1806e9c75245e11820d9ece9fbf32dc4ae2955b;p=thirdparty%2Fmtr.git cleanup: make unused and const attributes to look the same 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. --- diff --git a/curses.c b/curses.c index c4b7980..a071f40 100644 --- 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; diff --git a/display.c b/display.c index b66cd83..9a76204 100644 --- 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 ab6324a..92e9fb7 100644 --- 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 1d730c3..f196e24 100644 --- 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 ", @@ -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 494d0ed..b43a802 100644 --- 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. */