summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2019-01-20 23:09:40 +0200
committerToomas Soome <tsoome@me.com>2019-06-18 21:14:09 +0300
commite86c3f00315e5838c0ec0b14f34b94c292085956 (patch)
tree040cb32e51b16d757494c9ea86e33afccfb32133
parentad24f9fb30ac1431734347d46a592d22cbfcf3b6 (diff)
downloadillumos-joyent-e86c3f00315e5838c0ec0b14f34b94c292085956.tar.gz
11091 libc: NULL pointer errors
Reviewed by: Norm Jacobs <naj@snapcon.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/lib/libc/i386/crt/_rtld.c2
-rw-r--r--usr/src/lib/libc/port/gen/_xftw.c4
-rw-r--r--usr/src/lib/libc/port/gen/catopen.c8
-rw-r--r--usr/src/lib/libc/port/gen/crypt.c4
-rw-r--r--usr/src/lib/libc/port/gen/event_port.c10
-rw-r--r--usr/src/lib/libc/port/gen/fmtmsg.c6
-rw-r--r--usr/src/lib/libc/port/gen/getopt.c4
-rw-r--r--usr/src/lib/libc/port/gen/getutx.c2
-rw-r--r--usr/src/lib/libc/port/gen/mkstemp.c2
-rw-r--r--usr/src/lib/libc/port/gen/plock.c8
-rw-r--r--usr/src/lib/libc/port/gen/ttyname.c2
-rw-r--r--usr/src/lib/libc/port/inet/inet_network.c2
-rw-r--r--usr/src/lib/libc/port/locale/strptime.c2
-rw-r--r--usr/src/lib/libc/port/print/doprnt.c2
-rw-r--r--usr/src/lib/libc/port/rt/mqueue.c8
-rw-r--r--usr/src/lib/libc/port/threads/tdb_agent.c4
-rw-r--r--usr/src/lib/libc/port/threads/thr.c12
-rw-r--r--usr/src/lib/libc/sparc/crt/_rtld.c2
18 files changed, 33 insertions, 51 deletions
diff --git a/usr/src/lib/libc/i386/crt/_rtld.c b/usr/src/lib/libc/i386/crt/_rtld.c
index 92c9e53c55..459481ff57 100644
--- a/usr/src/lib/libc/i386/crt/_rtld.c
+++ b/usr/src/lib/libc/i386/crt/_rtld.c
@@ -99,7 +99,7 @@ __rtld(Elf32_Boot *ebp, const char *strings[], int (*funcs[])())
* Discover things about our environment: auxiliary vector (if
* any), arguments, program name, and the like.
*/
- while (ebp->eb_tag != NULL) {
+ while (ebp->eb_tag != 0) {
switch (ebp->eb_tag) {
case EB_ARGV:
program_name = *((char **)ebp->eb_un.eb_ptr);
diff --git a/usr/src/lib/libc/port/gen/_xftw.c b/usr/src/lib/libc/port/gen/_xftw.c
index c30d19fac0..681b6f20ca 100644
--- a/usr/src/lib/libc/port/gen/_xftw.c
+++ b/usr/src/lib/libc/port/gen/_xftw.c
@@ -27,8 +27,6 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* _xftw - file tree walk the uses expanded stat structure
*
@@ -348,7 +346,7 @@ nocdstat(const char *path, struct stat *statp, struct Var *vp, int sym)
(void) close(fd);
(void) free(dirp);
errno = ENAMETOOLONG;
- return (NULL);
+ return (0);
}
(void) close(fd);
fd = cfd;
diff --git a/usr/src/lib/libc/port/gen/catopen.c b/usr/src/lib/libc/port/gen/catopen.c
index 8a0ca43a3c..ece463fc2a 100644
--- a/usr/src/lib/libc/port/gen/catopen.c
+++ b/usr/src/lib/libc/port/gen/catopen.c
@@ -126,10 +126,10 @@ process_nls_path(char *name, int oflag)
while (s && *s) {
if (*s == '_') {
s1 = s;
- *s1++ = NULL;
+ *s1++ = '\0';
} else if (*s == '.') {
s2 = s;
- *s2++ = NULL;
+ *s2++ = '\0';
}
s++;
}
@@ -206,7 +206,7 @@ process_nls_path(char *name, int oflag)
s = name;
while (*s && t < pathname + PATH_MAX)
*t++ = *s++;
- *t = NULL;
+ *t = '\0';
return (file_open(pathname, SAFE_F));
}
@@ -269,7 +269,7 @@ replace_nls_option(char *s, char *name, char *pathname, char *locale,
}
++s;
}
- *t = NULL;
+ *t = '\0';
return (s);
}
diff --git a/usr/src/lib/libc/port/gen/crypt.c b/usr/src/lib/libc/port/gen/crypt.c
index 3d3e369bab..5edc9a1deb 100644
--- a/usr/src/lib/libc/port/gen/crypt.c
+++ b/usr/src/lib/libc/port/gen/crypt.c
@@ -697,9 +697,7 @@ free_crypt_alg(struct crypt_alg_s *alg)
if (alg->a_libhandle != NULL) {
(void) dlclose(alg->a_libhandle);
}
- if (alg->a_nparams != NULL) {
- free(alg->a_params);
- }
+ free(alg->a_params);
free(alg);
}
diff --git a/usr/src/lib/libc/port/gen/event_port.c b/usr/src/lib/libc/port/gen/event_port.c
index ee8317f21e..df8f5c7a64 100644
--- a/usr/src/lib/libc/port/gen/event_port.c
+++ b/usr/src/lib/libc/port/gen/event_port.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -73,7 +71,7 @@ port_get(int port, port_event_t *pe, struct timespec *to)
r.r_vals = _portfs(PORT_GET, port, (uintptr_t)pe, to->tv_sec,
to->tv_nsec, (uintptr_t)to);
else
- r.r_vals = _portfs(PORT_GET, port, (uintptr_t)pe, 0, 0, NULL);
+ r.r_vals = _portfs(PORT_GET, port, (uintptr_t)pe, 0, 0, 0);
return (r.r_val1);
}
@@ -112,8 +110,7 @@ int
port_send(int port, int events, void *user)
{
rval_t r;
- r.r_vals = _portfs(PORT_SEND, port, events, (uintptr_t)user, NULL,
- NULL);
+ r.r_vals = _portfs(PORT_SEND, port, events, (uintptr_t)user, 0, 0);
return (r.r_val1);
}
@@ -178,7 +175,6 @@ int
port_alert(int port, int flags, int events, void *user)
{
rval_t r;
- r.r_vals = _portfs(PORT_ALERT, port, flags, events, (uintptr_t)user,
- NULL);
+ r.r_vals = _portfs(PORT_ALERT, port, flags, events, (uintptr_t)user, 0);
return (r.r_val1);
}
diff --git a/usr/src/lib/libc/port/gen/fmtmsg.c b/usr/src/lib/libc/port/gen/fmtmsg.c
index 08ada435ce..063fe325f8 100644
--- a/usr/src/lib/libc/port/gen/fmtmsg.c
+++ b/usr/src/lib/libc/port/gen/fmtmsg.c
@@ -27,8 +27,6 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* fmtmsg.c
*
@@ -992,7 +990,7 @@ writemsg(char *buf, size_t size,
/* Write the TEXT, if requested */
if (dotext) {
p = (char *)text;
- for (c = *p++; c != NULL && buf < ebuf; c = *p++) {
+ for (c = *p++; c != '\0' && buf < ebuf; c = *p++) {
*buf++ = c;
if (c == '\n') {
for (i = 0; i < textindent && buf < ebuf; i++)
@@ -1017,7 +1015,7 @@ writemsg(char *buf, size_t size,
/* Write the "action" string */
p = (char *)action;
- for (c = *p++; c != NULL && buf < ebuf; c = *p++) {
+ for (c = *p++; c != '\0' && buf < ebuf; c = *p++) {
*buf++ = c;
if (c == '\n') {
for (i = 0; i < actindent && buf < ebuf; i++)
diff --git a/usr/src/lib/libc/port/gen/getopt.c b/usr/src/lib/libc/port/gen/getopt.c
index 5e3e3e23eb..cb6839f2ff 100644
--- a/usr/src/lib/libc/port/gen/getopt.c
+++ b/usr/src/lib/libc/port/gen/getopt.c
@@ -27,8 +27,6 @@
/* Copyright (c) 1988 AT&T */
/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* See getopt(3C) and SUS/XPG getopt() for function definition and
* requirements.
@@ -199,7 +197,7 @@ getopt(int argc, char *const *argv, const char *optstring)
if (optind >= argc || argv[optind][0] != '-' ||
argv[optind] == NULL || argv[optind][1] == '\0')
return (EOF);
- else if (strcmp(argv[optind], "--") == NULL) {
+ else if (strcmp(argv[optind], "--") == 0) {
optind++;
return (EOF);
}
diff --git a/usr/src/lib/libc/port/gen/getutx.c b/usr/src/lib/libc/port/gen/getutx.c
index 145ffc4a2a..da0c86fbbb 100644
--- a/usr/src/lib/libc/port/gen/getutx.c
+++ b/usr/src/lib/libc/port/gen/getutx.c
@@ -658,7 +658,7 @@ pututxline(const struct utmpx *entry)
*/
if (getutxid(&tmpxbuf) == NULL) {
lock++;
- if (lockf(fd, F_LOCK, 0) < NULL)
+ if (lockf(fd, F_LOCK, 0) < 0)
return (NULL);
(void) fseek(fp, 0, SEEK_END);
} else
diff --git a/usr/src/lib/libc/port/gen/mkstemp.c b/usr/src/lib/libc/port/gen/mkstemp.c
index d9de436d13..cb2b9be347 100644
--- a/usr/src/lib/libc/port/gen/mkstemp.c
+++ b/usr/src/lib/libc/port/gen/mkstemp.c
@@ -67,7 +67,7 @@ libc_mkstemps(char *as, int slen, int flags)
int len;
char *tstr, *str, *mkret;
- if (as == NULL || *as == NULL)
+ if (as == NULL || *as == '\0')
return (-1);
len = (int)strlen(as);
diff --git a/usr/src/lib/libc/port/gen/plock.c b/usr/src/lib/libc/port/gen/plock.c
index 1fb0367f1f..a3b313301d 100644
--- a/usr/src/lib/libc/port/gen/plock.c
+++ b/usr/src/lib/libc/port/gen/plock.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* plock - lock "segments" in physical memory.
*
@@ -117,7 +115,7 @@ plock(int op) /* desired operation */
* memcntl backs them out automatically.
*/
e = memcntl(NULL, 0, MC_LOCKAS, (caddr_t)MCL_CURRENT,
- PROC_TEXT|PRIVATE, (int)NULL);
+ PROC_TEXT|PRIVATE, 0);
if (!e)
lock_state |= TXTLOCK;
lmutex_unlock(&plock_lock);
@@ -144,7 +142,7 @@ plock(int op) /* desired operation */
* memcntl undoes the locks internally.
*/
e = memcntl(NULL, 0, MC_LOCKAS, (caddr_t)MCL_CURRENT,
- PROC_DATA|PRIVATE, (int)NULL);
+ PROC_DATA|PRIVATE, 0);
if (e) {
lmutex_unlock(&plock_lock);
return (-1);
@@ -160,7 +158,7 @@ plock(int op) /* desired operation */
if (e) {
e = errno;
(void) memcntl(NULL, 0, MC_UNLOCKAS,
- (caddr_t)MCL_CURRENT, PROC_DATA|PRIVATE, (int)NULL);
+ (caddr_t)MCL_CURRENT, PROC_DATA|PRIVATE, 0);
errno = e;
lmutex_unlock(&plock_lock);
return (-1);
diff --git a/usr/src/lib/libc/port/gen/ttyname.c b/usr/src/lib/libc/port/gen/ttyname.c
index d5c321a824..042a738db3 100644
--- a/usr/src/lib/libc/port/gen/ttyname.c
+++ b/usr/src/lib/libc/port/gen/ttyname.c
@@ -285,7 +285,7 @@ _ttyname_common(struct stat64 *fsp, char *buffer, uint_t match_mask)
* Is /dev/pts then just do a quick check. We don't have
* to stat the entire /dev/pts dir.
*/
- if (strcmp(PTS, srch_dirs[dirno].name) == NULL) {
+ if (strcmp(PTS, srch_dirs[dirno].name) == 0) {
if ((pt = ispts(fsp, match_mask)) != NULL) {
is_pts = 1;
found = 1;
diff --git a/usr/src/lib/libc/port/inet/inet_network.c b/usr/src/lib/libc/port/inet/inet_network.c
index 8205a4795a..952804b43c 100644
--- a/usr/src/lib/libc/port/inet/inet_network.c
+++ b/usr/src/lib/libc/port/inet/inet_network.c
@@ -68,7 +68,7 @@ again:
else
base = 8;
}
- while ((c = *cp) != NULL) {
+ while ((c = *cp) != '\0') {
if (isdigit(c)) {
if ((c - '0') >= base)
break;
diff --git a/usr/src/lib/libc/port/locale/strptime.c b/usr/src/lib/libc/port/locale/strptime.c
index f5be4eba8c..eba76189ad 100644
--- a/usr/src/lib/libc/port/locale/strptime.c
+++ b/usr/src/lib/libc/port/locale/strptime.c
@@ -426,7 +426,7 @@ label:
case 'Y':
case 'y':
- if (*buf == NULL || isspace(*buf))
+ if (*buf == '\0' || isspace(*buf))
break;
if (!isdigit(*buf))
diff --git a/usr/src/lib/libc/port/print/doprnt.c b/usr/src/lib/libc/port/print/doprnt.c
index e8cfaad6de..8a6dfd5e90 100644
--- a/usr/src/lib/libc/port/print/doprnt.c
+++ b/usr/src/lib/libc/port/print/doprnt.c
@@ -1904,7 +1904,7 @@ wide_S:
* wbuff, allocate larger buffer
*/
if ((nwc =
- mbstowcs(NULL, bp, NULL)) ==
+ mbstowcs(NULL, bp, 0)) ==
(size_t)-1) {
sec_display =
strlen(bp);
diff --git a/usr/src/lib/libc/port/rt/mqueue.c b/usr/src/lib/libc/port/rt/mqueue.c
index 59ff825210..b2cbd48264 100644
--- a/usr/src/lib/libc/port/rt/mqueue.c
+++ b/usr/src/lib/libc/port/rt/mqueue.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include "mtlib.h"
#define _KMEMUSER
@@ -260,7 +258,7 @@ mq_getmsg(mqhdr_t *mqhp, char *msgp, uint_t *msg_prio)
MQ_ASSERT_PTR(mqhp, currentp);
curbuf = MQ_PTR(mqhp, currentp);
- if ((*headpp = curbuf->msg_next) == NULL) {
+ if ((*headpp = curbuf->msg_next) == 0) {
/*
* We just nuked the last message in this priority's queue.
* Twiddle this priority's bit, and then find the next bit
@@ -275,7 +273,7 @@ mq_getmsg(mqhdr_t *mqhp, char *msgp, uint_t *msg_prio)
break;
mqhp->mq_curmaxprio = prio;
- *tailpp = NULL;
+ *tailpp = 0;
}
/*
@@ -312,7 +310,7 @@ mq_putmsg(mqhdr_t *mqhp, const char *msgp, ssize_t len, uint_t prio)
* Remove a message from the free list, and copy in the new contents.
*/
mqhp->mq_freep = curbuf->msg_next;
- curbuf->msg_next = NULL;
+ curbuf->msg_next = 0;
(void) memcpy((char *)&curbuf[1], msgp, len);
curbuf->msg_len = len;
diff --git a/usr/src/lib/libc/port/threads/tdb_agent.c b/usr/src/lib/libc/port/threads/tdb_agent.c
index 919f0473f4..84de640b63 100644
--- a/usr/src/lib/libc/port/threads/tdb_agent.c
+++ b/usr/src/lib/libc/port/threads/tdb_agent.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* This file contains most of the functionality
* required to support the threads portion of libc_db.
@@ -368,7 +366,7 @@ tdb_sync_obj_deregister(void *addr)
* (Once the hash table is allocated, it is never deallocated.)
*/
if (tdbp->tdb_sync_addr_hash == NULL ||
- tdbp->tdb_sync_addr_hash[hash = tdb_addr_hash(addr)] == NULL)
+ tdbp->tdb_sync_addr_hash[hash = tdb_addr_hash(addr)] == 0)
return;
lmutex_lock(&udp->tdb_hash_lock);
diff --git a/usr/src/lib/libc/port/threads/thr.c b/usr/src/lib/libc/port/threads/thr.c
index e849b19e6d..2a982eb8c8 100644
--- a/usr/src/lib/libc/port/threads/thr.c
+++ b/usr/src/lib/libc/port/threads/thr.c
@@ -88,12 +88,12 @@ extern const Lc_interface rtld_funcs[];
*/
#pragma weak _uberdata = __uberdata
uberdata_t __uberdata = {
- { DEFAULTMUTEX, NULL, 0 }, /* link_lock */
- { RECURSIVEMUTEX, NULL, 0 }, /* ld_lock */
- { RECURSIVEMUTEX, NULL, 0 }, /* fork_lock */
- { RECURSIVEMUTEX, NULL, 0 }, /* atfork_lock */
- { RECURSIVEMUTEX, NULL, 0 }, /* callout_lock */
- { DEFAULTMUTEX, NULL, 0 }, /* tdb_hash_lock */
+ { DEFAULTMUTEX, 0, 0 }, /* link_lock */
+ { RECURSIVEMUTEX, 0, 0 }, /* ld_lock */
+ { RECURSIVEMUTEX, 0, 0 }, /* fork_lock */
+ { RECURSIVEMUTEX, 0, 0 }, /* atfork_lock */
+ { RECURSIVEMUTEX, 0, 0 }, /* callout_lock */
+ { DEFAULTMUTEX, 0, 0 }, /* tdb_hash_lock */
{ 0, }, /* tdb_hash_lock_stats */
{ { 0 }, }, /* siguaction[NSIG] */
{{ DEFAULTMUTEX, NULL, 0 }, /* bucket[NBUCKETS] */
diff --git a/usr/src/lib/libc/sparc/crt/_rtld.c b/usr/src/lib/libc/sparc/crt/_rtld.c
index a9e9c6d98a..84caa8460e 100644
--- a/usr/src/lib/libc/sparc/crt/_rtld.c
+++ b/usr/src/lib/libc/sparc/crt/_rtld.c
@@ -98,7 +98,7 @@ __rtld(Elf32_Boot *ebp, const char *strings[], int (*funcs[])())
* Discover things about our environment: auxiliary vector (if
* any), arguments, program name, and the like.
*/
- while (ebp->eb_tag != NULL) {
+ while (ebp->eb_tag != 0) {
switch (ebp->eb_tag) {
case EB_ARGV:
program_name = *((char **)ebp->eb_un.eb_ptr);