Permalink
Browse files

More code hardening for CLANG

bug 403
  • Loading branch information...
jette committed Sep 9, 2013
1 parent 5269d0c commit eb4c20d0286acd8fa6e02c455e366b1888ad4d5e
Showing with 13 additions and 6 deletions.
  1. +4 −1 BUILD.NOTES
  2. +4 −2 src/common/list.c
  3. +1 −1 src/plugins/accounting_storage/mysql/as_mysql_acct.c
  4. +4 −2 src/slurmctld/controller.c
View
@@ -249,4 +249,7 @@ Before new major release:
- Review and release code
- Run "make check"
- Test that the prolog and epilog run
- - Run the test suite with SlurmUser NOT being self
+ - Run the test suite with SlurmUser NOT being self
+ - Test for errors reported by CLANG tool:
+ scan-build -k -v make >m.sb.out 2>&1
+ # and look for output in /tmp/scan-build-<DATE>
View
@@ -956,7 +956,8 @@ list_node_create (List l, ListNode *pp, void *x)
i->prev = &p->next;
else if (i->pos == p->next)
i->pos = p;
- assert((i->pos == *i->prev) || (i->pos == (*i->prev)->next));
+ assert((i->pos == *i->prev) ||
+ ((*i->prev) && (i->pos == (*i->prev)->next)));
}
return x;
@@ -996,7 +997,8 @@ list_node_destroy (List l, ListNode *pp)
i->pos = p->next, i->prev = pp;
else if (i->prev == &p->next)
i->prev = pp;
- assert((i->pos == *i->prev) || (i->pos == (*i->prev)->next));
+ assert((i->pos == *i->prev) ||
+ ((*i->prev) && (i->pos == (*i->prev)->next)));
}
list_node_free(p);
@@ -703,7 +703,7 @@ extern List as_mysql_get_accts(mysql_conn_t *mysql_conn, uid_t uid,
}
mysql_free_result(result);
- if (acct_cond && acct_cond->with_assocs
+ if (acct_cond && acct_cond->with_assocs && acct_cond->assoc_cond
&& list_count(acct_cond->assoc_cond->acct_list)) {
ListIterator assoc_itr = NULL;
slurmdb_account_rec_t *acct = NULL;
@@ -927,8 +927,10 @@ static void *_slurmctld_rpc_mgr(void *no_data)
sockfd[i] = slurm_init_msg_engine_addrname_port(
node_addr,
slurmctld_conf.slurmctld_port+i);
- if (sockfd[i] == SLURM_SOCKET_ERROR)
+ if (sockfd[i] == SLURM_SOCKET_ERROR) {
fatal("slurm_init_msg_engine_addrname_port error %m");
+ return NULL; /* Fix CLANG false positive */
+ }
slurm_get_stream_addr(sockfd[i], &srv_addr);
slurm_get_ip_str(&srv_addr, &port, ip, sizeof(ip));
debug2("slurmctld listening on %s:%d", ip, ntohs(port));
@@ -950,7 +952,7 @@ static void *_slurmctld_rpc_mgr(void *no_data)
int max_fd = -1;
FD_ZERO(&rfds);
for (i=0; i<nports; i++) {
- FD_SET(sockfd[i], &rfds); /* CLANG false positive */
+ FD_SET(sockfd[i], &rfds);
max_fd = MAX(sockfd[i], max_fd);
}
if (select(max_fd+1, &rfds, NULL, NULL, NULL) == -1) {

0 comments on commit eb4c20d

Please sign in to comment.