From eda9326eca7f062e5560d942577240867b772aa9 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Mon, 7 Dec 2020 07:58:40 -0500 Subject: [PATCH] Remove some dead assignments Found by the clang static analyzer. --- src/6model/serialization.c | 1 - src/instrument/line_coverage.c | 5 +---- src/platform/random.c | 3 +-- src/strings/ops.c | 6 ------ src/strings/utf8_c8.c | 1 - 5 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/6model/serialization.c b/src/6model/serialization.c index 395c03d934..2ca9df617c 100644 --- a/src/6model/serialization.c +++ b/src/6model/serialization.c @@ -2208,7 +2208,6 @@ static void resolve_dependencies(MVMThreadContext *tc, MVMSerializationReader *r else { cdesc = ""; } - if (!desc) desc = handle; fail_deserialize(tc, waste, reader, "Missing or wrong version of dependency '%s' (from '%s')", cname, diff --git a/src/instrument/line_coverage.c b/src/instrument/line_coverage.c index f5eb4a4be3..c9b2cf128c 100644 --- a/src/instrument/line_coverage.c +++ b/src/instrument/line_coverage.c @@ -26,7 +26,6 @@ static void instrument_graph_with_breakpoints(MVMThreadContext *tc, MVMSpeshGrap filename_string_index = bbba->filename_string_heap_index; MVM_free(bbba); } else { - line_number = -1; bb = bb->linear_next; continue; } @@ -147,7 +146,6 @@ static void instrument_graph(MVMThreadContext *tc, MVMSpeshGraph *g) { filename_string_index = bbba->filename_string_heap_index; MVM_free(bbba); } else { - line_number = -1; bb = bb->linear_next; continue; } @@ -308,12 +306,11 @@ void MVM_line_coverage_report(MVMThreadContext *tc, MVMString *filename, MVMuint if (tc->instance->coverage_control == 2 || (!tc->instance->coverage_control && cache[cache_slot] == 0)) { char *encoded_filename; char composed_line[256]; - size_t length; cache[cache_slot] = 1; encoded_filename = MVM_string_utf8_encode_C_string(tc, filename); - if ((length = snprintf(composed_line, 255, "HIT %s %d\n", encoded_filename, line_number)) > 0) { + if (snprintf(composed_line, 255, "HIT %s %d\n", encoded_filename, line_number) > 0) { fputs(composed_line, tc->instance->coverage_log_fh); } MVM_free(encoded_filename); diff --git a/src/platform/random.c b/src/platform/random.c index e56c5215b3..da6bdc53ef 100644 --- a/src/platform/random.c +++ b/src/platform/random.c @@ -71,8 +71,7 @@ #include MVMint32 MVM_getrandom_urandom (MVMThreadContext *tc, void *out, size_t size) { int fd = MVM_platform_open("/dev/urandom", O_RDONLY); - ssize_t num_read = 0; - if (fd < 0 || (num_read = read(fd, out, size) <= 0)) { + if (fd < 0 || read(fd, out, size) <= 0) { if (fd) close(fd); /* If using /dev/urandom fails (maybe we're in a chroot), on BSD's * use arc4random, which is likely seeded from the system's random diff --git a/src/strings/ops.c b/src/strings/ops.c index 3d2c198ae5..e414ffa8b3 100644 --- a/src/strings/ops.c +++ b/src/strings/ops.c @@ -2329,9 +2329,6 @@ MVMString * MVM_string_flip(MVMThreadContext *tc, MVMString *s) { while (spos_l < s->body.num_graphs) rbuffer[--rpos_l] = s->body.storage.blob_8[spos_l++]; - spos += sgraphs - spos; - rpos -= sgraphs - spos; - MVMROOT(tc, s, { res = (MVMString *)MVM_repr_alloc_init(tc, tc->instance->VMString); }); @@ -2348,9 +2345,6 @@ MVMString * MVM_string_flip(MVMThreadContext *tc, MVMString *s) { MVM_VECTORIZE_LOOP while (spos_l < s->body.num_graphs) rbuffer[--rpos_l] = s->body.storage.blob_32[spos_l++]; - - spos += sgraphs - spos; - rpos -= sgraphs - spos; } else for (; spos < sgraphs; spos++) diff --git a/src/strings/utf8_c8.c b/src/strings/utf8_c8.c index bacd26ac93..830a106c35 100644 --- a/src/strings/utf8_c8.c +++ b/src/strings/utf8_c8.c @@ -426,7 +426,6 @@ MVMuint32 MVM_string_utf8_c8_decodestream(MVMThreadContext *tc, MVMDecodeStream /* If there's no buffers, we're done. */ if (!ds->bytes_head) return 0; - last_accept_pos = ds->bytes_head_pos; /* If we're asked for zero chars, also done. */ if (stopper_chars && *stopper_chars == 0)