public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/net-tools:master commit in: lib/
  2011-04-09 13:58 [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
@ 2011-04-09 13:58 ` Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2011-04-09 13:58 UTC (permalink / raw
  To: gentoo-commits

commit:     1dd95c51357839aa86259dd4d9372b7a4e946264
Author:     Bernd Eckenfels <net-tools <AT> lina <DOT> inka <DOT> de>
AuthorDate: Thu Jan 27 00:43:13 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Jan 27 00:43:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=1dd95c51

corrected indention

---
 lib/net-support.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/net-support.h b/lib/net-support.h
index 2820619..b79f11b 100644
--- a/lib/net-support.h
+++ b/lib/net-support.h
@@ -140,7 +140,7 @@ extern char afname[];
 
 #define AFTRANS_OPTS \
 	{"ax25",	0,	0,	1}, \
-       {"x25",         0,      0,      1}, \
+	{"x25",         0,      0,      1}, \
 	{"ip",		0,	0,	1}, \
 	{"ipx",         0,	0,	1}, \
 	{"appletalk",	0,	0,	1}, \
@@ -148,7 +148,7 @@ extern char afname[];
 	{"inet",	0,	0,	1}, \
 	{"inet6",	0,	0,	1}, \
 	{"ddp",		0,	0,	1}, \
-	{"rose",		0,	0,	1}, \
+	{"rose",	0,	0,	1}, \
 	{"unix",	0,	0,	1}, \
 	{"tcpip",	0,	0,	1}
 #define AFTRANS_CNT 12



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/net-tools:master commit in: lib/
@ 2011-11-21  1:35 Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2011-11-21  1:35 UTC (permalink / raw
  To: gentoo-commits

commit:     6a9347cb91535eb35306eff731d94384c9b7025e
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 00:08:15 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 00:11:22 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=6a9347cb

get_sname: unify numeric handling

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 lib/inet.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/inet.c b/lib/inet.c
index 8080364..073c8a3 100644
--- a/lib/inet.c
+++ b/lib/inet.c
@@ -423,10 +423,9 @@ const char *get_sname(int socknumber, const char *proto, int numeric)
 
     if (socknumber == 0)
 	return ("*");
-    if (numeric) {
-	sprintf(buffer, "%d", ntohs(socknumber));
-	return (buffer);
-    }
+    if (numeric)
+	goto do_ntohs;
+
     if (!init) {
 	(void) read_services();
 	init = 1;
@@ -443,8 +442,11 @@ const char *get_sname(int socknumber, const char *proto, int numeric)
 	    sprintf(buffer, "%s", item->name);
 
     }
-    if (!buffer[0])
+
+    if (!buffer[0]) {
+ do_ntohs:
 	sprintf(buffer, "%d", ntohs(socknumber));
+    }
     return (buffer);
 }
 



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/net-tools:master commit in: lib/
  2011-11-21  1:38 [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
@ 2011-11-21  1:35 ` Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2011-11-21  1:35 UTC (permalink / raw
  To: gentoo-commits

commit:     243cd05e7ac857f64648639e970a8c0d28dc0f2e
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 00:25:56 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 00:46:38 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=243cd05e

pull in stdlib.h for malloc() prototype

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 lib/proc.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/proc.c b/lib/proc.c
index 9cd4eeb..5c709ed 100644
--- a/lib/proc.c
+++ b/lib/proc.c
@@ -5,6 +5,7 @@
 #include <string.h>
 #include <stdarg.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <ctype.h>
 #include <unistd.h>
 



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/net-tools:master commit in: lib/
@ 2011-11-21  1:35 Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2011-11-21  1:35 UTC (permalink / raw
  To: gentoo-commits

commit:     7ae4aa5619cc7e7067ea6ee24a4d49fa5b4a72fd
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 00:08:37 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 00:11:56 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=7ae4aa56

get_sname: avoid buffer overflows if proto name is too long

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 lib/inet.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/lib/inet.c b/lib/inet.c
index 073c8a3..60e55df 100644
--- a/lib/inet.c
+++ b/lib/inet.c
@@ -431,16 +431,17 @@ const char *get_sname(int socknumber, const char *proto, int numeric)
 	init = 1;
     }
     buffer[0] = '\0';
-    if (!strcmp(proto, "tcp")) {
-	if ((item = searchlist(tcp_name, socknumber)) != NULL)
-	    sprintf(buffer, "%s", item->name);
-    } else if (!strcmp(proto, "udp")) {
-	if ((item = searchlist(udp_name, socknumber)) != NULL)
-	    sprintf(buffer, "%s", item->name);
-    } else if (!strcmp(proto, "raw")) {
-	if ((item = searchlist(raw_name, socknumber)) != NULL)
-	    sprintf(buffer, "%s", item->name);
-
+    if (!strcmp(proto, "tcp"))
+	item = searchlist(tcp_name, socknumber);
+    else if (!strcmp(proto, "udp"))
+	item = searchlist(udp_name, socknumber);
+    else if (!strcmp(proto, "raw"))
+	item = searchlist(raw_name, socknumber);
+    else
+	item = NULL;
+    if (item) {
+	strncpy(buffer, item->name, sizeof(buffer));
+	buffer[sizeof(buffer) - 1] = '\0';
     }
 
     if (!buffer[0]) {



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/net-tools:master commit in: lib/
  2011-11-21  1:38 [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
@ 2011-11-21  1:35 ` Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2011-11-21  1:35 UTC (permalink / raw
  To: gentoo-commits

commit:     2b4f34b987dbb7a2003219162bab0d61305c95d7
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 00:07:40 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 00:11:05 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=2b4f34b9

get_sname: constify args/return when possible

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 lib/inet.c        |    2 +-
 lib/net-support.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/inet.c b/lib/inet.c
index c0f7efa..8080364 100644
--- a/lib/inet.c
+++ b/lib/inet.c
@@ -416,7 +416,7 @@ static int read_services(void)
 }
 
 
-char *get_sname(int socknumber, char *proto, int numeric)
+const char *get_sname(int socknumber, const char *proto, int numeric)
 {
     static char buffer[64], init = 0;
     struct service *item;

diff --git a/lib/net-support.h b/lib/net-support.h
index b79f11b..dae15ac 100644
--- a/lib/net-support.h
+++ b/lib/net-support.h
@@ -124,7 +124,7 @@ extern int ROSE_rinput(int action, int flags, char **argv);
 extern int aftrans_opt(const char *arg);
 extern void aftrans_def(char *tool, char *argv0, char *dflt);
 
-extern char *get_sname(int socknumber, char *proto, int numeric);
+extern const char *get_sname(int socknumber, const char *proto, int numeric);
 
 extern int flag_unx;
 extern int flag_ipx;



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/net-tools:master commit in: lib/
  2011-11-21  1:38 [gentoo-commits] proj/net-tools:gentoo commit in: lib/ Mike Frysinger
@ 2011-11-21  1:35 ` Mike Frysinger
  0 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2011-11-21  1:35 UTC (permalink / raw
  To: gentoo-commits

commit:     46cd57a736c30bafd41406781e7b1c6532e6a97d
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 00:27:14 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 00:46:38 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=46cd57a7

fix up unused variable warnings

Some of these are unused, so drop them.  Others are only used in debug
code, so refactor those so things are always compiled.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 lib/arcnet.c   |   32 ++++++++++++++------------------
 lib/ax25.c     |   27 +++++++++++++++------------
 lib/ether.c    |   32 ++++++++++++++------------------
 lib/eui64.c    |   37 +++++++++++++++++--------------------
 lib/fddi.c     |   32 ++++++++++++++------------------
 lib/hippi.c    |   32 ++++++++++++++------------------
 lib/ib.c       |   10 +++++++---
 lib/inet6_gr.c |    8 +++-----
 lib/ipx.c      |    2 --
 lib/netrom.c   |   27 +++++++++++++++------------
 lib/rose.c     |   11 -----------
 lib/tr.c       |   32 ++++++++++++++------------------
 12 files changed, 127 insertions(+), 155 deletions(-)

diff --git a/lib/arcnet.c b/lib/arcnet.c
index 35a2b9a..10b59e5 100644
--- a/lib/arcnet.c
+++ b/lib/arcnet.c
@@ -43,6 +43,11 @@ static const char *pr_arcnet(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an ARCnet address and convert to binary. */
 static int in_arcnet(char *bufp, struct sockaddr *sap)
@@ -66,9 +71,8 @@ static int in_arcnet(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_arcnet(%s): invalid arcnet address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_arcnet(%s): invalid arcnet address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -81,9 +85,8 @@ static int in_arcnet(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val |= c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_arcnet(%s): invalid arcnet address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_arcnet(%s): invalid arcnet address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -92,28 +95,21 @@ static int in_arcnet(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == ETH_ALEN) {
-#ifdef DEBUG
+	    if (_DEBUG && i == ETH_ALEN)
 		fprintf(stderr, _("in_arcnet(%s): trailing : ignored!\n"),
-			orig)
-#endif
-		    ;		/* nothing */
-	    }
+			orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == ETH_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == ETH_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_arcnet(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_arcnet(%s): %s\n", orig, pr_arcnet(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_arcnet(%s): %s\n", orig, pr_arcnet(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/ax25.c b/lib/ax25.c
index 209e479..afc035b 100644
--- a/lib/ax25.c
+++ b/lib/ax25.c
@@ -76,6 +76,11 @@ static const char *
     return (AX25_print(((struct sockaddr_ax25 *) sap)->sax25_call.ax25_call));
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 static int AX25_input(int type, char *bufp, struct sockaddr *sap)
 {
@@ -95,9 +100,8 @@ static int AX25_input(int type, char *bufp, struct sockaddr *sap)
 	    c = toupper(c);
 	if (!(isupper(c) || isdigit(c))) {
 	    safe_strncpy(AX25_errmsg, _("Invalid callsign"), sizeof(AX25_errmsg));
-#ifdef DEBUG
-	    fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -108,9 +112,8 @@ static int AX25_input(int type, char *bufp, struct sockaddr *sap)
     /* Callsign too long? */
     if ((i == 6) && (*bufp != '-') && (*bufp != '\0')) {
 	strcpy(AX25_errmsg, _("Callsign too long"));
-#ifdef DEBUG
-	fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
-#endif
+	if (_DEBUG)
+	    fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
 	errno = E2BIG;
 	return (-1);
     }
@@ -128,12 +131,12 @@ static int AX25_input(int type, char *bufp, struct sockaddr *sap)
     }
 
     /* All done. */
-#ifdef DEBUG
-    fprintf(stderr, "ax25_input(%s): ", orig);
-    for (i = 0; i < sizeof(ax25_address); i++)
-	fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
-    fprintf(stderr, "\n");
-#endif
+    if (_DEBUG) {
+	fprintf(stderr, "ax25_input(%s): ", orig);
+	for (i = 0; i < sizeof(ax25_address); i++)
+	    fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
+	fprintf(stderr, "\n");
+    }
 
     return (0);
 }

diff --git a/lib/ether.c b/lib/ether.c
index ddd1598..9bf8a55 100644
--- a/lib/ether.c
+++ b/lib/ether.c
@@ -46,6 +46,11 @@ static const char *pr_ether(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an Ethernet address and convert to binary. */
 static int in_ether(char *bufp, struct sockaddr *sap)
@@ -70,9 +75,8 @@ static int in_ether(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -87,9 +91,8 @@ static int in_ether(char *bufp, struct sockaddr *sap)
 	else if (c == ':' || c == 0)
 	    val >>= 4;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -100,28 +103,21 @@ static int in_ether(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == ETH_ALEN) {
-#ifdef DEBUG
+	    if (_DEBUG && i == ETH_ALEN)
 		fprintf(stderr, _("in_ether(%s): trailing : ignored!\n"),
-			orig)
-#endif
-		    ;		/* nothing */
-	    }
+			orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == ETH_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == ETH_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_ether(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_ether(%s): %s\n", orig, pr_ether(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_ether(%s): %s\n", orig, pr_ether(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/eui64.c b/lib/eui64.c
index 6ab7d26..32822a3 100644
--- a/lib/eui64.c
+++ b/lib/eui64.c
@@ -60,6 +60,12 @@ static const char *pr_eui64(const char *ptr)
 	return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
+
 /* Start the PPP encapsulation on the file descriptor. */
 static int in_eui64( char *bufp, struct sockaddr *sap )
 {
@@ -84,10 +90,9 @@ static int in_eui64( char *bufp, struct sockaddr *sap )
 		else if (c >= 'A' && c <= 'F')
 			val = c - 'A' + 10;
 		else {
-#ifdef DEBUG
-			fprintf( stderr, _("in_eui64(%s): invalid eui64 address!\n"), 
-				 orig );
-#endif
+			if (_DEBUG)
+				fprintf( stderr, _("in_eui64(%s): invalid eui64 address!\n"),
+					 orig );
 			errno = EINVAL;
 			return (-1);
 		}
@@ -103,10 +108,9 @@ static int in_eui64( char *bufp, struct sockaddr *sap )
 		else if (c == ':' || c == 0)
 			val >>= 4;
 		else {
-#ifdef DEBUG
-			fprintf( stderr, _("in_eui64(%s): invalid eui64 address!\n"), 
-				 orig );
-#endif
+			if (_DEBUG)
+				fprintf( stderr, _("in_eui64(%s): invalid eui64 address!\n"),
+					 orig );
 			errno = EINVAL;
 			return (-1);
 		}
@@ -119,28 +123,21 @@ static int in_eui64( char *bufp, struct sockaddr *sap )
 		
 		/* We might get a semicolon here - not required. */
 		if (*bufp == ':') {
-			if (i == EUI64_ALEN) {
-#ifdef DEBUG
+			if (_DEBUG && i == EUI64_ALEN)
 				fprintf(stderr, _("in_eui64(%s): trailing : ignored!\n"),
-					orig)
-#endif
-					; /* nothing */
-			}
+					orig);
 			bufp++;
 		}
 	}
 
 	/* That's it.  Any trailing junk? */
-	if ((i == EUI64_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+	if (_DEBUG && (i == EUI64_ALEN) && (*bufp != '\0')) {
 		fprintf(stderr, _("in_eui64(%s): trailing junk!\n"), orig);
 		errno = EINVAL;
 		return (-1);
-#endif
 	}
-#ifdef DEBUG
-	fprintf(stderr, "in_eui64(%s): %s\n", orig, pr_eui64(sap->sa_data));
-#endif
+	if (_DEBUG)
+		fprintf(stderr, "in_eui64(%s): %s\n", orig, pr_eui64(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/fddi.c b/lib/fddi.c
index 75adddd..750cc2d 100644
--- a/lib/fddi.c
+++ b/lib/fddi.c
@@ -57,6 +57,11 @@ static const char *pr_fddi(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an FDDI address and convert to binary. */
 static int in_fddi(char *bufp, struct sockaddr *sap)
@@ -80,9 +85,8 @@ static int in_fddi(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -95,9 +99,8 @@ static int in_fddi(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val |= c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -106,28 +109,21 @@ static int in_fddi(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == FDDI_K_ALEN) {
-#ifdef DEBUG
+	    if (_DEBUG && i == FDDI_K_ALEN)
 		fprintf(stderr, _("in_fddi(%s): trailing : ignored!\n"),
-			orig)
-#endif
-		    ;		/* nothing */
-	    }
+			orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == FDDI_K_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == FDDI_K_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_fddi(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_fddi(%s): %s\n", orig, pr_fddi(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_fddi(%s): %s\n", orig, pr_fddi(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/hippi.c b/lib/hippi.c
index bd73ea1..ae6e31b 100644
--- a/lib/hippi.c
+++ b/lib/hippi.c
@@ -57,6 +57,11 @@ static const char *pr_hippi(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an HIPPI address and convert to binary. */
 static int in_hippi(char *bufp, struct sockaddr *sap)
@@ -80,9 +85,8 @@ static int in_hippi(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -95,9 +99,8 @@ static int in_hippi(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val |= c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -106,27 +109,20 @@ static int in_hippi(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == HIPPI_ALEN) {
-#ifdef DEBUG
-		fprintf(stderr, _("in_hippi(%s): trailing : ignored!\n"), orig)
-#endif
-		    ;		/* nothing */
-	    }
+	    if (_DEBUG && i == HIPPI_ALEN)
+		fprintf(stderr, _("in_hippi(%s): trailing : ignored!\n"), orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == HIPPI_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == HIPPI_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_hippi(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_hippi(%s): %s\n", orig, pr_hippi(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_hippi(%s): %s\n", orig, pr_hippi(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/ib.c b/lib/ib.c
index e05bd3e..98f3446 100644
--- a/lib/ib.c
+++ b/lib/ib.c
@@ -56,6 +56,11 @@ static const char *pr_ib(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an Infiniband address and convert to binary. */
 static int in_ib(char *bufp, struct sockaddr *sap)
@@ -80,9 +85,8 @@ static int in_ib(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}

diff --git a/lib/inet6_gr.c b/lib/inet6_gr.c
index 7f1bc20..2b055f6 100644
--- a/lib/inet6_gr.c
+++ b/lib/inet6_gr.c
@@ -92,10 +92,8 @@ int rprint_fib6(int ext, int numeric)
 		     naddr6p[0], naddr6p[1], naddr6p[2], naddr6p[3],
 		     naddr6p[4], naddr6p[5], naddr6p[6], naddr6p[7],
 		     &metric, &refcnt, &use, &iflags, iface);
-#if 0
-	if (num < 23)
+	if (0 && num < 23)
 	    continue;
-#endif
 	if (iflags & RTF_CACHE) {
 		if (!(numeric & RTF_CACHE))
 			continue;
@@ -163,7 +161,7 @@ int rprint_cache6(int ext, int numeric)
     char buff[4096], iface[16], flags[16];
     char addr6[128], haddr[20], statestr[20];
     struct sockaddr_in6 saddr6;
-    int type, num, refcnt, prefix_len, location, state, gc;
+    int type, refcnt, prefix_len, location, state, gc;
     long tstamp, expire, ndflags, reachable, stale, delete;
     FILE *fp = fopen(_PATH_PROCNET_NDISC, "r");
     char addr6p[8][5], haddrp[6][3];
@@ -184,7 +182,7 @@ int rprint_cache6(int ext, int numeric)
 
 
     while (fgets(buff, 1023, fp)) {
-	num = sscanf(buff, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %08lx %08lx %08lx %04x %04x %04lx %8s %2s%2s%2s%2s%2s%2s\n",
+	sscanf(buff, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %08lx %08lx %08lx %04x %04x %04lx %8s %2s%2s%2s%2s%2s%2s\n",
 		     addr6p[0], addr6p[1], addr6p[2], addr6p[3],
 		     addr6p[4], addr6p[5], addr6p[6], addr6p[7],
 		     &location, &prefix_len, &type, &state, &expire, &tstamp, &reachable, &gc, &refcnt,

diff --git a/lib/ipx.c b/lib/ipx.c
index 1359f5f..f90c96c 100644
--- a/lib/ipx.c
+++ b/lib/ipx.c
@@ -87,12 +87,10 @@ static int IPX_getsock(char *bufp, struct sockaddr *sap)
 {
     char *sp = bufp, *bp;
     unsigned int i;
-    unsigned char val;
     struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) sap;
 
     sipx->sipx_port = 0;
 
-    val = 0;
     bp = (char *) sipx->sipx_node;
     for (i = 0; i < sizeof(sipx->sipx_node); i++) {
 	*sp = toupper(*sp);

diff --git a/lib/netrom.c b/lib/netrom.c
index f3033c7..254bd61 100644
--- a/lib/netrom.c
+++ b/lib/netrom.c
@@ -79,6 +79,11 @@ static const char *NETROM_sprint(struct sockaddr *sap, int numeric)
     return (NETROM_print(((struct sockaddr_ax25 *) sap)->sax25_call.ax25_call));
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 static int NETROM_input(int type, char *bufp, struct sockaddr *sap)
 {
@@ -98,9 +103,8 @@ static int NETROM_input(int type, char *bufp, struct sockaddr *sap)
 	    c = toupper(c);
 	if (!(isupper(c) || isdigit(c))) {
 	    safe_strncpy(netrom_errmsg, _("Invalid callsign"), sizeof(netrom_errmsg));
-#ifdef DEBUG
-	    fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -111,9 +115,8 @@ static int NETROM_input(int type, char *bufp, struct sockaddr *sap)
     /* Callsign too long? */
     if ((i == 6) && (*bufp != '-') && (*bufp != '\0')) {
 	safe_strncpy(netrom_errmsg, _("Callsign too long"), sizeof(netrom_errmsg));
-#ifdef DEBUG
-	fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
-#endif
+	if (_DEBUG)
+	    fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
 	errno = E2BIG;
 	return (-1);
     }
@@ -131,12 +134,12 @@ static int NETROM_input(int type, char *bufp, struct sockaddr *sap)
     }
 
     /* All done. */
-#ifdef DEBUG
-    fprintf(stderr, "netrom_input(%s): ", orig);
-    for (i = 0; i < sizeof(ax25_address); i++)
-	fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
-    fprintf(stderr, "\n");
-#endif
+    if (_DEBUG) {
+	fprintf(stderr, "netrom_input(%s): ", orig);
+	for (i = 0; i < sizeof(ax25_address); i++)
+	    fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
+	fprintf(stderr, "\n");
+    }
 
     return (0);
 }

diff --git a/lib/rose.c b/lib/rose.c
index 52d025a..c02e741 100644
--- a/lib/rose.c
+++ b/lib/rose.c
@@ -73,7 +73,6 @@ static const char *
     return (ROSE_print(((struct sockaddr_rose *) sap)->srose_addr.rose_addr));
 }
 
-
 static int ROSE_input(int type, char *bufp, struct sockaddr *sap)
 {
     char *ptr;
@@ -85,9 +84,6 @@ static int ROSE_input(int type, char *bufp, struct sockaddr *sap)
     /* Node address the correct length ? */
     if (strlen(bufp) != 10) {
 	strcpy(ROSE_errmsg, _("Node address must be ten digits"));
-#ifdef DEBUG
-	fprintf(stderr, "rose_input(%s): %s !\n", ROSE_errmsg, orig);
-#endif
 	errno = EINVAL;
 	return (-1);
     }
@@ -98,13 +94,6 @@ static int ROSE_input(int type, char *bufp, struct sockaddr *sap)
     }
 
     /* All done. */
-#ifdef DEBUG
-    fprintf(stderr, "rose_input(%s): ", orig);
-    for (i = 0; i < sizeof(rose_address); i++)
-	fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
-    fprintf(stderr, "\n");
-#endif
-
     return (0);
 }
 

diff --git a/lib/tr.c b/lib/tr.c
index 961cdb1..a0413f4 100644
--- a/lib/tr.c
+++ b/lib/tr.c
@@ -50,6 +50,11 @@ static const char *pr_tr(const char *ptr)
     return (buff);
       }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 static int in_tr(char *bufp, struct sockaddr *sap)
 {
@@ -82,9 +87,8 @@ static int in_tr(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -97,9 +101,8 @@ static int in_tr(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val |= c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -108,28 +111,21 @@ static int in_tr(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == TR_ALEN) {
-#ifdef DEBUG
+	    if (_DEBUG && i == TR_ALEN)
 		fprintf(stderr, _("in_tr(%s): trailing : ignored!\n"),
-			orig)
-#endif
-		    ;		/* nothing */
-	    }
+			orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == TR_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == TR_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_tr(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_tr(%s): %s\n", orig, pr_tr(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_tr(%s): %s\n", orig, pr_tr(sap->sa_data));
 
     return (0);
 }



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-commits] proj/net-tools:gentoo commit in: lib/
@ 2011-11-21  1:38 Mike Frysinger
  2011-11-21  1:35 ` [gentoo-commits] proj/net-tools:master " Mike Frysinger
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2011-11-21  1:38 UTC (permalink / raw
  To: gentoo-commits

commit:     46cd57a736c30bafd41406781e7b1c6532e6a97d
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 21 00:27:14 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Nov 21 00:46:38 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/net-tools.git;a=commit;h=46cd57a7

fix up unused variable warnings

Some of these are unused, so drop them.  Others are only used in debug
code, so refactor those so things are always compiled.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 lib/arcnet.c   |   32 ++++++++++++++------------------
 lib/ax25.c     |   27 +++++++++++++++------------
 lib/ether.c    |   32 ++++++++++++++------------------
 lib/eui64.c    |   37 +++++++++++++++++--------------------
 lib/fddi.c     |   32 ++++++++++++++------------------
 lib/hippi.c    |   32 ++++++++++++++------------------
 lib/ib.c       |   10 +++++++---
 lib/inet6_gr.c |    8 +++-----
 lib/ipx.c      |    2 --
 lib/netrom.c   |   27 +++++++++++++++------------
 lib/rose.c     |   11 -----------
 lib/tr.c       |   32 ++++++++++++++------------------
 12 files changed, 127 insertions(+), 155 deletions(-)

diff --git a/lib/arcnet.c b/lib/arcnet.c
index 35a2b9a..10b59e5 100644
--- a/lib/arcnet.c
+++ b/lib/arcnet.c
@@ -43,6 +43,11 @@ static const char *pr_arcnet(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an ARCnet address and convert to binary. */
 static int in_arcnet(char *bufp, struct sockaddr *sap)
@@ -66,9 +71,8 @@ static int in_arcnet(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_arcnet(%s): invalid arcnet address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_arcnet(%s): invalid arcnet address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -81,9 +85,8 @@ static int in_arcnet(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val |= c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_arcnet(%s): invalid arcnet address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_arcnet(%s): invalid arcnet address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -92,28 +95,21 @@ static int in_arcnet(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == ETH_ALEN) {
-#ifdef DEBUG
+	    if (_DEBUG && i == ETH_ALEN)
 		fprintf(stderr, _("in_arcnet(%s): trailing : ignored!\n"),
-			orig)
-#endif
-		    ;		/* nothing */
-	    }
+			orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == ETH_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == ETH_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_arcnet(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_arcnet(%s): %s\n", orig, pr_arcnet(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_arcnet(%s): %s\n", orig, pr_arcnet(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/ax25.c b/lib/ax25.c
index 209e479..afc035b 100644
--- a/lib/ax25.c
+++ b/lib/ax25.c
@@ -76,6 +76,11 @@ static const char *
     return (AX25_print(((struct sockaddr_ax25 *) sap)->sax25_call.ax25_call));
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 static int AX25_input(int type, char *bufp, struct sockaddr *sap)
 {
@@ -95,9 +100,8 @@ static int AX25_input(int type, char *bufp, struct sockaddr *sap)
 	    c = toupper(c);
 	if (!(isupper(c) || isdigit(c))) {
 	    safe_strncpy(AX25_errmsg, _("Invalid callsign"), sizeof(AX25_errmsg));
-#ifdef DEBUG
-	    fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -108,9 +112,8 @@ static int AX25_input(int type, char *bufp, struct sockaddr *sap)
     /* Callsign too long? */
     if ((i == 6) && (*bufp != '-') && (*bufp != '\0')) {
 	strcpy(AX25_errmsg, _("Callsign too long"));
-#ifdef DEBUG
-	fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
-#endif
+	if (_DEBUG)
+	    fprintf(stderr, "ax25_input(%s): %s !\n", AX25_errmsg, orig);
 	errno = E2BIG;
 	return (-1);
     }
@@ -128,12 +131,12 @@ static int AX25_input(int type, char *bufp, struct sockaddr *sap)
     }
 
     /* All done. */
-#ifdef DEBUG
-    fprintf(stderr, "ax25_input(%s): ", orig);
-    for (i = 0; i < sizeof(ax25_address); i++)
-	fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
-    fprintf(stderr, "\n");
-#endif
+    if (_DEBUG) {
+	fprintf(stderr, "ax25_input(%s): ", orig);
+	for (i = 0; i < sizeof(ax25_address); i++)
+	    fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
+	fprintf(stderr, "\n");
+    }
 
     return (0);
 }

diff --git a/lib/ether.c b/lib/ether.c
index ddd1598..9bf8a55 100644
--- a/lib/ether.c
+++ b/lib/ether.c
@@ -46,6 +46,11 @@ static const char *pr_ether(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an Ethernet address and convert to binary. */
 static int in_ether(char *bufp, struct sockaddr *sap)
@@ -70,9 +75,8 @@ static int in_ether(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -87,9 +91,8 @@ static int in_ether(char *bufp, struct sockaddr *sap)
 	else if (c == ':' || c == 0)
 	    val >>= 4;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_ether(%s): invalid ether address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -100,28 +103,21 @@ static int in_ether(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == ETH_ALEN) {
-#ifdef DEBUG
+	    if (_DEBUG && i == ETH_ALEN)
 		fprintf(stderr, _("in_ether(%s): trailing : ignored!\n"),
-			orig)
-#endif
-		    ;		/* nothing */
-	    }
+			orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == ETH_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == ETH_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_ether(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_ether(%s): %s\n", orig, pr_ether(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_ether(%s): %s\n", orig, pr_ether(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/eui64.c b/lib/eui64.c
index 6ab7d26..32822a3 100644
--- a/lib/eui64.c
+++ b/lib/eui64.c
@@ -60,6 +60,12 @@ static const char *pr_eui64(const char *ptr)
 	return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
+
 /* Start the PPP encapsulation on the file descriptor. */
 static int in_eui64( char *bufp, struct sockaddr *sap )
 {
@@ -84,10 +90,9 @@ static int in_eui64( char *bufp, struct sockaddr *sap )
 		else if (c >= 'A' && c <= 'F')
 			val = c - 'A' + 10;
 		else {
-#ifdef DEBUG
-			fprintf( stderr, _("in_eui64(%s): invalid eui64 address!\n"), 
-				 orig );
-#endif
+			if (_DEBUG)
+				fprintf( stderr, _("in_eui64(%s): invalid eui64 address!\n"),
+					 orig );
 			errno = EINVAL;
 			return (-1);
 		}
@@ -103,10 +108,9 @@ static int in_eui64( char *bufp, struct sockaddr *sap )
 		else if (c == ':' || c == 0)
 			val >>= 4;
 		else {
-#ifdef DEBUG
-			fprintf( stderr, _("in_eui64(%s): invalid eui64 address!\n"), 
-				 orig );
-#endif
+			if (_DEBUG)
+				fprintf( stderr, _("in_eui64(%s): invalid eui64 address!\n"),
+					 orig );
 			errno = EINVAL;
 			return (-1);
 		}
@@ -119,28 +123,21 @@ static int in_eui64( char *bufp, struct sockaddr *sap )
 		
 		/* We might get a semicolon here - not required. */
 		if (*bufp == ':') {
-			if (i == EUI64_ALEN) {
-#ifdef DEBUG
+			if (_DEBUG && i == EUI64_ALEN)
 				fprintf(stderr, _("in_eui64(%s): trailing : ignored!\n"),
-					orig)
-#endif
-					; /* nothing */
-			}
+					orig);
 			bufp++;
 		}
 	}
 
 	/* That's it.  Any trailing junk? */
-	if ((i == EUI64_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+	if (_DEBUG && (i == EUI64_ALEN) && (*bufp != '\0')) {
 		fprintf(stderr, _("in_eui64(%s): trailing junk!\n"), orig);
 		errno = EINVAL;
 		return (-1);
-#endif
 	}
-#ifdef DEBUG
-	fprintf(stderr, "in_eui64(%s): %s\n", orig, pr_eui64(sap->sa_data));
-#endif
+	if (_DEBUG)
+		fprintf(stderr, "in_eui64(%s): %s\n", orig, pr_eui64(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/fddi.c b/lib/fddi.c
index 75adddd..750cc2d 100644
--- a/lib/fddi.c
+++ b/lib/fddi.c
@@ -57,6 +57,11 @@ static const char *pr_fddi(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an FDDI address and convert to binary. */
 static int in_fddi(char *bufp, struct sockaddr *sap)
@@ -80,9 +85,8 @@ static int in_fddi(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -95,9 +99,8 @@ static int in_fddi(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val |= c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_fddi(%s): invalid fddi address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -106,28 +109,21 @@ static int in_fddi(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == FDDI_K_ALEN) {
-#ifdef DEBUG
+	    if (_DEBUG && i == FDDI_K_ALEN)
 		fprintf(stderr, _("in_fddi(%s): trailing : ignored!\n"),
-			orig)
-#endif
-		    ;		/* nothing */
-	    }
+			orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == FDDI_K_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == FDDI_K_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_fddi(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_fddi(%s): %s\n", orig, pr_fddi(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_fddi(%s): %s\n", orig, pr_fddi(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/hippi.c b/lib/hippi.c
index bd73ea1..ae6e31b 100644
--- a/lib/hippi.c
+++ b/lib/hippi.c
@@ -57,6 +57,11 @@ static const char *pr_hippi(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an HIPPI address and convert to binary. */
 static int in_hippi(char *bufp, struct sockaddr *sap)
@@ -80,9 +85,8 @@ static int in_hippi(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -95,9 +99,8 @@ static int in_hippi(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val |= c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_hippi(%s): invalid hippi address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -106,27 +109,20 @@ static int in_hippi(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == HIPPI_ALEN) {
-#ifdef DEBUG
-		fprintf(stderr, _("in_hippi(%s): trailing : ignored!\n"), orig)
-#endif
-		    ;		/* nothing */
-	    }
+	    if (_DEBUG && i == HIPPI_ALEN)
+		fprintf(stderr, _("in_hippi(%s): trailing : ignored!\n"), orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == HIPPI_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == HIPPI_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_hippi(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_hippi(%s): %s\n", orig, pr_hippi(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_hippi(%s): %s\n", orig, pr_hippi(sap->sa_data));
 
     return (0);
 }

diff --git a/lib/ib.c b/lib/ib.c
index e05bd3e..98f3446 100644
--- a/lib/ib.c
+++ b/lib/ib.c
@@ -56,6 +56,11 @@ static const char *pr_ib(const char *ptr)
     return (buff);
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 /* Input an Infiniband address and convert to binary. */
 static int in_ib(char *bufp, struct sockaddr *sap)
@@ -80,9 +85,8 @@ static int in_ib(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_ib(%s): invalid infiniband address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}

diff --git a/lib/inet6_gr.c b/lib/inet6_gr.c
index 7f1bc20..2b055f6 100644
--- a/lib/inet6_gr.c
+++ b/lib/inet6_gr.c
@@ -92,10 +92,8 @@ int rprint_fib6(int ext, int numeric)
 		     naddr6p[0], naddr6p[1], naddr6p[2], naddr6p[3],
 		     naddr6p[4], naddr6p[5], naddr6p[6], naddr6p[7],
 		     &metric, &refcnt, &use, &iflags, iface);
-#if 0
-	if (num < 23)
+	if (0 && num < 23)
 	    continue;
-#endif
 	if (iflags & RTF_CACHE) {
 		if (!(numeric & RTF_CACHE))
 			continue;
@@ -163,7 +161,7 @@ int rprint_cache6(int ext, int numeric)
     char buff[4096], iface[16], flags[16];
     char addr6[128], haddr[20], statestr[20];
     struct sockaddr_in6 saddr6;
-    int type, num, refcnt, prefix_len, location, state, gc;
+    int type, refcnt, prefix_len, location, state, gc;
     long tstamp, expire, ndflags, reachable, stale, delete;
     FILE *fp = fopen(_PATH_PROCNET_NDISC, "r");
     char addr6p[8][5], haddrp[6][3];
@@ -184,7 +182,7 @@ int rprint_cache6(int ext, int numeric)
 
 
     while (fgets(buff, 1023, fp)) {
-	num = sscanf(buff, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %08lx %08lx %08lx %04x %04x %04lx %8s %2s%2s%2s%2s%2s%2s\n",
+	sscanf(buff, "%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %08lx %08lx %08lx %04x %04x %04lx %8s %2s%2s%2s%2s%2s%2s\n",
 		     addr6p[0], addr6p[1], addr6p[2], addr6p[3],
 		     addr6p[4], addr6p[5], addr6p[6], addr6p[7],
 		     &location, &prefix_len, &type, &state, &expire, &tstamp, &reachable, &gc, &refcnt,

diff --git a/lib/ipx.c b/lib/ipx.c
index 1359f5f..f90c96c 100644
--- a/lib/ipx.c
+++ b/lib/ipx.c
@@ -87,12 +87,10 @@ static int IPX_getsock(char *bufp, struct sockaddr *sap)
 {
     char *sp = bufp, *bp;
     unsigned int i;
-    unsigned char val;
     struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) sap;
 
     sipx->sipx_port = 0;
 
-    val = 0;
     bp = (char *) sipx->sipx_node;
     for (i = 0; i < sizeof(sipx->sipx_node); i++) {
 	*sp = toupper(*sp);

diff --git a/lib/netrom.c b/lib/netrom.c
index f3033c7..254bd61 100644
--- a/lib/netrom.c
+++ b/lib/netrom.c
@@ -79,6 +79,11 @@ static const char *NETROM_sprint(struct sockaddr *sap, int numeric)
     return (NETROM_print(((struct sockaddr_ax25 *) sap)->sax25_call.ax25_call));
 }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 static int NETROM_input(int type, char *bufp, struct sockaddr *sap)
 {
@@ -98,9 +103,8 @@ static int NETROM_input(int type, char *bufp, struct sockaddr *sap)
 	    c = toupper(c);
 	if (!(isupper(c) || isdigit(c))) {
 	    safe_strncpy(netrom_errmsg, _("Invalid callsign"), sizeof(netrom_errmsg));
-#ifdef DEBUG
-	    fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -111,9 +115,8 @@ static int NETROM_input(int type, char *bufp, struct sockaddr *sap)
     /* Callsign too long? */
     if ((i == 6) && (*bufp != '-') && (*bufp != '\0')) {
 	safe_strncpy(netrom_errmsg, _("Callsign too long"), sizeof(netrom_errmsg));
-#ifdef DEBUG
-	fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
-#endif
+	if (_DEBUG)
+	    fprintf(stderr, "netrom_input(%s): %s !\n", netrom_errmsg, orig);
 	errno = E2BIG;
 	return (-1);
     }
@@ -131,12 +134,12 @@ static int NETROM_input(int type, char *bufp, struct sockaddr *sap)
     }
 
     /* All done. */
-#ifdef DEBUG
-    fprintf(stderr, "netrom_input(%s): ", orig);
-    for (i = 0; i < sizeof(ax25_address); i++)
-	fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
-    fprintf(stderr, "\n");
-#endif
+    if (_DEBUG) {
+	fprintf(stderr, "netrom_input(%s): ", orig);
+	for (i = 0; i < sizeof(ax25_address); i++)
+	    fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
+	fprintf(stderr, "\n");
+    }
 
     return (0);
 }

diff --git a/lib/rose.c b/lib/rose.c
index 52d025a..c02e741 100644
--- a/lib/rose.c
+++ b/lib/rose.c
@@ -73,7 +73,6 @@ static const char *
     return (ROSE_print(((struct sockaddr_rose *) sap)->srose_addr.rose_addr));
 }
 
-
 static int ROSE_input(int type, char *bufp, struct sockaddr *sap)
 {
     char *ptr;
@@ -85,9 +84,6 @@ static int ROSE_input(int type, char *bufp, struct sockaddr *sap)
     /* Node address the correct length ? */
     if (strlen(bufp) != 10) {
 	strcpy(ROSE_errmsg, _("Node address must be ten digits"));
-#ifdef DEBUG
-	fprintf(stderr, "rose_input(%s): %s !\n", ROSE_errmsg, orig);
-#endif
 	errno = EINVAL;
 	return (-1);
     }
@@ -98,13 +94,6 @@ static int ROSE_input(int type, char *bufp, struct sockaddr *sap)
     }
 
     /* All done. */
-#ifdef DEBUG
-    fprintf(stderr, "rose_input(%s): ", orig);
-    for (i = 0; i < sizeof(rose_address); i++)
-	fprintf(stderr, "%02X ", sap->sa_data[i] & 0377);
-    fprintf(stderr, "\n");
-#endif
-
     return (0);
 }
 

diff --git a/lib/tr.c b/lib/tr.c
index 961cdb1..a0413f4 100644
--- a/lib/tr.c
+++ b/lib/tr.c
@@ -50,6 +50,11 @@ static const char *pr_tr(const char *ptr)
     return (buff);
       }
 
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
 
 static int in_tr(char *bufp, struct sockaddr *sap)
 {
@@ -82,9 +87,8 @@ static int in_tr(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val = c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -97,9 +101,8 @@ static int in_tr(char *bufp, struct sockaddr *sap)
 	else if (c >= 'A' && c <= 'F')
 	    val |= c - 'A' + 10;
 	else {
-#ifdef DEBUG
-	    fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
-#endif
+	    if (_DEBUG)
+		fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
 	    errno = EINVAL;
 	    return (-1);
 	}
@@ -108,28 +111,21 @@ static int in_tr(char *bufp, struct sockaddr *sap)
 
 	/* We might get a semicolon here - not required. */
 	if (*bufp == ':') {
-	    if (i == TR_ALEN) {
-#ifdef DEBUG
+	    if (_DEBUG && i == TR_ALEN)
 		fprintf(stderr, _("in_tr(%s): trailing : ignored!\n"),
-			orig)
-#endif
-		    ;		/* nothing */
-	    }
+			orig);
 	    bufp++;
 	}
     }
 
     /* That's it.  Any trailing junk? */
-    if ((i == TR_ALEN) && (*bufp != '\0')) {
-#ifdef DEBUG
+    if (_DEBUG && (i == TR_ALEN) && (*bufp != '\0')) {
 	fprintf(stderr, _("in_tr(%s): trailing junk!\n"), orig);
 	errno = EINVAL;
 	return (-1);
-#endif
     }
-#ifdef DEBUG
-    fprintf(stderr, "in_tr(%s): %s\n", orig, pr_tr(sap->sa_data));
-#endif
+    if (_DEBUG)
+	fprintf(stderr, "in_tr(%s): %s\n", orig, pr_tr(sap->sa_data));
 
     return (0);
 }



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-11-21  1:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-21  1:38 [gentoo-commits] proj/net-tools:gentoo commit in: lib/ Mike Frysinger
2011-11-21  1:35 ` [gentoo-commits] proj/net-tools:master " Mike Frysinger
  -- strict thread matches above, loose matches on Subject: below --
2011-11-21  1:38 [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
2011-11-21  1:35 ` [gentoo-commits] proj/net-tools:master " Mike Frysinger
2011-11-21  1:38 [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
2011-11-21  1:35 ` [gentoo-commits] proj/net-tools:master " Mike Frysinger
2011-11-21  1:35 Mike Frysinger
2011-11-21  1:35 Mike Frysinger
2011-04-09 13:58 [gentoo-commits] proj/net-tools:gentoo " Mike Frysinger
2011-04-09 13:58 ` [gentoo-commits] proj/net-tools:master " Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox