simplications suggested by scan-build

This commit is contained in:
Matthew Flatt 2020-05-09 12:04:41 -06:00
parent 7fc0dc36d1
commit 60bf8f970e
8 changed files with 24 additions and 30 deletions

View File

@ -142,8 +142,6 @@ static void configure_environment(Scheme_Object *mod)
Scheme_Object *mli, *dyreq, *a[3], *gi, *v, *vs;
Scheme_Object *submod, *cr, *mdp, *mpij;
cr = scheme_intern_symbol("configure-runtime");
/* Modern style: look for `runtime-configure' submodule to initialize
the configuration: */
@ -1154,7 +1152,6 @@ static int run_from_cmd_line(int argc, char *_argv[],
} else {
/* No switches => -u mode */
script_mode = 1;
no_more_switches = 1;
sprog = argv[0];
evals_and_loads[num_enl] = argv[0];
eval_kind[num_enl++] = mzcmd_REQUIRE_FILE;

View File

@ -1010,7 +1010,7 @@ static AllocCacheBlock *alloc_cache;
static void *platform_plain_sector(int count, int executable)
{
intptr_t sd;
intptr_t sd = 0;
if (executable)
return mmap_sector(count, 1);

View File

@ -926,7 +926,7 @@ static Scheme_Object *do_bitop(const Scheme_Object *a, const Scheme_Object *b, i
intptr_t a_size, b_size, a_pos, b_pos, res_alloc, i;
short res_pos;
bigdig* a_digs, *b_digs, *res_digs, quick_digs[1];
int carry_out_a, carry_out_b, carry_out_res, carry_in_a, carry_in_b, carry_in_res;
int carry_out_a, carry_out_b, carry_out_res, carry_in_b, carry_in_res;
Scheme_Object* o;
SAFE_SPACE(asd) SAFE_SPACE(bsd)
@ -972,7 +972,7 @@ static Scheme_Object *do_bitop(const Scheme_Object *a, const Scheme_Object *b, i
res_digs = allocate_bigdig_array(res_alloc);
carry_out_a = carry_out_b = carry_out_res = 1;
carry_in_a = carry_in_b = carry_in_res = 0;
carry_in_b = carry_in_res = 0;
for (i = 0; i < res_alloc; ++i)
{
@ -981,8 +981,8 @@ static Scheme_Object *do_bitop(const Scheme_Object *a, const Scheme_Object *b, i
a_val = a_digs[i];
if (!a_pos)
{
/* We have to do te operation on the 2's complement of a */
carry_in_a = carry_out_a;
/* We have to do the operation on the 2's complement of a */
int carry_in_a = carry_out_a;
carry_out_a = (carry_in_a == 1 && a_val == 0) ? 1 : 0;
a_val = ~a_val + carry_in_a;
}

View File

@ -3399,7 +3399,7 @@ static Scheme_Object *do_chaperone_procedure(const char *name, const char *whati
int argc, Scheme_Object *argv[], int is_unsafe)
{
Scheme_Chaperone *px, *px2;
Scheme_Object *val = argv[0], *orig, *naya, *r, *app_mark;
Scheme_Object *val = argv[0], *orig, *r, *app_mark;
Scheme_Object *props;
if (SCHEME_CHAPERONEP(val))
@ -3416,9 +3416,8 @@ static Scheme_Object *do_chaperone_procedure(const char *name, const char *whati
}
orig = get_or_check_arity(val, -1, NULL, 1);
if (SCHEME_FALSEP(argv[1]))
naya = scheme_false;
else {
if (!SCHEME_FALSEP(argv[1])) {
Scheme_Object *naya;
naya = get_or_check_arity(argv[1], -1, NULL, 1);
if (!is_subarity(orig, naya, pass_self ? 1 : 0))
@ -8763,13 +8762,9 @@ static Scheme_Object *get_set_cont_mark_by_pos(Scheme_Object *key,
bottom = 0;
} else {
startpos = (intptr_t)MZ_CONT_MARK_STACK;
if (!p->cont_mark_stack_segments)
findpos = 0;
bottom = p->cont_mark_stack_bottom;
}
findpos = startpos;
/* binary search: */
while (bottom < startpos) {
findpos = ((bottom + startpos) / 2) - down_delta;

View File

@ -2948,8 +2948,8 @@ void scheme_wrong_contract_from_ft(const char *who, const char *expected_type, i
future->source_of_request = who;
future_do_runtimecall(fts, NULL, 0, 1, 0);
/* Fetch the future again, in case moved by a GC */
future = fts->thread->current_ft;
/* If more: fetch the future again, in case moved by a GC */
/* future = fts->thread->current_ft; */
}
Scheme_Object **scheme_rtcall_on_demand(Scheme_Object **argv)

View File

@ -100,7 +100,7 @@
@(if (equal? arg-types '("Scheme_Object*")) @string-append{send_special_result(future, @(car arg-names));} "")
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@(if (string=? result-type "void") "" @string-append{future = fts->thread->current_ft;})
@(if (string=? result-type "void") "" @string-append{retval = @|fretval|;})
@(if (string=? result-type "void") "" @string-append{@|fretval| = 0;})
@(if (string=? result-type "Scheme_Object*") @string-append{receive_special_result(future, retval, 1);} "")

View File

@ -304,7 +304,7 @@
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@ -331,7 +331,7 @@
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@ -357,7 +357,7 @@
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@ -382,7 +382,7 @@
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@ -484,7 +484,7 @@
send_special_result(future, g272);
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@ -538,7 +538,7 @@
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@ -643,7 +643,7 @@
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@ -696,7 +696,7 @@
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@ -748,7 +748,7 @@
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;
@ -774,7 +774,7 @@
future_do_runtimecall(fts, (void*)f, 0, 1, 0);
fts->thread = scheme_current_thread;
future = fts->thread->current_ft;

View File

@ -516,8 +516,10 @@ static rktio_addrinfo_lookup_t *start_lookup(rktio_t *rktio, rktio_addrinfo_look
if (!rktio->ghbn_started) {
rktio->ghbn_run = 1;
if (!ghbn_init(rktio))
if (!ghbn_init(rktio)) {
free_lookup(lookup);
return NULL;
}
rktio->ghbn_started = 1;
}