svn commit: r298182 - head/usr.bin/netstat
Marcelo Araujo
araujo at FreeBSD.org
Mon Apr 18 05:46:19 UTC 2016
Author: araujo
Date: Mon Apr 18 05:46:18 2016
New Revision: 298182
URL: https://svnweb.freebsd.org/changeset/base/298182
Log:
Use NULL instead of 0 for pointers.
Also malloc will return NULL if it cannot allocate memory.
MFC after: 2 weeks.
Modified:
head/usr.bin/netstat/inet.c
head/usr.bin/netstat/sctp.c
head/usr.bin/netstat/unix.c
Modified: head/usr.bin/netstat/inet.c
==============================================================================
--- head/usr.bin/netstat/inet.c Mon Apr 18 05:26:32 2016 (r298181)
+++ head/usr.bin/netstat/inet.c Mon Apr 18 05:46:18 2016 (r298182)
@@ -120,7 +120,7 @@ pcblist_sysctl(int proto, const char *na
xo_warn("sysctl: %s", mibvar);
return (0);
}
- if ((buf = malloc(len)) == 0) {
+ if ((buf = malloc(len)) == NULL) {
xo_warnx("malloc %lu bytes", (u_long)len);
return (0);
}
@@ -207,7 +207,7 @@ pcblist_kvm(u_long off, char **bufp, int
len = 2 * sizeof(xig) +
(pcbinfo.ipi_count + pcbinfo.ipi_count / 8) *
sizeof(struct xinpcb);
- if ((buf = malloc(len)) == 0) {
+ if ((buf = malloc(len)) == NULL) {
xo_warnx("malloc %lu bytes", (u_long)len);
return (0);
}
@@ -1460,7 +1460,7 @@ inetname(struct in_addr *inp)
if (np)
cp = np->n_name;
}
- if (cp == 0) {
+ if (cp == NULL) {
hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET);
if (hp) {
cp = hp->h_name;
Modified: head/usr.bin/netstat/sctp.c
==============================================================================
--- head/usr.bin/netstat/sctp.c Mon Apr 18 05:26:32 2016 (r298181)
+++ head/usr.bin/netstat/sctp.c Mon Apr 18 05:46:18 2016 (r298182)
@@ -128,7 +128,7 @@ inetname(struct in_addr *inp)
if (np)
cp = np->n_name;
}
- if (cp == 0) {
+ if (cp == NULL) {
hp = gethostbyaddr((char *)inp, sizeof (*inp), AF_INET);
if (hp) {
cp = hp->h_name;
@@ -586,7 +586,7 @@ sctp_protopr(u_long off __unused,
xo_warn("sysctl: %s", mibvar);
return;
}
- if ((buf = malloc(len)) == 0) {
+ if ((buf = malloc(len)) == NULL) {
xo_warnx("malloc %lu bytes", (u_long)len);
return;
}
Modified: head/usr.bin/netstat/unix.c
==============================================================================
--- head/usr.bin/netstat/unix.c Mon Apr 18 05:26:32 2016 (r298181)
+++ head/usr.bin/netstat/unix.c Mon Apr 18 05:46:18 2016 (r298182)
@@ -83,7 +83,7 @@ pcblist_sysctl(int type, char **bufp)
xo_warn("sysctl: %s", mibvar);
return (-1);
}
- if ((buf = malloc(len)) == 0) {
+ if ((buf = malloc(len)) == NULL) {
xo_warnx("malloc %lu bytes", (u_long)len);
return (-2);
}
@@ -116,7 +116,7 @@ pcblist_kvm(u_long count_off, u_long gen
return (-1);
kread(count_off, &unp_count, sizeof(unp_count));
len = 2 * sizeof(xug) + (unp_count + unp_count / 8) * sizeof(xu);
- if ((buf = malloc(len)) == 0) {
+ if ((buf = malloc(len)) == NULL) {
xo_warnx("malloc %lu bytes", (u_long)len);
return (-2);
}
More information about the svn-src-all
mailing list