Use NULL instead of 0 for pointers.

gethostbyname(3) will return NULL for error status.

MFC after:	2 weeks.
This commit is contained in:
araujo 2016-04-20 01:26:03 +00:00
parent 7ce919789a
commit b9140f06e3
3 changed files with 10 additions and 10 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;