From f08b4e0c5d8959b72e938b890410d4e2dfdd304f Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Sat, 6 Jun 2020 19:03:03 +0200 Subject: [PATCH] Remove some dead stores signalled by clang analyzer Signed-off-by: Erik Boasson --- src/mpt/tests/qos/procs/rw.c | 3 +-- src/tools/ddsperf/ddsperf.c | 6 +++--- src/tools/pubsub/pubsub.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mpt/tests/qos/procs/rw.c b/src/mpt/tests/qos/procs/rw.c index 747302a..59dc678 100644 --- a/src/mpt/tests/qos/procs/rw.c +++ b/src/mpt/tests/qos/procs/rw.c @@ -328,13 +328,12 @@ MPT_ProcessEntry (rw_publisher, static void wait_for_done (dds_entity_t rd, const char *userdata) { - int32_t n; void *raw = NULL; dds_sample_info_t si; bool done = false; while (!done) { - while (!done && (n = dds_take (rd, &raw, &si, 1, 1)) == 1) + while (!done && dds_take (rd, &raw, &si, 1, 1) == 1) { const dds_builtintopic_participant_t *sample = raw; void *ud = NULL; diff --git a/src/tools/ddsperf/ddsperf.c b/src/tools/ddsperf/ddsperf.c index 04ee308..d755b49 100644 --- a/src/tools/ddsperf/ddsperf.c +++ b/src/tools/ddsperf/ddsperf.c @@ -562,7 +562,7 @@ static uint32_t pubthread (void *varg) { int result; dds_instance_handle_t *ihs; - dds_time_t ntot = 0, tfirst, tfirst0; + dds_time_t ntot = 0, tfirst; union data data; uint64_t timeouts = 0; void *baggage = NULL; @@ -584,7 +584,7 @@ static uint32_t pubthread (void *varg) } data.seq_keyval.keyval = 0; - tfirst0 = tfirst = dds_time(); + tfirst = dds_time(); uint32_t bi = 0; while (!ddsrt_atomic_ld32 (&termflag)) @@ -623,7 +623,7 @@ static uint32_t pubthread (void *varg) if (++bi == burstsize) { /* FIXME: should average rate over a short-ish period, rather than over the entire run */ - while (((double) (ntot / burstsize) / ((double) (t - tfirst0) / 1e9 + 5e-3)) > pub_rate && !ddsrt_atomic_ld32 (&termflag)) + while (((double) (ntot / burstsize) / ((double) (t - tfirst) / 1e9 + 5e-3)) > pub_rate && !ddsrt_atomic_ld32 (&termflag)) { /* FIXME: flushing manually because batching is not yet implemented properly */ dds_write_flush (wr_data); diff --git a/src/tools/pubsub/pubsub.c b/src/tools/pubsub/pubsub.c index 3d8c581..2c6479b 100644 --- a/src/tools/pubsub/pubsub.c +++ b/src/tools/pubsub/pubsub.c @@ -1980,7 +1980,7 @@ static char *read_line_from_textfile(FILE *fp) { str[n++] = (char)c; } if (c != EOF || n > 0) { - if (n == sz) str = dds_realloc(str, sz += 1); + if (n == sz) str = dds_realloc(str, sz + 1); str[n] = 0; } else if (ferror(fp)) { error_exit("error reading file, errno = %d\n", errno);