]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
warnings: stop variable shadowing
authorSami Kerola <kerolasa@iki.fi>
Sun, 14 Aug 2016 19:11:36 +0000 (20:11 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 14 Aug 2016 19:56:44 +0000 (20:56 +0100)
Rename local variables not to conflict at following locations:

asn.c:160:26: warning: declaration of 'txtrec' shadows a global declaration [-Wshadow]
dns.c:351:50: warning: declaration of 'af' shadows a global declaration [-Wshadow]
dns.c:89:40: warning: declaration of 'af' shadows a global declaration [-Wshadow]
gtk.c:213:31: warning: declaration of 'Entry' shadows a global declaration [-Wshadow]
net.c:1408:31: warning: declaration of 'host' shadows a global declaration [-Wshadow]
net.c:1726:38: warning: declaration of 'af' shadows a global declaration [-Wshadow]
net.c:1744:39: warning: declaration of 'af' shadows a global declaration [-Wshadow]
net.c:876:7: warning: declaration of 'sequence' shadows a global declaration [-Wshadow]

asn.c
dns.c
gtk.c
net.c

diff --git a/asn.c b/asn.c
index 62880dc23b8fa6bedcd2a84ebb0d87c21ad387e1..bdc46c2ea4c8a87acff6e90baad85fb86a501bad 100644 (file)
--- a/asn.c
+++ b/asn.c
@@ -157,23 +157,23 @@ char* trimsep(char *s) {
 }
 
 // originX.asn.cymru.com txtrec:    ASN | Route | Country | Registry | Allocated
-char* split_txtrec(char *txtrec) {
-    if (!txtrec)
+char* split_txtrec(char *txt_rec) {
+    if (!txt_rec)
        return NULL;
     if (iihash) {
 #ifdef IIDEBUG
-        syslog(LOG_INFO, "Malloc-tbl: %s", txtrec);
+        syslog(LOG_INFO, "Malloc-tbl: %s", txt_rec);
 #endif
         if (!(items = malloc(sizeof(*items)))) {
 #ifdef IIDEBUG
-            syslog(LOG_INFO, "Free-txt(%p)", txtrec);
+            syslog(LOG_INFO, "Free-txt(%p)", txt_rec);
 #endif
-            free(txtrec);
+            free(txt_rec);
             return NULL;
         }
     }
 
-    char* prev = txtrec;
+    char* prev = txt_rec;
     char* next;
     int i = 0, j;
 
diff --git a/dns.c b/dns.c
index ec3c6eaed337b373b6d99f893a8f73815b10ea1b..16eedd2ccfe56f9edd45b413d8f6f6d84aaf7209 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -86,10 +86,10 @@ char *strlongip(ip_t * ip)
 }
 
 
-int longipstr( char *s, ip_t *dst, int af )
+int longipstr( char *s, ip_t *dst, int family )
 {
 #ifdef ENABLE_IPV6
-  return inet_pton( af, s, dst );
+  return inet_pton( family, s, dst );
 #else
   return inet_aton( s, dst );
 #endif
@@ -348,9 +348,9 @@ char *strlongip(ip_t * ip)
 // XXX check if necessary/exported. 
 
 /* Resolve an IP address to a hostname. */ 
-struct hostent *addr2host( const char *addr, int af ) {
+struct hostent *addr2host( const char *addr, int family ) {
   int len = 0;
-  switch ( af ) {
+  switch ( family ) {
   case AF_INET:
     len = sizeof( struct in_addr );
     break;
@@ -360,7 +360,7 @@ struct hostent *addr2host( const char *addr, int af ) {
     break;
 #endif
   }
-  return gethostbyaddr( addr, len, af );
+  return gethostbyaddr( addr, len, family );
 }
 
 
diff --git a/gtk.c b/gtk.c
index 39f4c6eb846a45ee260570bf43e1968b9c246c1c..5c6a2ccf836ed0a6d77b20522a8687db9a23906e 100644 (file)
--- a/gtk.c
+++ b/gtk.c
@@ -210,20 +210,20 @@ gint WaitTime_changed(UNUSED GtkAdjustment *Adj, UNUSED GtkWidget *Button)
 }
 
 
-gint Host_activate(GtkWidget *Entry, UNUSED gpointer data) 
+gint Host_activate(GtkWidget *entry, UNUSED gpointer data) 
 {
   struct hostent * addr;
 
-  addr = dns_forward(gtk_entry_get_text(GTK_ENTRY(Entry)));
+  addr = dns_forward(gtk_entry_get_text(GTK_ENTRY(entry)));
   if(addr) {
     net_reopen(addr);
     /* If we are "Paused" at this point it is usually because someone
        entered a non-existing host. Therefore do the go-ahead... */
     gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( Pause_Button ) , 0);
   } else {
-    int pos = strlen(gtk_entry_get_text( GTK_ENTRY(Entry)));
+    int pos = strlen(gtk_entry_get_text( GTK_ENTRY(entry)));
     gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( Pause_Button ) , 1);
-    gtk_editable_insert_text( GTK_EDITABLE(Entry), ": not found", -1, &pos);
+    gtk_editable_insert_text( GTK_EDITABLE(entry), ": not found", -1, &pos);
   }
 
   return FALSE;
diff --git a/net.c b/net.c
index 21320eaa4e89779b2e395121a2905c760247d003..fa5b3ef8e1014357aebfcf3bb4a5f1fa6482b0bc 100644 (file)
--- a/net.c
+++ b/net.c
@@ -873,7 +873,7 @@ void net_process_return(void)
   struct timeval now;
   ip_t * fromaddress = NULL;
   int echoreplytype = 0, timeexceededtype = 0, unreachabletype = 0;
-  int sequence = 0;
+  int seq_num = 0;
 
   /* MPLS decoding */
   struct mplslen mpls;
@@ -924,7 +924,7 @@ void net_process_return(void)
       if(header->id != (uint16)getpid())
         return;
 
-      sequence = header->sequence;
+      seq_num = header->sequence;
     } else if (header->type == timeexceededtype) {
       switch ( af ) {
       case AF_INET:
@@ -961,7 +961,7 @@ void net_process_return(void)
       if (header->id != (uint16)getpid())
         return;
   
-      sequence = header->sequence;
+      seq_num = header->sequence;
     }
     break;
   
@@ -1002,9 +1002,9 @@ void net_process_return(void)
         return;
 
       if (remoteport && remoteport == ntohs(udpheader->dstport)) {
-        sequence = ntohs(udpheader->checksum);
+        seq_num = ntohs(udpheader->checksum);
       } else if (!remoteport) {
-        sequence = ntohs(udpheader->dstport);
+        seq_num = ntohs(udpheader->dstport);
       }
     }
     break;
@@ -1042,7 +1042,7 @@ void net_process_return(void)
         break;
 #endif
       }
-      sequence = ntohs(tcpheader->srcport);
+      seq_num = ntohs(tcpheader->srcport);
     }
     break;
     
@@ -1079,12 +1079,12 @@ void net_process_return(void)
         break;
 #endif
       }
