From: Andre Noll Date: Wed, 18 Mar 2009 22:05:22 +0000 (+0100) Subject: Fix various dead stores found by the clang static analyzer. X-Git-Tag: v0.3.4~26 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=31233289bedbb596b98eadd411bc6aac54d4ed69;p=paraslash.git Fix various dead stores found by the clang static analyzer. --- diff --git a/aft.c b/aft.c index daa9c730..62dedbf2 100644 --- a/aft.c +++ b/aft.c @@ -1308,7 +1308,6 @@ static void com_ls_callback(int fd, const struct osl_object *query) prepare_ls_row); if (ret < 0) goto out; - ret = opts->num_patterns? -E_NO_MATCH : 0; if (!opts->num_matching_paths) goto out; ret = sort_matching_paths(opts); @@ -1723,7 +1722,7 @@ static void com_add_callback(int fd, const struct osl_object *query) afs_event(AUDIO_FILE_ADD, &msg, aft_row); out: if (ret < 0) - ret = para_printf(&msg, "%s\n", para_strerror(-ret)); + para_printf(&msg, "%s\n", para_strerror(-ret)); if (msg.offset) pass_buffer_as_shm(msg.buf, msg.offset, &fd); free(msg.buf); @@ -2138,7 +2137,7 @@ static int remove_audio_file(__a_unused struct osl_table *table, struct osl_row *row, const char *name, void *data) { struct com_rm_action_data *crd = data; - int ret, ret2; + int ret; if (crd->flags & RM_FLAG_VERBOSE) { ret = para_printf(&crd->pb, "removing %s\n", name); @@ -2148,8 +2147,7 @@ static int remove_audio_file(__a_unused struct osl_table *table, afs_event(AUDIO_FILE_REMOVE, &crd->pb, row); ret = osl_del_row(audio_file_table, row); if (ret < 0) - ret2 = para_printf(&crd->pb, "%s: %s\n", name, - para_strerror(-ret)); + para_printf(&crd->pb, "%s: %s\n", name, para_strerror(-ret)); else crd->num_removed++; return ret; @@ -2178,7 +2176,7 @@ static void com_rm_callback(int fd, const struct osl_object *query) pmd.fnmatch_flags |= FNM_PATHNAME; ret = for_each_matching_row(&pmd); if (ret < 0) { - ret = para_printf(&crd.pb, "%s\n", para_strerror(-ret)); + para_printf(&crd.pb, "%s\n", para_strerror(-ret)); return; } if (!crd.num_removed && !(crd.flags & RM_FLAG_FORCE)) @@ -2328,14 +2326,13 @@ static void com_cpsi_callback(int fd, const struct osl_object *query) ret = for_each_matching_row(&pmd); out: if (ret < 0) - ret = para_printf(&cad.pb, "%s\n", para_strerror(-ret)); + para_printf(&cad.pb, "%s\n", para_strerror(-ret)); else if (cad.flags & CPSI_FLAG_VERBOSE) { if (cad.num_copied) - ret = para_printf(&cad.pb, "copied requested afsi from %s " - "to %u files\n", - source_path, cad.num_copied); + para_printf(&cad.pb, "copied requested afsi from %s " + "to %u files\n", source_path, cad.num_copied); else - ret = para_printf(&cad.pb, "nothing copied\n"); + para_printf(&cad.pb, "nothing copied\n"); } if (cad.pb.offset) pass_buffer_as_shm(cad.pb.buf, cad.pb.offset, &fd); diff --git a/attribute.c b/attribute.c index cce8ce6e..30c12f1c 100644 --- a/attribute.c +++ b/attribute.c @@ -127,13 +127,13 @@ static int print_attribute(struct osl_table *table, struct osl_row *row, { struct lsatt_action_data *laad = data; struct osl_object bitnum_obj; - int ret, ret2; + int ret; if (!(laad->flags & LSATT_FLAG_LONG)) return para_printf(&laad->pb, "%s\n", name); ret = osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj); if (ret < 0) { - ret2 = para_printf(&laad->pb, "%s: %s\n", name, para_strerror(-ret)); + para_printf(&laad->pb, "%s: %s\n", name, para_strerror(-ret)); return ret; } return para_printf(&laad->pb, "%u\t%s\n", *(unsigned char*)bitnum_obj.data, @@ -288,7 +288,7 @@ struct addatt_event_data { static void com_addatt_callback(int fd, const struct osl_object *query) { - char *p = query->data; + char *p; int ret = 1, ret2 = 0; struct para_buffer pb = { .max_size = SHMMAX, @@ -347,7 +347,7 @@ static void com_addatt_callback(int fd, const struct osl_object *query) } out: if (ret < 0 && ret2 >= 0) - ret = para_printf(&pb, "%s: %s\n", p, para_strerror(-ret)); + para_printf(&pb, "%s: %s\n", p, para_strerror(-ret)); if (pb.offset) pass_buffer_as_shm(pb.buf, pb.offset, &fd); free(pb.buf); @@ -388,7 +388,7 @@ static void com_mvatt_callback(int fd, const struct osl_object *query) ret = osl_update_object(attribute_table, row, ATTCOL_NAME, &obj); out: if (ret < 0) - ret = para_printf(&pb, "%s\n", para_strerror(-ret)); + para_printf(&pb, "%s\n", para_strerror(-ret)); else afs_event(ATTRIBUTE_RENAME, &pb, NULL); if (pb.offset) diff --git a/audiod_command.c b/audiod_command.c index a6f67762..3b41376d 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -379,7 +379,6 @@ int handle_connect(int accept_fd) ret = check_perms(uid); if (ret < 0) goto out; - ret = -E_INVALID_AUDIOD_CMD; cmd = para_strdup(buf); p = strchr(cmd, '\n'); if (!p) diff --git a/blob.c b/blob.c index 1742ac42..dbabba22 100644 --- a/blob.c +++ b/blob.c @@ -67,13 +67,13 @@ static int print_blob(struct osl_table *table, struct osl_row *row, struct lsblob_action_data *lbad = data; struct osl_object obj; uint32_t id; - int ret, ret2; + int ret; if (!(lbad->flags & BLOB_LS_FLAG_LONG)) return para_printf(&lbad->pb, "%s\n", name); ret = osl_get_object(table, row, BLOBCOL_ID, &obj); if (ret < 0) { - ret2 = para_printf(&lbad->pb, "%s: %s\n", name, para_strerror(-ret)); + para_printf(&lbad->pb, "%s: %s\n", name, para_strerror(-ret)); return ret; } id = *(uint32_t *)obj.data; @@ -110,7 +110,7 @@ static void com_lsblob_callback(struct osl_table *table, pmd.loop_col_num = BLOBCOL_ID; ret = for_each_matching_row(&pmd); if (ret < 0) - ret = para_printf(&lbad.pb, "%s\n", para_strerror(-ret)); + para_printf(&lbad.pb, "%s\n", para_strerror(-ret)); if (lbad.pb.offset) pass_buffer_as_shm(lbad.pb.buf, lbad.pb.offset, &fd); free(lbad.pb.buf); @@ -200,9 +200,9 @@ static int remove_blob(struct osl_table *table, struct osl_row *row, const char *name, void *data) { struct rmblob_data *rmbd = data; - int ret = osl_del_row(table, row), ret2; + int ret = osl_del_row(table, row); if (ret < 0) { - ret2 = para_printf(&rmbd->pb, "%s: %s\n", name, para_strerror(-ret)); + para_printf(&rmbd->pb, "%s: %s\n", name, para_strerror(-ret)); return ret; } rmbd->num_removed++; diff --git a/color.c b/color.c index 8be246d3..ca5a32d3 100644 --- a/color.c +++ b/color.c @@ -113,7 +113,7 @@ int color_parse(const char *value, char *dst) } } if (bg >= 0) { - if (sep++) + if (sep) *dst++ = ';'; if (bg < 8) { *dst++ = '4'; diff --git a/exec.c b/exec.c index 3c810a3e..86a483cf 100644 --- a/exec.c +++ b/exec.c @@ -135,11 +135,11 @@ err_out: */ int para_exec_cmdline_pid(pid_t *pid, const char *cmdline, int *fds) { - int argc, ret; + int ret; char **argv; char *tmp = para_strdup(cmdline); - argc = split_args(tmp, &argv, " \t"); + split_args(tmp, &argv, " \t"); ret = para_exec(pid, argv[0], argv, fds); free(argv); free(tmp); diff --git a/gui.c b/gui.c index 4862df5e..15422b96 100644 --- a/gui.c +++ b/gui.c @@ -1092,13 +1092,14 @@ static void com_page_up(void) { unsigned lines; int fvr = first_visible_rbe(&lines); + if (fvr < 0 || fvr + 1 >= ringbuffer_filled(bot_win_rb)) { print_in_bar(COLOR_ERRMSG, "top of buffer is shown\n"); return; } scroll_position = fvr + 1; for (; scroll_position > 0; scroll_position--) { - fvr = first_visible_rbe(&lines); + first_visible_rbe(&lines); if (lines == bot.lines) break; } diff --git a/mood.c b/mood.c index 57f3f00a..540d0c70 100644 --- a/mood.c +++ b/mood.c @@ -537,10 +537,10 @@ static int check_mood(struct osl_row *mood_row, void *data) struct osl_object mood_def; struct mood_line_parser_data mlpd = {.line_num = 0}; - int ret2, ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def); + int ret = mood_get_name_and_def_by_row(mood_row, &mood_name, &mood_def); if (ret < 0) { - ret2 = para_printf(pb, "failed to get mood definition: %s\n", + para_printf(pb, "failed to get mood definition: %s\n", para_strerror(-ret)); return ret; } @@ -552,7 +552,7 @@ static int check_mood(struct osl_row *mood_row, void *data) ret = for_each_line_ro(mood_def.data, mood_def.size, parse_mood_line, &mlpd); if (ret < 0) - ret2 = para_printf(pb, "%s line %u: %s\n", mood_name, mlpd.line_num, + para_printf(pb, "%s line %u: %s\n", mood_name, mlpd.line_num, para_strerror(-ret)); out: osl_close_disk_object(&mood_def); diff --git a/ogg_afh.c b/ogg_afh.c index c633f92f..55cf4ced 100644 --- a/ogg_afh.c +++ b/ogg_afh.c @@ -210,7 +210,6 @@ static long unsigned ogg_compute_chunk_table(OggVorbis_File *of, long unsigned num_chunks; ogg_int64_t max = 0, min = 0, old_pos = 0; - ret = 0; num = time_total / chunk_time + 3; PARA_DEBUG_LOG("chunk time: %g allocating %d chunk pointers\n", chunk_time, num); diff --git a/osl.c b/osl.c index ff588713..e2c1ef46 100644 --- a/osl.c +++ b/osl.c @@ -312,7 +312,6 @@ static int init_column_descriptions(struct osl_table *t) int i, j, ret; const struct osl_column_description *cd; - ret = -E_BAD_TABLE_DESC; ret = verify_name(t->desc->name); if (ret < 0) goto err; diff --git a/string.c b/string.c index 3c80d27c..eb458dad 100644 --- a/string.c +++ b/string.c @@ -292,9 +292,9 @@ __must_check __malloc char *para_homedir(void) * * \return The number of substrings found in \a args. */ -__must_check unsigned split_args(char *args, char *** const argv_ptr, const char *delim) +unsigned split_args(char *args, char *** const argv_ptr, const char *delim) { - char *p = args; + char *p; char **argv; size_t n = 0, i, j; diff --git a/string.h b/string.h index 77e62e90..272f107d 100644 --- a/string.h +++ b/string.h @@ -38,7 +38,7 @@ void chop(char *buf); __must_check __malloc char *para_tmpname(void); __must_check __malloc char *para_logname(void); __must_check __malloc char *para_homedir(void); -__must_check unsigned split_args(char *args, char *** const argv_ptr, const char *delim); +unsigned split_args(char *args, char *** const argv_ptr, const char *delim); __malloc char *para_hostname(void); __printf_2_3 int para_printf(struct para_buffer *b, const char *fmt, ...); /** Used for for_each_line() and for_each_line_ro(). */ diff --git a/vss.c b/vss.c index 9346d209..066a8851 100644 --- a/vss.c +++ b/vss.c @@ -877,7 +877,10 @@ static void vss_post_select(struct sched *s, struct task *t) } else if (FD_ISSET(vsst->afs_socket, &s->wfds)) { PARA_NOTICE_LOG("requesting new fd from afs\n"); ret = send_buffer(vsst->afs_socket, "new"); - vsst->afsss = AFS_SOCKET_AFD_PENDING; + if (ret < 0) + PARA_CRIT_LOG("%s\n", para_strerror(-ret)); + else + vsst->afsss = AFS_SOCKET_AFD_PENDING; } for (i = 0; senders[i].name; i++) { if (!senders[i].post_select)