Spotted by Coverity Scan Signed-off-by: Fabio M. Di Nitto <fdini...@redhat.com> --- :100644 100644 b92090c... a1c1c14... M cman/cman_tool/join.c :100644 100644 46c315d... 0e8876a... M cman/cman_tool/main.c cman/cman_tool/join.c | 10 +++++----- cman/cman_tool/main.c | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/cman/cman_tool/join.c b/cman/cman_tool/join.c index b92090c..a1c1c14 100644 --- a/cman/cman_tool/join.c +++ b/cman/cman_tool/join.c @@ -122,7 +122,7 @@ static int check_corosync_status(pid_t pid) int join(commandline_t *comline) { - int i, err; + int i; int envptr = 0; int argvptr = 0; char scratch[1024]; @@ -252,13 +252,13 @@ int join(commandline_t *comline) be_daemon(); sprintf(scratch, "FORKED: %d\n", getpid()); - err = write(p[1], scratch, strlen(scratch)); + write(p[1], scratch, strlen(scratch)); execve(COROSYNCBIN, argv, envp); /* exec failed - tell the parent process */ sprintf(scratch, "execve of " COROSYNCBIN " failed: %s", strerror(errno)); - err = write(p[1], scratch, strlen(scratch)); + write(p[1], scratch, strlen(scratch)); exit(1); break; @@ -290,7 +290,7 @@ int join(commandline_t *comline) if ((len = read(p[0], message, sizeof(message)) > 0)) { /* Forked OK - get the real corosync pid */ - if (sscanf(messageptr, "FORKED: %d", &corosync_pid) == 1) { + if ((messageptr) && (sscanf(messageptr, "FORKED: %d", &corosync_pid) == 1)) { if (comline->verbose & DEBUG_STARTUP_ONLY) fprintf(stderr, "forked process ID is %d\n", corosync_pid); status = 0; @@ -303,7 +303,7 @@ int join(commandline_t *comline) continue; } /* Success! get the new PID of double-forked corosync */ - if (sscanf(messageptr, "SUCCESS: %d", &corosync_pid) == 1) { + if ((messageptr) && (sscanf(messageptr, "SUCCESS: %d", &corosync_pid) == 1)) { if (comline->verbose & DEBUG_STARTUP_ONLY) fprintf(stderr, "corosync running, process ID is %d\n", corosync_pid); status = 0; diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c index 46c315d..0e8876a 100644 --- a/cman/cman_tool/main.c +++ b/cman/cman_tool/main.c @@ -618,11 +618,10 @@ static void leave(commandline_t *comline) static void set_expected(commandline_t *comline) { cman_handle_t h; - int result; h = open_cman_handle(1); - if ((result = cman_set_expected_votes(h, comline->expected_votes))) + if (cman_set_expected_votes(h, comline->expected_votes)) die("can't set expected votes: %s", cman_error(errno)); cman_finish(h); @@ -631,7 +630,6 @@ static void set_expected(commandline_t *comline) static void set_votes(commandline_t *comline) { cman_handle_t h; - int result; int nodeid; struct cman_node node; @@ -650,7 +648,7 @@ static void set_votes(commandline_t *comline) nodeid = node.cn_nodeid; } - if ((result = cman_set_votes(h, comline->votes, nodeid))) + if (cman_set_votes(h, comline->votes, nodeid)) die("can't set votes: %s", cman_error(errno)); cman_finish(h); -- 1.7.4.4