-      sequence = ntohs(sctpheader->srcport);
+      seq_num = ntohs(sctpheader->srcport);
     }
     break;
   }
-  if (sequence)
-    net_process_ping (sequence, mpls, (void *) fromaddress, now);
+  if (seq_num)
+    net_process_ping (seq_num, mpls, (void *) fromaddress, now);
 }
 
 
@@ -1405,7 +1405,7 @@ int net_selectsocket(void)
 }
 
 
-int net_open(struct hostent * host) 
+int net_open(struct hostent * hostent
 {
 #ifdef ENABLE_IPV6
   struct sockaddr_storage name_struct;
@@ -1417,13 +1417,13 @@ int net_open(struct hostent * host)
 
   net_reset();
 
-  remotesockaddr->sa_family = host->h_addrtype;
+  remotesockaddr->sa_family = hostent->h_addrtype;
 
-  switch ( host->h_addrtype ) {
+  switch ( hostent->h_addrtype ) {
   case AF_INET:
     sendsock = sendsock4;
     recvsock = recvsock4;
-    addrcpy( (void *) &(rsa4->sin_addr), host->h_addr, AF_INET );
+    addrcpy( (void *) &(rsa4->sin_addr), hostent->h_addr, AF_INET );
     sourceaddress = (ip_t *) &(ssa4->sin_addr);
     remoteaddress = (ip_t *) &(rsa4->sin_addr);
     break;
@@ -1435,7 +1435,7 @@ int net_open(struct hostent * host)
     }
     sendsock = sendsock6;
     recvsock = recvsock6;
-    addrcpy( (void *) &(rsa6->sin6_addr), host->h_addr, AF_INET6 );
+    addrcpy( (void *) &(rsa6->sin6_addr), hostent->h_addr, AF_INET6 );
     sourceaddress = (ip_t *) &(ssa6->sin6_addr);
     remoteaddress = (ip_t *) &(rsa6->sin6_addr);
     break;
@@ -1723,10 +1723,10 @@ void sockaddrtop( struct sockaddr * saddr, char * strptr, size_t len ) {
 }
 
 /* Address comparison. */
-int addrcmp( char * a, char * b, int af ) {
+int addrcmp( char * a, char * b, int family ) {
   int rc = -1;
 
-  switch ( af ) {
+  switch ( family ) {
   case AF_INET:
     rc = memcmp( a, b, sizeof (struct in_addr) );
     break;
@@ -1741,9 +1741,9 @@ int addrcmp( char * a, char * b, int af ) {
 }
 
 /* Address copy. */
-void addrcpy( char * a, char * b, int af ) {
+void addrcpy( char * a, char * b, int family ) {
 
-  switch ( af ) {
+  switch ( family ) {
   case AF_INET:
     memcpy( a, b, sizeof (struct in_addr) );
     break;