Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[asan] various test and core bug repairs toward asan testing #1737

Merged
merged 6 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/bindings/lua/lua-affinity/lua-affinity.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ static int lua_string_to_cpu_setp (lua_State *L, int index, cpu_set_t *setp)
* If string begins with 0x, 00, or contains long string of digits
* separated by ',', or cstr_to_cpuset() fails then try hex_to_cpuset().
*/
if ((memcmp (s, "0x", 2L) == 0)
|| (memcmp (s, "00", 2L) == 0)
if ((strncmp (s, "0x", 2L) == 0)
|| (strncmp (s, "00", 2L) == 0)
|| ((strchr (s, ',') - s) >= 8)
|| ((err = cstr_to_cpuset (setp, s)) && err != E2BIG)) {
err = hex_to_cpuset (setp, s);
Expand Down
42 changes: 21 additions & 21 deletions src/broker/test/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ int main (int argc, char **argv)
*/
val = attr_first (attrs);
ok (val && !strcmp (val, "foo"),
"attr_first returned %s", val);
"attr_first returned foo");
ok (attr_next (attrs) == NULL,
"attr_next returned NULL");
ok (attr_add (attrs, "foo1", "42", 0) == 0
Expand All @@ -112,19 +112,19 @@ int main (int argc, char **argv)
"attr_add foo1, foo2, foo3, foo4 works");
val = attr_first (attrs);
ok (val && !strncmp (val, "foo", 3),
"attr_first returned %s", val);
"attr_first returned foo-prefixed attr");
val = attr_next (attrs);
ok (val && !strncmp (val, "foo", 3),
"attr_next returned %s", val);
"attr_next returned foo-prefixed attr");
val = attr_next (attrs);
ok (val && !strncmp (val, "foo", 3),
"attr_next returned %s", val);
"attr_next returned foo-prefixed attr");
val = attr_next (attrs);
ok (val && !strncmp (val, "foo", 3),
"attr_next returned %s", val);
"attr_next returned foo-prefixed attr");
val = attr_next (attrs);
ok (val && !strncmp (val, "foo", 3),
"attr_next returned %s", val);
"attr_next returned foo-prefixed attr");
ok (attr_next (attrs) == NULL,
"attr_next returned NULL");

Expand All @@ -134,28 +134,28 @@ int main (int argc, char **argv)
"attr_add_active_int works");
a = 0;
ok (attr_get (attrs, "a", &val, NULL) == 0 && val && !strcmp (val, "0"),
"attr_get on active int tracks value: %s", val);
"attr_get on active int tracks val=0");
a = 1;
ok (attr_get (attrs, "a", &val, NULL) == 0 && !strcmp (val, "1"),
"attr_get on active int tracks value: %s", val);
"attr_get on active int tracks val=1");
a = -1;
ok (attr_get (attrs, "a", &val, NULL) == 0 && !strcmp (val, "-1"),
"attr_get on active int tracks value: %s", val);
"attr_get on active int tracks val=-1");
a = INT_MAX - 1;
ok (attr_get (attrs, "a", &val, NULL) == 0
&& strtol (val, NULL, 10) == INT_MAX - 1,
"attr_get on active int tracks value: %s", val);
"attr_get on active int tracks val=INT_MAX-1");
a = INT_MIN + 1;
ok (attr_get (attrs, "a", &val, NULL) == 0
&& strtol (val, NULL, 10) == INT_MIN + 1,
"attr_get on active int tracks value: %s", val);
"attr_get on active int tracks val=INT_MIN+1");

ok (attr_set (attrs, "a", "0", false) == 0 && a == 0,
"attr_set on active int sets value: %d", a);
"attr_set on active int sets val=0");
ok (attr_set (attrs, "a", "1", false) == 0 && a == 1,
"attr_set on active int sets value: %d", a);
"attr_set on active int sets val=1");
ok (attr_set (attrs, "a", "-1", false) == 0 && a == -1,
"attr_set on active int sets value: %d", a);
"attr_set on active int sets val=-1");
errno = 0;
ok (attr_delete (attrs, "a", false) < 0 && errno == EPERM,
"attr_delete on active attr fails with EPERM");
Expand All @@ -168,19 +168,19 @@ int main (int argc, char **argv)
"attr_add_active_uint32 works");
b = 0;
ok (attr_get (attrs, "b", &val, NULL) == 0 && val && !strcmp (val, "0"),
"attr_get on active uin32_t tracks value: %s", val);
"attr_get on active uin32_t tracks val=0");
b = 1;
ok (attr_get (attrs, "b", &val, NULL) == 0 && !strcmp (val, "1"),
"attr_get on active uint32_t tracks value: %s", val);
"attr_get on active uint32_t tracks val=1");
b = UINT_MAX - 1;
ok (attr_get (attrs, "b", &val, NULL) == 0
&& strtoul (val, NULL, 10) == UINT_MAX - 1,
"attr_get on active uint32_t tracks value: %s", val);
"attr_get on active uint32_t tracks val=UINT_MAX-1");

