]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
posix: replace bzero() and index() with modern equivelants 134/head
authorSami Kerola <kerolasa@iki.fi>
Sun, 14 Aug 2016 19:52:47 +0000 (20:52 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sun, 14 Aug 2016 19:56:45 +0000 (20:56 +0100)
Replace bzero() with memset() and index() with strchr().  The earlier
functions are marked as legacy in posix.

Reference: http://pubs.opengroup.org/onlinepubs/009695399/functions/index.html
Reference: http://pubs.opengroup.org/onlinepubs/009695399/functions/bzero.html

curses.c
mtr.c
report.c

index b4201d866bb2c6d683828204da5d4c3530b7b6fb..e7555fa1c033e7bd11162aed7f4f94e8998bc636 100644 (file)
--- a/curses.c
+++ b/curses.c
@@ -288,7 +288,7 @@ int mtr_curses_keyaction(void)
     return ActionNone;
   }
   if (tolower(c) == 'j') {
-    if( index(fld_active, 'N') ) {
+    if( strchr(fld_active, 'N') ) {
       strcpy(fld_active, "DR AGJMXI");        /* GeoMean and jitter */
     } else {
       strcpy(fld_active, "LS NABWV");         /* default */
diff --git a/mtr.c b/mtr.c
index f4bbf1083cc84c172ad61d302c471b86a0a0bbde..40852369f29bd8fbf95b2a392e22d3274ad7ee13 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -723,7 +723,7 @@ int main(int argc, char **argv)
 
 #ifdef ENABLE_IPV6
     /* gethostbyname2() is deprecated so we'll use getaddrinfo() instead. */
-    bzero( &hints, sizeof hints );
+    memset( &hints, 0, sizeof hints );
     hints.ai_family = af;
     hints.ai_socktype = SOCK_DGRAM;
     error = getaddrinfo( Hostname, NULL, &hints, &res );
@@ -741,7 +741,7 @@ int main(int argc, char **argv)
     }
     /* Convert the first addrinfo into a hostent. */
     host = &trhost;
-    bzero( host, sizeof trhost );
+    memset( host, 0, sizeof trhost );
     host->h_name = res->ai_canonname;
     host->h_aliases = NULL;
     host->h_addrtype = res->ai_family;
index b47a85504a8fd4718072535e2555ccc3806aeefa..f33626c85a4ff1fe783dec10d046d6b1b063a3b5 100644 (file)
--- a/report.c
+++ b/report.c
@@ -162,7 +162,7 @@ void report_close(void)
       if (j < 0) continue;
 
       /* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
-      if( index( data_fields[j].format, 'f' ) ) {
+      if( strchr( data_fields[j].format, 'f' ) ) {
         snprintf( buf + len, sizeof(buf), data_fields[j].format,
                data_fields[j].net_xxx(at) /1000.0 );
       } else {
@@ -318,7 +318,7 @@ void json_close(void)
       /* Format value */
       const char *format;
       format = data_fields[j].format;
-      if( index(format, 'f') ) {
+      if( strchr(format, 'f') ) {
         format = "%.2f";
       } else {
         format = "%d";
@@ -329,7 +329,7 @@ void json_close(void)
       strcat(name, format);
 
       /* Output json line */
-      if(index(data_fields[j].format, 'f')) {
+      if(strchr(data_fields[j].format, 'f')) {
         /* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
         printf(name,
                data_fields[j].title,
@@ -401,7 +401,7 @@ void xml_close(void)
       }
 
       /* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
-      if( index( data_fields[j].format, 'f' ) ) {
+      if( strchr( data_fields[j].format, 'f' ) ) {
        printf( name,
                title,
                data_fields[j].net_xxx(at) /1000.0,
@@ -471,7 +471,7 @@ void csv_close(time_t now)
       if (j < 0) continue; 
 
       /* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
-      if( index( data_fields[j].format, 'f' ) ) {
+      if( strchr( data_fields[j].format, 'f' ) ) {
        printf( ",%.2f", data_fields[j].net_xxx(at) / 1000.0);
       } else {
        printf( ",%d",   data_fields[j].net_xxx(at) );