Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove useless assignments/variables detected by clang/clang-tidy #2914

Merged
merged 2 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ static block block_bind(block binder, block body, int bindflags) {

block block_bind_library(block binder, block body, int bindflags, const char *libname) {
bindflags |= OP_HAS_BINDING;
int nrefs = 0;
int matchlen = (libname == NULL) ? 0 : strlen(libname);
char *matchname = jv_mem_alloc(matchlen+2+1);
matchname[0] = '\0';
Expand All @@ -395,7 +394,7 @@ block block_bind_library(block binder, block body, int bindflags, const char *li

// This mutation is ugly, even if we undo it
curr->symbol = tname;
nrefs += block_bind_subblock(inst_block(curr), body, bindflags2, 0);
block_bind_subblock(inst_block(curr), body, bindflags2, 0);
curr->symbol = cname;
free(tname);
}
Expand Down
2 changes: 1 addition & 1 deletion src/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ int jq_compile_args(jq_state *jq, const char* str, jv args) {
if (nerrors == 0) {
nerrors = builtins_bind(jq, &program);
if (nerrors == 0) {
nerrors = block_compile(program, &jq->bc, locations, args = args2obj(args));
nerrors = block_compile(program, &jq->bc, locations, args2obj(args));
}
} else
jv_free(args);
Expand Down
1 change: 0 additions & 1 deletion src/jq_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ static void run_jq_tests(jv lib_dirs, int verbose, FILE *testdata, int skip, int
take--;
} else if (take == 0) {
printf("Hit the number of tests limit (%d), breaking\n", tests_to_take);
take = -1;
break;
}

Expand Down
3 changes: 1 addition & 2 deletions src/jv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,14 +1080,13 @@ static jvp_string* jvp_string_alloc(uint32_t size) {
static jv jvp_string_copy_replace_bad(const char* data, uint32_t length) {
const char* end = data + length;
const char* i = data;
const char* cstart;

uint32_t maxlength = length * 3 + 1; // worst case: all bad bytes, each becomes a 3-byte U+FFFD
jvp_string* s = jvp_string_alloc(maxlength);
char* out = s->data;
int c = 0;

while ((i = jvp_utf8_next((cstart = i), end, &c))) {
while ((i = jvp_utf8_next(i, end, &c))) {
if (c == -1) {
c = 0xFFFD; // U+FFFD REPLACEMENT CHARACTER
}
Expand Down
2 changes: 1 addition & 1 deletion src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static int jq_util_input_read_more(jq_util_input_state *state) {
* terminating '\0'. This only works because we previously memset our
* buffer with something nonzero.
*/
for (p = state->buf, i = sizeof(state->buf) - 1; i > 0; i--) {
for (i = sizeof(state->buf) - 1; i > 0; i--) {
if (state->buf[i] == '\0')
break;
}
Expand Down