From b9140f06e39542ce964c5ebdceb847b4bf624130 Mon Sep 17 00:00:00 2001 From: araujo Date: Wed, 20 Apr 2016 01:26:03 +0000 Subject: [PATCH] Use NULL instead of 0 for pointers. gethostbyname(3) will return NULL for error status. MFC after: 2 weeks. --- usr.bin/systat/cmds.c | 6 +++--- usr.bin/systat/netcmds.c | 12 ++++++------ usr.bin/systat/netstat.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/usr.bin/systat/cmds.c b/usr.bin/systat/cmds.c index 46b39310be35..f461f94b9a19 100644 --- a/usr.bin/systat/cmds.c +++ b/usr.bin/systat/cmds.c @@ -120,10 +120,10 @@ command(const char *cmd) (*curcmd->c_close)(wnd); curcmd->c_flags &= ~CF_INIT; wnd = (*p->c_open)(); - if (wnd == 0) { + if (wnd == NULL) { error("Couldn't open new display"); wnd = (*curcmd->c_open)(); - if (wnd == 0) { + if (wnd == NULL) { error("Couldn't change back to previous cmd"); exit(1); } @@ -141,7 +141,7 @@ command(const char *cmd) status(); goto done; } - if (curcmd->c_cmd == 0 || !(*curcmd->c_cmd)(tmpstr1, cp)) + if (curcmd->c_cmd == NULL || !(*curcmd->c_cmd)(tmpstr1, cp)) error("%s: Unknown command.", tmpstr1); done: free(tmpstr); diff --git a/usr.bin/systat/netcmds.c b/usr.bin/systat/netcmds.c index f9da13e1667d..a91af38317af 100644 --- a/usr.bin/systat/netcmds.c +++ b/usr.bin/systat/netcmds.c @@ -150,7 +150,7 @@ changeitems(const char *args, int onoff) continue; } hp = gethostbyname(tmpstr1); - if (hp == 0) { + if (hp == NULL) { in.s_addr = inet_addr(tmpstr1); if (in.s_addr == INADDR_NONE) { error("%s: unknown host or port", tmpstr1); @@ -167,7 +167,7 @@ static int selectproto(const char *proto) { - if (proto == 0 || streq(proto, "all")) + if (proto == NULL || streq(proto, "all")) protos = TCP | UDP; else if (streq(proto, "tcp")) protos = TCP; @@ -202,13 +202,13 @@ selectport(long port, int onoff) struct pitem *p; if (port == -1) { - if (ports == 0) + if (ports == NULL) return (0); free((char *)ports), ports = 0; nports = 0; return (1); } - for (p = ports; p < ports+nports; p++) + for (p = ports; p < ports + nports; p++) if (p->port == port) { p->onoff = onoff; return (0); @@ -258,8 +258,8 @@ selecthost(struct in_addr *in, int onoff) { struct hitem *p; - if (in == 0) { - if (hosts == 0) + if (in == NULL) { + if (hosts == NULL) return (0); free((char *)hosts), hosts = 0; nhosts = 0; diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index 56bc34ea3021..90ddd2539c17 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -605,7 +605,7 @@ inetname(struct sockaddr *sa) if (np) cp = np->n_name; } - if (cp == 0) { + if (cp == NULL) { hp = gethostbyaddr((char *)&in, sizeof (in), AF_INET); if (hp) cp = hp->h_name;