ok (attr_set (attrs, "b", "0", false) == 0 && b == 0,
"attr_set on active uint32_t sets value: %d", b);
"attr_set on active uint32_t sets val=0");
ok (attr_set (attrs, "b", "1", false) == 0 && b == 1,
"attr_set on active uint32_t sets value: %d", b);
"attr_set on active uint32_t sets val=1");
ok (attr_delete (attrs, "b", true) == 0,
"attr_delete (force) works on active attr");

Expand All @@ -190,10 +190,10 @@ int main (int argc, char **argv)
"attr_add_active_int FLUX_ATTRFLAG_IMMUTABLE works");
c = 42;
ok (attr_get (attrs, "c", &val, NULL) == 0 && val && !strcmp (val, "42"),
"attr_get returns initial value: %s", val);
"attr_get returns initial val=42");
c = 43;
ok (attr_get (attrs, "c", &val, NULL) == 0 && val && !strcmp (val, "42"),
"attr_get ignores value changes: %s", val);
"attr_get ignores value changes");
errno = 0;
ok (attr_delete (attrs, "c", true) < 0 && errno == EPERM,
"attr_delete (force) fails with EPERM");
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/flux.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static const char *default_cmdhelp_pattern (optparse_t *p)

void usage (optparse_t *p)
{
char *help_pattern;
char *help_pattern = NULL;
const char *val = getenv ("FLUX_CMDHELP_PATTERN");
const char *def = default_cmdhelp_pattern (p);

Expand All @@ -80,6 +80,7 @@ void usage (optparse_t *p)
optparse_print_usage (p);
fprintf (stderr, "\n");
emit_command_help (help_pattern, stderr);
free (help_pattern);
}

static optparse_t * setup_optparse_parse_args (int argc, char *argv[])
Expand Down
1 change: 1 addition & 0 deletions src/common/libflux/mrpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ static flux_mrpc_t *mrpc (flux_t *h,
if (rv < 0)
goto error;
nodeset_iterator_destroy (itr);
nodeset_destroy (ns);
return mrpc;
error:
flux_mrpc_destroy (mrpc);
Expand Down
3 changes: 1 addition & 2 deletions src/common/libkvs/test/kvs_eventlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ void bad_input (void)
struct flux_kvs_eventlog *log;
char *s;
int i;
char buf[512];

lives_ok ({flux_kvs_eventlog_destroy (NULL);},
"flux_kvs_eventlog_destroy log=NULL doesn't crash");
Expand Down Expand Up @@ -191,7 +192,6 @@ void bad_input (void)

/* decode bad events */
for (i = 0; badevent[i] != NULL; i++) {
char buf[80];
errno = 0;
ok (flux_kvs_event_decode (badevent[i], NULL, NULL, 0, NULL, 0) < 0
&& errno == EINVAL,
Expand All @@ -206,7 +206,6 @@ void bad_input (void)

/* decode bad logs */
for (i = 0; badlog[i] != NULL; i++) {
char buf[512];
errno = 0;
ok (flux_kvs_eventlog_decode (badlog[i]) == NULL && errno == EINVAL,
"flux_kvs_eventlog_decode log=\"%s\" fails with EINVAL",
Expand Down
3 changes: 2 additions & 1 deletion src/common/libutil/read_all.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,15 @@ ssize_t read_all (int fd, void **bufp)
do {
if (len - count == 0) {
len += chunksize;
if (!(new = realloc (buf, len)))
if (!(new = realloc (buf, len+1)))
goto error;
buf = new;
}
if ((n = read (fd, buf + count, len - count)) < 0)
goto error;
count += n;
} while (n != 0);
((char*)buf)[count] = '\0';
*bufp = buf;
return count;
error:
Expand Down