From: Richard Kettlewell Date: Thu, 17 Jun 2010 19:52:01 +0000 (+0100) Subject: Merge various clang-inspired fixes X-Git-Tag: branchpoint-5.1~74 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/commitdiff_plain/85f0650b8304e3a1cd34eec40a272cda02371ff5?hp=f87532949a0834686852e1cf59519d948c59eee7 Merge various clang-inspired fixes --- diff --git a/cgi/actions.c b/cgi/actions.c index fae533a..f6755b0 100644 --- a/cgi/actions.c +++ b/cgi/actions.c @@ -612,7 +612,7 @@ static int process_prefs(int numfile) { byte_xasprintf((char **)&name, "trackname_%s_%s", context, part); disorder_set(dcgi_client, file, name, value); } - if((value = numbered_arg("random", numfile))) + if(numbered_arg("random", numfile)) disorder_unset(dcgi_client, file, "pick_at_random"); else disorder_set(dcgi_client, file, "pick_at_random", "0"); diff --git a/disobedience/choose-search.c b/disobedience/choose-search.c index acfddfa..60df2ec 100644 --- a/disobedience/choose-search.c +++ b/disobedience/choose-search.c @@ -441,6 +441,7 @@ static gboolean choose_get_visible_range(GtkTreeView *tree_view, * @param direction -1 for prev, +1 for next */ static void choose_move(int direction) { + assert(direction); /* placate analyzer */ /* Refocus the main view so typahead find continues to work */ gtk_widget_grab_focus(choose_view); /* If there's no results we have nothing to do */ diff --git a/disobedience/playlists.c b/disobedience/playlists.c index 4d4194e..c1a857d 100644 --- a/disobedience/playlists.c +++ b/disobedience/playlists.c @@ -601,7 +601,7 @@ static void playlist_new_details(char **namep, if(privatep) *privatep = private; if(namep) *namep = name; if(fullnamep) { - if(*sharedp) *fullnamep = *namep; + if(shared) *fullnamep = *namep; else byte_xasprintf(fullnamep, "%s.%s", config->username, name); } } diff --git a/disobedience/rtp.c b/disobedience/rtp.c index cbedb18..4693173 100644 --- a/disobedience/rtp.c +++ b/disobedience/rtp.c @@ -1,6 +1,6 @@ /* * This file is part of Disobedience - * Copyright (C) 2007 Richard Kettlewell + * Copyright (C) 2007-2010 Richard Kettlewell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -108,7 +108,7 @@ void start_rtp(void) { if(!(pid = xfork())) { if(setsid() < 0) disorder_fatal(errno, "error calling setsid"); - if(!(pid = xfork())) { + if(!xfork()) { /* grandchild */ exitfn = _exit; /* log errors and output somewhere reasonably sane. rtp_running() diff --git a/lib/cgi.c b/lib/cgi.c index 15b556c..9fd42f1 100644 --- a/lib/cgi.c +++ b/lib/cgi.c @@ -226,7 +226,6 @@ void cgi_clear(void) { */ char *cgi_sgmlquote(const char *src) { uint32_t *ucs, c; - int n; struct dynstr d[1]; struct sink *s; @@ -234,7 +233,6 @@ char *cgi_sgmlquote(const char *src) { exit(1); dynstr_init(d); s = sink_dynstr(d); - n = 1; /* format the string */ while((c = *ucs++)) { switch(c) { diff --git a/lib/client.c b/lib/client.c index 67f8a53..00727ef 100644 --- a/lib/client.c +++ b/lib/client.c @@ -507,7 +507,7 @@ int disorder_close(disorder_client *c) { } c->ident = 0; c->user = 0; - return 0; + return ret; } /** @brief Play a track diff --git a/libtests/t-hash.c b/libtests/t-hash.c index 4d8b68a..e23ee1a 100644 --- a/libtests/t-hash.c +++ b/libtests/t-hash.c @@ -50,8 +50,10 @@ static void test_hash(void) { for(i = 0; i < 10000; ++i) { insist((ip = hash_find(h, do_printf("%d", i))) != 0); - check_integer(*ip, i); - insist(hash_add(h, do_printf("%d", i), &i, HASH_REPLACE) == 0); + if(ip) { + check_integer(*ip, i); + insist(hash_add(h, do_printf("%d", i), &i, HASH_REPLACE) == 0); + } } check_integer(hash_count(h), 10000); keys = hash_keys(h); diff --git a/plugins/exec.c b/plugins/exec.c index f6ed8b3..e2e712c 100644 --- a/plugins/exec.c +++ b/plugins/exec.c @@ -39,7 +39,6 @@ void disorder_play_track(const char *const *parameters, const char **vec; vec = disorder_malloc((nparameters + 2) * sizeof (char *)); - i = 0; j = 0; for(i = 0; i < nparameters; ++i) vec[j++] = parameters[i]; diff --git a/server/dump.c b/server/dump.c index cdc3a44..fb07415 100644 --- a/server/dump.c +++ b/server/dump.c @@ -378,8 +378,8 @@ int main(int argc, char **argv) { case 'd': dump = 1; break; case 'u': undump = 1; break; case 'D': debugging = 1; break; - case 'r': recover = TRACKDB_NORMAL_RECOVER; - case 'R': recover = TRACKDB_FATAL_RECOVER; + case 'r': recover = TRACKDB_NORMAL_RECOVER; break; + case 'R': recover = TRACKDB_FATAL_RECOVER; break; case 'a': recompute = 1; break; case 'P': remove_pathless = 1; break; default: disorder_fatal(0, "invalid option"); diff --git a/server/play.c b/server/play.c index 99ef483..8406238 100644 --- a/server/play.c +++ b/server/play.c @@ -300,7 +300,7 @@ static int start(ev_source *ev, D(("start %s", q->id)); /* Find the player plugin. */ - if(!(player = find_player(q)) < 0) + if(!(player = find_player(q))) return START_HARDFAIL; /* No player */ if(!(q->pl = open_plugin(player->s[1], 0))) return START_HARDFAIL; @@ -395,7 +395,7 @@ int prepare(ev_source *ev, if(q->prepared || q->preparing) return START_OK; /* Find the player plugin */ - if(!(player = find_player(q)) < 0) + if(!(player = find_player(q))) return START_HARDFAIL; /* No player */ q->pl = open_plugin(player->s[1], 0); q->type = play_get_type(q->pl); diff --git a/server/schedule.c b/server/schedule.c index f1b20a1..c7b4eed 100644 --- a/server/schedule.c +++ b/server/schedule.c @@ -471,14 +471,12 @@ static int schedule_lookup(const char *id, static int schedule_trigger(ev_source *ev, const struct timeval attribute((unused)) *now, void *u) { - const char *action, *id = u; + const char *id = u; struct kvp *actiondata = schedule_get(id); int n; if(!actiondata) return 0; - /* schedule_get() enforces these being present */ - action = kvp_get(actiondata, "action"); /* Look up the action */ n = schedule_lookup(id, actiondata); if(n < 0) diff --git a/server/server.c b/server/server.c index 858edbc..4dafabb 100644 --- a/server/server.c +++ b/server/server.c @@ -1177,7 +1177,7 @@ static int c_nop(struct conn *c, static int c_new(struct conn *c, char **vec, int nvec) { - int max, n; + int max; char **tracks; if(nvec > 0) @@ -1188,7 +1188,6 @@ static int c_new(struct conn *c, max = config->new_max; tracks = trackdb_new(0, max); sink_printf(ev_writer_sink(c->w), "253 New track list follows\n"); - n = 0; while(*tracks) { sink_printf(ev_writer_sink(c->w), "%s%s\n", **tracks == '.' ? "." : "", *tracks); diff --git a/server/speaker.c b/server/speaker.c index a2c2e7c..3af36aa 100644 --- a/server/speaker.c +++ b/server/speaker.c @@ -340,7 +340,8 @@ static int speaker_fill(struct track *t) { t->playable = 1; rc = 0; } - } + } else + rc = 0; return rc; }