mirror of
https://github.com/traviscross/mtr.git
synced 2024-09-22 02:47:11 +00:00
posix: replace bzero() and index() with modern equivelants
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
This commit is contained in:
parent
73e17d9a02
commit
c7f30fdded
2
curses.c
2
curses.c
@ -288,7 +288,7 @@ int mtr_curses_keyaction(void)
|
|||||||
return ActionNone;
|
return ActionNone;
|
||||||
}
|
}
|
||||||
if (tolower(c) == 'j') {
|
if (tolower(c) == 'j') {
|
||||||
if( index(fld_active, 'N') ) {
|
if( strchr(fld_active, 'N') ) {
|
||||||
strcpy(fld_active, "DR AGJMXI"); /* GeoMean and jitter */
|
strcpy(fld_active, "DR AGJMXI"); /* GeoMean and jitter */
|
||||||
} else {
|
} else {
|
||||||
strcpy(fld_active, "LS NABWV"); /* default */
|
strcpy(fld_active, "LS NABWV"); /* default */
|
||||||
|
4
mtr.c
4
mtr.c
@ -723,7 +723,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
#ifdef ENABLE_IPV6
|
||||||
/* gethostbyname2() is deprecated so we'll use getaddrinfo() instead. */
|
/* gethostbyname2() is deprecated so we'll use getaddrinfo() instead. */
|
||||||
bzero( &hints, sizeof hints );
|
memset( &hints, 0, sizeof hints );
|
||||||
hints.ai_family = af;
|
hints.ai_family = af;
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
hints.ai_socktype = SOCK_DGRAM;
|
||||||
error = getaddrinfo( Hostname, NULL, &hints, &res );
|
error = getaddrinfo( Hostname, NULL, &hints, &res );
|
||||||
@ -741,7 +741,7 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
/* Convert the first addrinfo into a hostent. */
|
/* Convert the first addrinfo into a hostent. */
|
||||||
host = &trhost;
|
host = &trhost;
|
||||||
bzero( host, sizeof trhost );
|
memset( host, 0, sizeof trhost );
|
||||||
host->h_name = res->ai_canonname;
|
host->h_name = res->ai_canonname;
|
||||||
host->h_aliases = NULL;
|
host->h_aliases = NULL;
|
||||||
host->h_addrtype = res->ai_family;
|
host->h_addrtype = res->ai_family;
|
||||||
|
10
report.c
10
report.c
@ -162,7 +162,7 @@ void report_close(void)
|
|||||||
if (j < 0) continue;
|
if (j < 0) continue;
|
||||||
|
|
||||||
/* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
|
/* 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,
|
snprintf( buf + len, sizeof(buf), data_fields[j].format,
|
||||||
data_fields[j].net_xxx(at) /1000.0 );
|
data_fields[j].net_xxx(at) /1000.0 );
|
||||||
} else {
|
} else {
|
||||||
@ -318,7 +318,7 @@ void json_close(void)
|
|||||||
/* Format value */
|
/* Format value */
|
||||||
const char *format;
|
const char *format;
|
||||||
format = data_fields[j].format;
|
format = data_fields[j].format;
|
||||||
if( index(format, 'f') ) {
|
if( strchr(format, 'f') ) {
|
||||||
format = "%.2f";
|
format = "%.2f";
|
||||||
} else {
|
} else {
|
||||||
format = "%d";
|
format = "%d";
|
||||||
@ -329,7 +329,7 @@ void json_close(void)
|
|||||||
strcat(name, format);
|
strcat(name, format);
|
||||||
|
|
||||||
/* Output json line */
|
/* 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. */
|
/* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
|
||||||
printf(name,
|
printf(name,
|
||||||
data_fields[j].title,
|
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. */
|
/* 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,
|
printf( name,
|
||||||
title,
|
title,
|
||||||
data_fields[j].net_xxx(at) /1000.0,
|
data_fields[j].net_xxx(at) /1000.0,
|
||||||
@ -471,7 +471,7 @@ void csv_close(time_t now)
|
|||||||
if (j < 0) continue;
|
if (j < 0) continue;
|
||||||
|
|
||||||
/* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */
|
/* 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);
|
printf( ",%.2f", data_fields[j].net_xxx(at) / 1000.0);
|
||||||
} else {
|
} else {
|
||||||
printf( ",%d", data_fields[j].net_xxx(at) );
|
printf( ",%d", data_fields[j].net_xxx(at) );
|
||||||
|
Loading…
Reference in New Issue
Block a user