]> code.delx.au - pulseaudio/commitdiff
llvm-clang-analyzer: drop a few unnecessary assignments and other trivial fixes
authorLennart Poettering <lennart@poettering.net>
Tue, 8 Sep 2009 21:46:23 +0000 (23:46 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 8 Sep 2009 21:46:23 +0000 (23:46 +0200)
20 files changed:
src/modules/alsa/alsa-mixer.c
src/modules/alsa/alsa-sink.c
src/modules/alsa/alsa-source.c
src/modules/alsa/alsa-util.c
src/modules/module-hal-detect.c
src/modules/module-tunnel.c
src/modules/raop/base64.c
src/modules/x11/module-x11-publish.c
src/pulse/utf8.c
src/pulse/volume.c
src/pulsecore/core-util.c
src/pulsecore/flist.c
src/pulsecore/memtrap.c
src/pulsecore/pid.c
src/pulsecore/protocol-esound.c
src/pulsecore/protocol-native.c
src/pulsecore/protocol-simple.c
src/pulsecore/sink-input.c
src/pulsecore/socket-client.c
src/utils/pacat.c

index 61c92cd0ee15040c6a0dd6b404c30596b6ad7b38..9eb7b4629c79099e08e6b62e6cdb45288863c41b 100644 (file)
@@ -2889,7 +2889,7 @@ static void profile_set_add_auto_pair(
     else
         name = pa_sprintf_malloc("input:%s", n->name);
 
-    if ((p = pa_hashmap_get(ps->profiles, name))) {
+    if (pa_hashmap_get(ps->profiles, name)) {
         pa_xfree(name);
         return;
     }
index 195bdf6ec0e780daab162a160ef07bfa2bfd8f51..63a3e906c5b7d4f845e11de7804e59e3cf66a2bf 100644 (file)
@@ -1638,7 +1638,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
     const char *dev_id = NULL;
     pa_sample_spec ss, requested_ss;
     pa_channel_map map;
-    uint32_t nfrags, hwbuf_size, frag_size, tsched_size, tsched_watermark;
+    uint32_t nfrags, frag_size, tsched_size, tsched_watermark;
     snd_pcm_uframes_t period_frames, tsched_frames;
     size_t frame_size;
     pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE;
@@ -1673,7 +1673,6 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
         goto fail;
     }
 
-    hwbuf_size = frag_size * nfrags;
     period_frames = frag_size/frame_size;
     tsched_frames = tsched_size/frame_size;
 
index f42d35429e7fd7bd909492dc8ed38925f956e1ca..64f89806175681a9911fb9899b1c140572d74653 100644 (file)
@@ -1483,7 +1483,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
     const char *dev_id = NULL;
     pa_sample_spec ss, requested_ss;
     pa_channel_map map;
-    uint32_t nfrags, hwbuf_size, frag_size, tsched_size, tsched_watermark;
+    uint32_t nfrags, frag_size, tsched_size, tsched_watermark;
     snd_pcm_uframes_t period_frames, tsched_frames;
     size_t frame_size;
     pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d, ignore_dB = FALSE;
@@ -1518,7 +1518,6 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
         goto fail;
     }
 
-    hwbuf_size = frag_size * nfrags;
     period_frames = frag_size/frame_size;
     tsched_frames = tsched_size/frame_size;
 
index a47a8958bfcc9407cd11ee8cb4d08b543cc1e2bc..4d75c63c36ecc6646faf648005518c7074aec49b 100644 (file)
@@ -900,7 +900,7 @@ void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name) {
     snd_ctl_card_info_alloca(&info);
 
     if ((err = snd_ctl_open(&ctl, name, 0)) < 0) {
-        pa_log_warn("Error opening low-level control device '%s'", name);
+        pa_log_warn("Error opening low-level control device '%s': %s", name, snd_strerror(err));
         return;
     }
 
index 6034d0ee6408689df4972fdb8c0f57df5b2e878c..185191318cb757751360d468bdf91b9ff8b9bc32 100644 (file)
@@ -435,9 +435,7 @@ static int hal_device_add_all(struct userdata *u) {
         int i;
 
         for (i = 0; i < n; i++) {
-            struct device *d;
-
-            if ((d = hal_device_add(u, udis[i]))) {
+            if (hal_device_add(u, udis[i])) {
                 count++;
                 pa_log_debug("Loaded device %s", udis[i]);
             } else
index 5ccb81d0659c2c3cac989d781a222e9641375e94..af4b8b2acbc40c088ebd46bf3ff2a97e0b3266cf 100644 (file)
@@ -332,7 +332,7 @@ static void command_moved(pa_pdispatch *pd,  uint32_t command,  uint32_t tag, pa
 
 static void command_stream_buffer_attr_changed(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
     struct userdata *u = userdata;
-    uint32_t channel, maxlength, tlength, fragsize, prebuf, minreq;
+    uint32_t channel, maxlength, tlength = 0, fragsize, prebuf, minreq;
     pa_usec_t usec;
 
     pa_assert(pd);
@@ -1097,7 +1097,7 @@ static void sink_input_info_cb(pa_pdispatch *pd, uint32_t command,  uint32_t tag
     uint32_t idx, owner_module, client, sink;
     pa_usec_t buffer_usec, sink_usec;
     const char *name, *driver, *resample_method;
-    pa_bool_t mute;
+    pa_bool_t mute = FALSE;
     pa_sample_spec sample_spec;
     pa_channel_map channel_map;
     pa_cvolume volume;
@@ -1345,12 +1345,11 @@ static void command_subscribe_event(pa_pdispatch *pd,  uint32_t command,  uint32
 /* Called from main context */
 static void start_subscribe(struct userdata *u) {
     pa_tagstruct *t;
-    uint32_t tag;
     pa_assert(u);
 
     t = pa_tagstruct_new(NULL, 0);
     pa_tagstruct_putu32(t, PA_COMMAND_SUBSCRIBE);
-    pa_tagstruct_putu32(t, tag = u->ctag++);
+    pa_tagstruct_putu32(t, u->ctag++);
     pa_tagstruct_putu32(t, PA_SUBSCRIPTION_MASK_SERVER|
 #ifdef TUNNEL_SINK
                         PA_SUBSCRIPTION_MASK_SINK_INPUT|PA_SUBSCRIPTION_MASK_SINK
@@ -1526,7 +1525,7 @@ static void setup_complete_callback(pa_pdispatch *pd, uint32_t command, uint32_t
 
     reply = pa_tagstruct_new(NULL, 0);
     pa_tagstruct_putu32(reply, PA_COMMAND_SET_CLIENT_NAME);
-    pa_tagstruct_putu32(reply, tag = u->ctag++);
+    pa_tagstruct_putu32(reply, u->ctag++);
 
     if (u->version >= 13) {
         pa_proplist *pl;
@@ -1753,7 +1752,6 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
 static void sink_set_volume(pa_sink *sink) {
     struct userdata *u;
     pa_tagstruct *t;
-    uint32_t tag;
 
     pa_assert(sink);
     u = sink->userdata;
@@ -1761,7 +1759,7 @@ static void sink_set_volume(pa_sink *sink) {
 
     t = pa_tagstruct_new(NULL, 0);
     pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_INPUT_VOLUME);
-    pa_tagstruct_putu32(t, tag = u->ctag++);
+    pa_tagstruct_putu32(t, u->ctag++);
     pa_tagstruct_putu32(t, u->device_index);
     pa_tagstruct_put_cvolume(t, &sink->real_volume);
     pa_pstream_send_tagstruct(u->pstream, t);
@@ -1771,7 +1769,6 @@ static void sink_set_volume(pa_sink *sink) {
 static void sink_set_mute(pa_sink *sink) {
     struct userdata *u;
     pa_tagstruct *t;
-    uint32_t tag;
 
     pa_assert(sink);
     u = sink->userdata;
@@ -1782,7 +1779,7 @@ static void sink_set_mute(pa_sink *sink) {
 
     t = pa_tagstruct_new(NULL, 0);
     pa_tagstruct_putu32(t, PA_COMMAND_SET_SINK_INPUT_MUTE);
-    pa_tagstruct_putu32(t, tag = u->ctag++);
+    pa_tagstruct_putu32(t, u->ctag++);
     pa_tagstruct_putu32(t, u->device_index);
     pa_tagstruct_put_boolean(t, !!sink->muted);
     pa_pstream_send_tagstruct(u->pstream, t);
index e1cbed026987913e6d4411365b996b15f1f55643..5b061034174af5053a23547a8db3f5b0d468695d 100644 (file)
@@ -57,7 +57,6 @@ int pa_base64_encode(const void *data, int size, char **str)
 
     p = s = pa_xnew(char, size * 4 / 3 + 4);
     q = (const unsigned char *) data;
-    i = 0;
     for (i = 0; i < size;) {
         c = q[i++];
         c *= 256;
index 2c7fdc12352f631a1259612d18c67597bb030134..7ee1b6daf91afa09adeb20762cb9811562baa483 100644 (file)
@@ -90,7 +90,7 @@ static void publish_servers(struct userdata *u, pa_strlist *l) {
 
         l = pa_strlist_reverse(l);
         s = pa_strlist_tostring(l);
-        l = pa_strlist_reverse(l);
+        pa_strlist_reverse(l);
 
         pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SERVER", s);
         pa_xfree(s);
index 6b58bde34fe5112906eadf623211d50686b9ea62..9dddf4a3f3ee8b0191409d4aaa3d14d843c79c6c 100644 (file)
@@ -120,10 +120,8 @@ static char* utf8_validate(const char *str, char *output) {
                 size = 4;
                 min = (1 << 16);
                 val = (uint32_t) (*p & 0x07);
-            } else {
-                size = 1;
+            } else
                 goto error;
-            }
 
             p++;
             if (!is_continuation_char(*p))
index 47bccad291da96cd0e8e631d1a70a5779ba441bf..2d2bba2506defa3b878040801a07880f715213d5 100644 (file)
@@ -155,7 +155,7 @@ pa_volume_t pa_cvolume_min(const pa_cvolume *a) {
 
 pa_volume_t pa_cvolume_max_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) {
     pa_volume_t m = PA_VOLUME_MUTED;
-    unsigned c, n;
+    unsigned c;
 
     pa_assert(a);
 
@@ -164,7 +164,7 @@ pa_volume_t pa_cvolume_max_mask(const pa_cvolume *a, const pa_channel_map *cm, p
 
     pa_return_val_if_fail(pa_cvolume_compatible_with_channel_map(a, cm), PA_VOLUME_MUTED);
 
-    for (c = n = 0; c < a->channels; c++) {
+    for (c = 0; c < a->channels; c++) {
 
         if (!(PA_CHANNEL_POSITION_MASK(cm->map[c]) & mask))
             continue;
@@ -178,7 +178,7 @@ pa_volume_t pa_cvolume_max_mask(const pa_cvolume *a, const pa_channel_map *cm, p
 
 pa_volume_t pa_cvolume_min_mask(const pa_cvolume *a, const pa_channel_map *cm, pa_channel_position_mask_t mask) {
     pa_volume_t m = PA_VOLUME_MAX;
-    unsigned c, n;
+    unsigned c;
 
     pa_assert(a);
 
@@ -187,7 +187,7 @@ pa_volume_t pa_cvolume_min_mask(const pa_cvolume *a, const pa_channel_map *cm, p
 
     pa_return_val_if_fail(pa_cvolume_compatible_with_channel_map(a, cm), PA_VOLUME_MUTED);
 
-    for (c = n = 0; c < a->channels; c++) {
+    for (c = 0; c < a->channels; c++) {
 
         if (!(PA_CHANNEL_POSITION_MASK(cm->map[c]) & mask))
             continue;
index 1daa46eb592576103f9047b4f2665682bf411873..d64c7388c8712f573b041fdd54146bb1b687670e 100644 (file)
@@ -591,13 +591,13 @@ static int set_scheduler(int rtprio) {
     sp.sched_priority = rtprio;
 
 #ifdef SCHED_RESET_ON_FORK
-    if ((r = pthread_setschedparam(pthread_self(), SCHED_RR|SCHED_RESET_ON_FORK, &sp)) == 0) {
+    if (pthread_setschedparam(pthread_self(), SCHED_RR|SCHED_RESET_ON_FORK, &sp) == 0) {
         pa_log_debug("SCHED_RR|SCHED_RESET_ON_FORK worked.");
         return 0;
     }
 #endif
 
-    if ((r = pthread_setschedparam(pthread_self(), SCHED_RR, &sp)) == 0) {
+    if (pthread_setschedparam(pthread_self(), SCHED_RR, &sp) == 0) {
         pa_log_debug("SCHED_RR worked.");
         return 0;
     }
@@ -786,7 +786,6 @@ int pa_match(const char *expr, const char *v) {
 /* Try to parse a boolean string value.*/
 int pa_parse_boolean(const char *v) {
     const char *expr;
-    int r;
     pa_assert(v);
 
     /* First we check language independant */
@@ -798,12 +797,12 @@ int pa_parse_boolean(const char *v) {
     /* And then we check language dependant */
     if ((expr = nl_langinfo(YESEXPR)))
         if (expr[0])
-            if ((r = pa_match(expr, v)) > 0)
+            if (pa_match(expr, v) > 0)
                 return 1;
 
     if ((expr = nl_langinfo(NOEXPR)))
         if (expr[0])
-            if ((r = pa_match(expr, v)) > 0)
+            if (pa_match(expr, v) > 0)
                 return 0;
 
     errno = EINVAL;
@@ -1195,7 +1194,7 @@ char* pa_strip_nl(char *s) {
 
 /* Create a temporary lock file and lock it. */
 int pa_lock_lockfile(const char *fn) {
-    int fd = -1;
+    int fd;
     pa_assert(fn);
 
     for (;;) {
@@ -1238,8 +1237,6 @@ int pa_lock_lockfile(const char *fn) {
             fd = -1;
             goto fail;
         }
-
-        fd = -1;
     }
 
     return fd;
index 6fb944f9cc5a5f2806b56330620279806b90d3ff..7e5ee244c92416362c694467e64bec4b91aa8371 100644 (file)
@@ -130,15 +130,22 @@ void pa_flist_free(pa_flist *l, pa_free_cb_t free_cb) {
 }
 
 int pa_flist_push(pa_flist*l, void *p) {
-    unsigned idx, n, len;
+    unsigned idx, n;
     pa_atomic_ptr_t*cells;
+#ifdef PROFILE
+    unsigned len;
+#endif
 
     pa_assert(l);
     pa_assert(p);
 
     cells = PA_FLIST_CELLS(l);
 
-    n = len = l->size + N_EXTRA_SCAN - (unsigned) pa_atomic_load(&l->length);
+    n = l->size + N_EXTRA_SCAN - (unsigned) pa_atomic_load(&l->length);
+
+#ifdef PROFILE
+    len = n;
+#endif
 
     _Y;
     idx = reduce(l, (unsigned) pa_atomic_load(&l->write_idx));
@@ -171,14 +178,21 @@ int pa_flist_push(pa_flist*l, void *p) {
 }
 
 void* pa_flist_pop(pa_flist*l) {
-    unsigned idx, len, n;
+    unsigned idx, n;
     pa_atomic_ptr_t *cells;
+#ifdef PROFILE
+    unsigned len;
+#endif
 
     pa_assert(l);
 
     cells = PA_FLIST_CELLS(l);
 
-    n = len = (unsigned) pa_atomic_load(&l->length) + N_EXTRA_SCAN;
+    n = (unsigned) pa_atomic_load(&l->length) + N_EXTRA_SCAN;
+
+#ifdef PROFILE
+    len = n;
+#endif
 
     _Y;
     idx = reduce(l, (unsigned) pa_atomic_load(&l->read_idx));
index c647e50710a242e1fd48b3b3b18e7d3ec95b09bd..373872c1c5bd4e7bcabbb3c00cf6cef8eb1bcbbc 100644 (file)
@@ -200,13 +200,13 @@ pa_memtrap *pa_memtrap_update(pa_memtrap *m, const void *start, size_t size) {
         goto unlock;
 
     memtrap_unlink(m, j);
-    j = pa_aupdate_write_swap(aupdate);
+    pa_aupdate_write_swap(aupdate);
 
     m->start = (void*) start;
     m->size = size;
     pa_atomic_store(&m->bad, 0);
 
-    j = pa_aupdate_write_swap(aupdate);
+    pa_assert_se(pa_aupdate_write_swap(aupdate) == j);
     memtrap_link(m, j);
 
 unlock:
index 008784629de97b899580773aaf42af3568276f93..996946c284c86794e58a7c4bd2372e5c384c6cce 100644 (file)
@@ -81,7 +81,7 @@ static pid_t read_pid(const char *fn, int fd) {
 }
 
 static int open_pid_file(const char *fn, int mode) {
-    int fd = -1;
+    int fd;
 
     pa_assert(fn);
 
@@ -123,8 +123,6 @@ static int open_pid_file(const char *fn, int mode) {
             fd = -1;
             goto fail;
         }
-
-        fd = -1;
     }
 
     return fd;
index 480af6d562609d1b325d4387909a0f974ee43631..2326eb3a72aa22457ed1640056035a627bf92adb 100644 (file)
@@ -771,7 +771,6 @@ static int esd_proto_stream_pan(connection *c, esd_proto_t request, const void *
 
     memcpy(&rvolume, data, sizeof(uint32_t));
     rvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, rvolume);
-    data = (const char*)data + sizeof(uint32_t);
 
     if ((conn = pa_idxset_get_by_index(c->protocol->connections, idx)) && conn->sink_input) {
         pa_cvolume volume;
@@ -809,7 +808,6 @@ static int esd_proto_sample_pan(connection *c, esd_proto_t request, const void *
 
     memcpy(&rvolume, data, sizeof(uint32_t));
     rvolume = PA_MAYBE_UINT32_SWAP(c->swap_byte_order, rvolume);
-    data = (const char*)data + sizeof(uint32_t);
 
     volume.values[0] = (lvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE;
     volume.values[1] = (rvolume*PA_VOLUME_NORM)/ESD_VOLUME_BASE;
@@ -1123,7 +1121,7 @@ static int do_read(connection *c) {
         ssize_t r;
         size_t l;
         void *p;
-        size_t space;
+        size_t space = 0;
 
         pa_assert(c->input_memblockq);
 
index d961dba2dd5c758a29a974832774bc4cd3d23fb1..0215c233210e33d2a46365c714961847659475b0 100644 (file)
@@ -628,7 +628,6 @@ static record_stream* record_stream_new(
 
     record_stream *s;
     pa_source_output *source_output = NULL;
-    size_t base;
     pa_source_output_new_data data;
 
     pa_assert(c);
@@ -682,7 +681,7 @@ static record_stream* record_stream_new(
             0,
             s->buffer_attr.maxlength,
             0,
-            base = pa_frame_size(&source_output->sample_spec),
+            pa_frame_size(&source_output->sample_spec),
             1,
             0,
             0,
index d66db4b7228ccdf275e8a1d8e4b381f464c16276..a9f73896706e156557295349561afcc647405f75 100644 (file)
@@ -154,7 +154,7 @@ static int do_read(connection *c) {
     ssize_t r;
     size_t l;
     void *p;
-    size_t space;
+    size_t space = 0;
 
     connection_assert_ref(c);
 
index adda2affb7196c1af692f4b967d5ee036f484daf..5f79ab1ea19cd90f130e43cf28db60c177db6c45 100644 (file)
@@ -1152,7 +1152,6 @@ pa_bool_t pa_sink_input_may_move_to(pa_sink_input *i, pa_sink *dest) {
 /* Called from main context */
 int pa_sink_input_start_move(pa_sink_input *i) {
     pa_source_output *o, *p = NULL;
-    pa_sink *origin;
     int r;
 
     pa_sink_input_assert_ref(i);
@@ -1166,8 +1165,6 @@ int pa_sink_input_start_move(pa_sink_input *i) {
     if ((r = pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_START], i)) < 0)
         return r;
 
-    origin = i->sink;
-
     /* Kill directly connected outputs */
     while ((o = pa_idxset_first(i->direct_outputs, NULL))) {
         pa_assert(o != p);
index 2453515785f86caac832182110b451d28b779e6e..c9cfdbe36025c3dcafd679e55898abe86ec32ffb 100644 (file)
@@ -202,8 +202,6 @@ static void connect_io_cb(pa_mainloop_api*m, pa_io_event *e, int fd, pa_io_event
 }
 
 static int do_connect(pa_socket_client *c, const struct sockaddr *sa, socklen_t len) {
-    int r;
-
     pa_assert(c);
     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     pa_assert(sa);
@@ -211,7 +209,7 @@ static int do_connect(pa_socket_client *c, const struct sockaddr *sa, socklen_t
 
     pa_make_fd_nonblock(c->fd);
 
-    if ((r = connect(c->fd, sa, len)) < 0) {
+    if (connect(c->fd, sa, len) < 0) {
 #ifdef OS_IS_WIN32
         if (WSAGetLastError() != EWOULDBLOCK) {
             pa_log_debug("connect(): %d", WSAGetLastError());
index 0a369bc285853f3bff57579db8756980e207dc52..d6c04db77e464a979a6e28af7d993301fbcd879c 100644 (file)
@@ -406,7 +406,6 @@ static void context_state_callback(pa_context *c, void *userdata) {
             break;
 
         case PA_CONTEXT_READY: {
-            int r;
             pa_buffer_attr buffer_attr;
 
             pa_assert(c);
@@ -443,13 +442,13 @@ static void context_state_callback(pa_context *c, void *userdata) {
 
             if (mode == PLAYBACK) {
                 pa_cvolume cv;
-                if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, volume_is_set ? pa_cvolume_set(&cv, sample_spec.channels, volume) : NULL, NULL)) < 0) {
+                if (pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, volume_is_set ? pa_cvolume_set(&cv, sample_spec.channels, volume) : NULL, NULL) < 0) {
                     pa_log(_("pa_stream_connect_playback() failed: %s"), pa_strerror(pa_context_errno(c)));
                     goto fail;
                 }
 
             } else {
-                if ((r = pa_stream_connect_record(stream, device, latency > 0 ? &buffer_attr : NULL, flags)) < 0) {
+                if (pa_stream_connect_record(stream, device, latency > 0 ? &buffer_attr : NULL, flags) < 0) {
                     pa_log(_("pa_stream_connect_record() failed: %s"), pa_strerror(pa_context_errno(c)));
                     goto fail;
                 }