summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@fingolfin.org>2020-01-19 06:33:55 +0000
committerRobert Mustacchi <rm@fingolfin.org>2020-02-01 06:34:51 +0000
commitb36afad7ffe84071c2c6831936cc1c524bd1ca90 (patch)
tree88f8bda1d62357d86da61576a1858be8e07a8947
parent69c811ab73b7ce531454837ae68c4343e8724e0b (diff)
downloadillumos-joyent-b36afad7ffe84071c2c6831936cc1c524bd1ca90.tar.gz
12216 Clean up libc-tests smatch
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: C Fraire <cfraire@me.com> Reviewed by: Jason King <jason.brian.king@gmail.com> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/test/libc-tests/tests/Makefile3
-rw-r--r--usr/src/test/libc-tests/tests/c11_threads.c4
-rw-r--r--usr/src/test/libc-tests/tests/call_once.c5
-rw-r--r--usr/src/test/libc-tests/tests/fnmatch.c2
-rw-r--r--usr/src/test/libc-tests/tests/memset_s.c24
-rw-r--r--usr/src/test/libc-tests/tests/printf-6961.c34
-rw-r--r--usr/src/test/libc-tests/tests/select/Makefile3
-rw-r--r--usr/src/test/libc-tests/tests/select/select_test.c18
-rw-r--r--usr/src/test/libc-tests/tests/set_constraint_handler_s.c4
-rw-r--r--usr/src/test/libc-tests/tests/symbols/Makefile3
-rw-r--r--usr/src/test/libc-tests/tests/symbols/symbols_test.c4
-rw-r--r--usr/src/test/os-tests/tests/odirectory.c4
12 files changed, 53 insertions, 55 deletions
diff --git a/usr/src/test/libc-tests/tests/Makefile b/usr/src/test/libc-tests/tests/Makefile
index f746498b0c..348a871926 100644
--- a/usr/src/test/libc-tests/tests/Makefile
+++ b/usr/src/test/libc-tests/tests/Makefile
@@ -57,9 +57,6 @@ SCRIPTS = \
CPPFLAGS += -D_REENTRANT
-# needs work
-SMOFF += all_func_returns,snprintf_overflow,unreachable
-
PROGS32 = $(PROGS:%=%.32)
PROGS64 = \
$(PROGS:%=%.64) \
diff --git a/usr/src/test/libc-tests/tests/c11_threads.c b/usr/src/test/libc-tests/tests/c11_threads.c
index 4504a9c262..2c7185ce47 100644
--- a/usr/src/test/libc-tests/tests/c11_threads.c
+++ b/usr/src/test/libc-tests/tests/c11_threads.c
@@ -51,10 +51,10 @@ static int
cthr_test_sleep_thr(void *arg)
{
for (;;) {
- sleep(1000);
+ (void) sleep(1000);
}
- abort();
+ return (0);
}
static void
diff --git a/usr/src/test/libc-tests/tests/call_once.c b/usr/src/test/libc-tests/tests/call_once.c
index 8c10420bcd..17a7dcd98a 100644
--- a/usr/src/test/libc-tests/tests/call_once.c
+++ b/usr/src/test/libc-tests/tests/call_once.c
@@ -42,8 +42,9 @@ static int
co_thr(void *arg)
{
VERIFY3S(mtx_lock(&co_mtx), ==, thrd_success);
- while (co_go == B_FALSE)
- cnd_wait(&co_cnd, &co_mtx);
+ while (co_go == B_FALSE) {
+ (void) cnd_wait(&co_cnd, &co_mtx);
+ }
VERIFY3S(mtx_unlock(&co_mtx), ==, thrd_success);
call_once(&co_once, co_once_func);
return (0);
diff --git a/usr/src/test/libc-tests/tests/fnmatch.c b/usr/src/test/libc-tests/tests/fnmatch.c
index ca42d9e904..503ae78d32 100644
--- a/usr/src/test/libc-tests/tests/fnmatch.c
+++ b/usr/src/test/libc-tests/tests/fnmatch.c
@@ -208,7 +208,7 @@ flags_to_string(int flags)
if (p == result)
memcpy(p, "0", 2);
else if (flags != 0)
- sprintf(p, "%d", flags);
+ (void) sprintf(p, "%d", flags);
else
*p = '\0';
return (result);
diff --git a/usr/src/test/libc-tests/tests/memset_s.c b/usr/src/test/libc-tests/tests/memset_s.c
index eb44230d60..e02fef20b2 100644
--- a/usr/src/test/libc-tests/tests/memset_s.c
+++ b/usr/src/test/libc-tests/tests/memset_s.c
@@ -46,33 +46,33 @@ main(void)
char b[3];
/* null ptr */
- set_constraint_handler_s(ignore_handler_s);
+ (void) set_constraint_handler_s(ignore_handler_s);
assert(memset_s(0, 1, 1, 1) != 0);
/* smax > rmax */
- set_constraint_handler_s(ignore_handler_s);
+ (void) set_constraint_handler_s(ignore_handler_s);
assert(memset_s(&b, RSIZE_MAX + 1, 1, 1) != 0);
/* smax < 0 */
- set_constraint_handler_s(ignore_handler_s);
+ (void) set_constraint_handler_s(ignore_handler_s);
assert(memset_s(&a, -1, 1, 1) != 0);
/* normal */
- set_constraint_handler_s(ignore_handler_s);
+ (void) set_constraint_handler_s(ignore_handler_s);
a = 3;
assert(memset_s(&a, 1, 5, 1) == 0);
assert(a == 5);
/* n > rmax */
- set_constraint_handler_s(ignore_handler_s);
+ (void) set_constraint_handler_s(ignore_handler_s);
assert(memset_s(&a, 1, 1, RSIZE_MAX + 1) != 0);
/* n < 0 */
- set_constraint_handler_s(ignore_handler_s);
+ (void) set_constraint_handler_s(ignore_handler_s);
assert(memset_s(&a, 1, 1, -1) != 0);
/* n < smax */
- set_constraint_handler_s(ignore_handler_s);
+ (void) set_constraint_handler_s(ignore_handler_s);
b[0] = 1; b[1] = 2; b[2] = 3;
assert(memset_s(&b[0], 3, 9, 1) == 0);
assert(b[0] == 9);
@@ -80,7 +80,7 @@ main(void)
assert(b[2] == 3);
/* n > smax, handler */
- set_constraint_handler_s(h);
+ (void) set_constraint_handler_s(h);
e = 0;
m = NULL;
b[0] = 1; b[1] = 2; b[2] = 3;
@@ -92,7 +92,7 @@ main(void)
assert(b[2] == 3);
/* smax > rmax, handler */
- set_constraint_handler_s(h);
+ (void) set_constraint_handler_s(h);
e = 0;
m = NULL;
assert(memset_s(&a, RSIZE_MAX + 1, 1, 1) != 0);
@@ -100,7 +100,7 @@ main(void)
assert(strcmp(m, "memset_s: smax > RSIZE_MAX") == 0);
/* smax < 0, handler */
- set_constraint_handler_s(h);
+ (void) set_constraint_handler_s(h);
e = 0;
m = NULL;
assert(memset_s(&a, -1, 1, 1) != 0);
@@ -108,7 +108,7 @@ main(void)
assert(strcmp(m, "memset_s: smax > RSIZE_MAX") == 0);
/* n > rmax, handler */
- set_constraint_handler_s(h);
+ (void) set_constraint_handler_s(h);
e = 0;
m = NULL;
assert(memset_s(&a, 1, 1, RSIZE_MAX + 1) != 0);
@@ -116,7 +116,7 @@ main(void)
assert(strcmp(m, "memset_s: n > RSIZE_MAX") == 0);
/* n < 0, handler */
- set_constraint_handler_s(h);
+ (void) set_constraint_handler_s(h);
e = 0;
m = NULL;
assert(memset_s(&a, 1, 1, -1) != 0);
diff --git a/usr/src/test/libc-tests/tests/printf-6961.c b/usr/src/test/libc-tests/tests/printf-6961.c
index 5c60b96425..c98c2b6a79 100644
--- a/usr/src/test/libc-tests/tests/printf-6961.c
+++ b/usr/src/test/libc-tests/tests/printf-6961.c
@@ -41,71 +41,71 @@ main(void)
char buf[32];
/* ~0L in octal */
- char octal0[] = { 'r', 'r', 'r', 'r', '1', '7', '7', '7', '7', '7', '7',
+ char octal0[32] = { 'r', 'r', 'r', 'r', '1', '7', '7', '7', '7', '7',
'7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7', '7',
- '7', '7', '\0', 'r', 'r', 'r', 'r', 'r', 'r' };
+ '7', '7', '7', '\0', 'r', 'r', 'r', 'r', 'r' };
- char decimal0[] = { 'r', 'r', 'r', 'r', '-', '1', '\0', 'r', 'r', 'r',
+ char decimal0[32] = { 'r', 'r', 'r', 'r', '-', '1', '\0', 'r', 'r', 'r',
'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r',
- 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r' };
+ 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r' };
- char hex0[] = { 'r', 'r', 'r', 'r', 'f', 'f', 'f', 'f', 'f', 'f',
+ char hex0[32] = { 'r', 'r', 'r', 'r', 'f', 'f', 'f', 'f', 'f', 'f',
'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f', '\0', 'r', 'r',
- 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r' };
+ 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r' };
/* 42 in octal */
- char octal1[] = { 'r', 'r', 'r', 'r', '5', '2', '\0', 'r', 'r', 'r',
+ char octal1[32] = { 'r', 'r', 'r', 'r', '5', '2', '\0', 'r', 'r', 'r',
'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r',
- 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r' };
+ 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r' };
/* 42 in decimal */
- char decimal1[] = { 'r', 'r', 'r', 'r', '4', '2', '\0', 'r', 'r', 'r',
+ char decimal1[32] = { 'r', 'r', 'r', 'r', '4', '2', '\0', 'r', 'r', 'r',
'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r',
- 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r' };
+ 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r' };
/* 42 in hex */
- char hex1[] = { 'r', 'r', 'r', 'r', '2', 'a', '\0', 'r', 'r', 'r', 'r',
+ char hex1[32] = { 'r', 'r', 'r', 'r', '2', 'a', '\0', 'r', 'r', 'r',
'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r',
'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r' };
(void) memset(buf, 'r', sizeof (buf));
- (void) snprintf(buf + 4, sizeof (buf), "%lo", ~0L);
+ (void) snprintf(buf + 4, sizeof (buf) - 4, "%lo", ~0L);
if (bcmp(octal0, buf, sizeof (buf)) != 0) {
print_diff("~0 in Octal", octal0, buf);
ret++;
}
(void) memset(buf, 'r', sizeof (buf));
- (void) snprintf(buf + 4, sizeof (buf), "%lo", 42L);
+ (void) snprintf(buf + 4, sizeof (buf) - 4, "%lo", 42L);
if (bcmp(octal1, buf, sizeof (buf)) != 0) {
print_diff("42 in Octal", octal1, buf);
ret++;
}
(void) memset(buf, 'r', sizeof (buf));
- (void) snprintf(buf + 4, sizeof (buf), "%ld", ~0L);
+ (void) snprintf(buf + 4, sizeof (buf) - 4, "%ld", ~0L);
if (bcmp(decimal0, buf, sizeof (buf)) != 0) {
print_diff("~0 in Decimal", decimal0, buf);
ret++;
}
(void) memset(buf, 'r', sizeof (buf));
- (void) snprintf(buf + 4, sizeof (buf), "%ld", 42L);
+ (void) snprintf(buf + 4, sizeof (buf) - 4, "%ld", 42L);
if (bcmp(decimal1, buf, sizeof (buf)) != 0) {
print_diff("42 in Decimal", decimal1, buf);
ret++;
}
(void) memset(buf, 'r', sizeof (buf));
- (void) snprintf(buf + 4, sizeof (buf), "%lx", ~0L);
+ (void) snprintf(buf + 4, sizeof (buf) - 4, "%lx", ~0L);
if (bcmp(hex0, buf, sizeof (buf)) != 0) {
print_diff("~0 in Hex", hex0, buf);
ret++;
}
(void) memset(buf, 'r', sizeof (buf));
- (void) snprintf(buf + 4, sizeof (buf), "%lx", 42L);
+ (void) snprintf(buf + 4, sizeof (buf) - 4, "%lx", 42L);
if (bcmp(hex1, buf, sizeof (buf)) != 0) {
print_diff("42 in Hex", hex1, buf);
ret++;
diff --git a/usr/src/test/libc-tests/tests/select/Makefile b/usr/src/test/libc-tests/tests/select/Makefile
index 2b0d80c6d6..ce019e281a 100644
--- a/usr/src/test/libc-tests/tests/select/Makefile
+++ b/usr/src/test/libc-tests/tests/select/Makefile
@@ -25,9 +25,6 @@ PROGS= select_test
CSTD= $(CSTD_GNU99)
-# needs work
-SMOFF += all_func_returns
-
select_test: select_test.c
$(LINK64.c) -o $@ select_test.c $(LDLIBS64)
$(POST_PROCESS)
diff --git a/usr/src/test/libc-tests/tests/select/select_test.c b/usr/src/test/libc-tests/tests/select/select_test.c
index f6af3718cb..2b30df4f5c 100644
--- a/usr/src/test/libc-tests/tests/select/select_test.c
+++ b/usr/src/test/libc-tests/tests/select/select_test.c
@@ -39,12 +39,12 @@ print_set(fd_set *a, size_t size)
{
for (int i = 0; i < size; i++) {
if (FD_ISSET(i, a))
- putc('1', stdout);
+ (void) putc('1', stdout);
else
- putc('0', stdout);
+ (void) putc('0', stdout);
}
- putc('\n', stdout);
+ (void) putc('\n', stdout);
}
int
@@ -85,8 +85,10 @@ main(int argc, char **argv)
if ((null = open("/dev/null", O_RDONLY)) == -1)
err(1, "couldn't open /dev/null");
- read(null, &buf, 1);
- read(null, &buf, 1);
+ if (read(null, &buf, 1) < 0)
+ err(1, "failed to read fd");
+ if (read(null, &buf, 1) < 0)
+ err(1, "failed to read fd");
if ((zero = open("/dev/zero", O_RDWR)) == -1)
err(1, "couldn't open /dev/zero");
@@ -103,11 +105,11 @@ main(int argc, char **argv)
}
if (swrite != NULL)
- puts("write");
+ (void) puts("write");
else if (sread != NULL)
- puts("read");
+ (void) puts("read");
else if (serr != NULL)
- puts("err");
+ (void) puts("err");
print_set(&proto, 80);
diff --git a/usr/src/test/libc-tests/tests/set_constraint_handler_s.c b/usr/src/test/libc-tests/tests/set_constraint_handler_s.c
index 770d5d46a4..1f9d6fe6df 100644
--- a/usr/src/test/libc-tests/tests/set_constraint_handler_s.c
+++ b/usr/src/test/libc-tests/tests/set_constraint_handler_s.c
@@ -33,11 +33,11 @@ main(void)
assert(set_constraint_handler_s(abort_handler_s) == NULL);
/* abort handler */
- set_constraint_handler_s(abort_handler_s);
+ (void) set_constraint_handler_s(abort_handler_s);
assert(set_constraint_handler_s(ignore_handler_s) == abort_handler_s);
/* ignore handler */
- set_constraint_handler_s(ignore_handler_s);
+ (void) set_constraint_handler_s(ignore_handler_s);
assert(set_constraint_handler_s(abort_handler_s) == ignore_handler_s);
return (0);
diff --git a/usr/src/test/libc-tests/tests/symbols/Makefile b/usr/src/test/libc-tests/tests/symbols/Makefile
index ac2ede1092..a5eef8a3a8 100644
--- a/usr/src/test/libc-tests/tests/symbols/Makefile
+++ b/usr/src/test/libc-tests/tests/symbols/Makefile
@@ -50,9 +50,6 @@ EXTRAPROG += $(SYMTESTS)
include ../Makefile.com
-# needs work
-SMOFF += testing_index_after_use
-
LDLIBS += -lcustr
LDLIBS64 += -lcustr
diff --git a/usr/src/test/libc-tests/tests/symbols/symbols_test.c b/usr/src/test/libc-tests/tests/symbols/symbols_test.c
index ac92feb2b6..ca714eb9f2 100644
--- a/usr/src/test/libc-tests/tests/symbols/symbols_test.c
+++ b/usr/src/test/libc-tests/tests/symbols/symbols_test.c
@@ -372,7 +372,7 @@ mkprog(struct sym_test *st)
case SYM_FUNC:
addprogstr("\ntest_func(");
- for (int i = 0; st->st_atypes[i] != NULL && i < MAXARG; i++) {
+ for (int i = 0; i < MAXARG && st->st_atypes[i] != NULL; i++) {
int didname = 0;
if (i > 0) {
addprogstr(", ");
@@ -422,7 +422,7 @@ mkprog(struct sym_test *st)
/* add the function call */
addprogfmt("%s(", st->st_name);
- for (int i = 0; st->st_atypes[i] != NULL && i < MAXARG; i++) {
+ for (int i = 0; i < MAXARG && st->st_atypes[i] != NULL; i++) {
if (strcmp(st->st_atypes[i], "") != 0 &&
strcmp(st->st_atypes[i], "void") != 0) {
addprogfmt("%sa%d", i > 0 ? ", " : "", i);
diff --git a/usr/src/test/os-tests/tests/odirectory.c b/usr/src/test/os-tests/tests/odirectory.c
index f818c6433f..e994126227 100644
--- a/usr/src/test/os-tests/tests/odirectory.c
+++ b/usr/src/test/os-tests/tests/odirectory.c
@@ -185,6 +185,10 @@ odir_cleanup(void)
if (fdetach(odir_doorpath) != 0) {
warn("failed to detach door %s", odir_doorpath);
}
+
+ if (unlink(odir_doorpath) != 0) {
+ warn("failed to unlink %s", odir_doorpath);
+ }
}
if (odir_did != -1) {