test: a fixture that cannot fail needs no guard
ximbegin took a struct ct* only to USED() it and always returned 1, so its seven `if(!ximbegin(...)) goto cleanup;` call sites tested nothing and three of the cleanup labels they jumped to were unreachable. ibusbegin malloc'd one byte twice so that its two fake DBusConnections would differ by address, then CT_CHECKed the mallocs; two bytes in the fixture are two addresses, and nothing has to be freed. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -398,8 +398,8 @@ struct Freejob
|
||||
Channel *done;
|
||||
};
|
||||
|
||||
static int
|
||||
ximbegin(struct ct *t, Ximfix *f, int lang)
|
||||
static void
|
||||
ximbegin(Ximfix *f, int lang)
|
||||
{
|
||||
Drawcmd dc;
|
||||
|
||||
@@ -410,8 +410,6 @@ ximbegin(struct ct *t, Ximfix *f, int lang)
|
||||
f->oldreply = replyc;
|
||||
replyc = chancreate(sizeof(Keyres), 0);
|
||||
pumpstart(&f->pump, 16);
|
||||
USED(t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -466,8 +464,7 @@ xim_adapter_key_contract(struct ct *t)
|
||||
u32int allmod;
|
||||
|
||||
memset(&state, 0, sizeof state);
|
||||
if(!ximbegin(t, &f, LangJP))
|
||||
goto cleanup;
|
||||
ximbegin(&f, LangJP);
|
||||
allmod = ~0;
|
||||
keypress(&state, 'x', allmod, &res);
|
||||
req = nexttrace(t, &f, Keypress, &state);
|
||||
@@ -487,7 +484,6 @@ xim_adapter_key_contract(struct ct *t)
|
||||
CT_CHECK(t, !res.eaten);
|
||||
checkstr(t, "preedit", "か", &res.commit);
|
||||
checkstr(t, "preedit", "", &res.preedit);
|
||||
cleanup:
|
||||
ximend(&f);
|
||||
}
|
||||
|
||||
@@ -502,8 +498,7 @@ xim_adapter_release_lifecycle(struct ct *t)
|
||||
memset(&a, 0, sizeof a);
|
||||
memset(&b, 0, sizeof b);
|
||||
dead = nil;
|
||||
if(!ximbegin(t, &f, LangJP))
|
||||
goto cleanup;
|
||||
ximbegin(&f, LangJP);
|
||||
keypress(&a, 'k', 0, &res);
|
||||
nexttrace(t, &f, Keypress, &a);
|
||||
keypress(&a, 'a', 0, &res);
|
||||
@@ -580,8 +575,7 @@ xim_adapter_free_waits_for_release(struct ct *t)
|
||||
state = nil;
|
||||
freed = nil;
|
||||
workeractive = 0;
|
||||
if(!ximbegin(t, &f, LangJP))
|
||||
goto cleanup;
|
||||
ximbegin(&f, LangJP);
|
||||
state = calloc(1, sizeof *state);
|
||||
freed = chancreate(sizeof(uchar), 0);
|
||||
if(!CT_CHECK(t, state != nil && freed != nil))
|
||||
@@ -736,8 +730,7 @@ xim_adapter_placement_updates(struct ct *t)
|
||||
ic = (xcb_im_input_context_t*)(uintptr)71;
|
||||
memset(&state, 0, sizeof state);
|
||||
oldstate = kstate;
|
||||
if(!ximbegin(t, &f, LangJP))
|
||||
goto cleanup;
|
||||
ximbegin(&f, LangJP);
|
||||
kstate = testkeystate("us");
|
||||
if(!CT_CHECK(t, kstate != nil))
|
||||
goto cleanup;
|
||||
@@ -891,8 +884,7 @@ xim_adapter_callback_cleanup(struct ct *t)
|
||||
|
||||
ic = (xcb_im_input_context_t*)(uintptr)29;
|
||||
memset(&state, 0, sizeof state);
|
||||
if(!ximbegin(t, &f, LangJP))
|
||||
return;
|
||||
ximbegin(&f, LangJP);
|
||||
wireclear();
|
||||
wirebind(0, ic, &state);
|
||||
state.xic = ic;
|
||||
@@ -980,8 +972,7 @@ xim_adapter_callback_transfer(struct ct *t)
|
||||
aic = (xcb_im_input_context_t*)(uintptr)50;
|
||||
memset(&a, 0, sizeof a);
|
||||
memset(&b, 0, sizeof b);
|
||||
if(!ximbegin(t, &f, LangJP))
|
||||
goto cleanup;
|
||||
ximbegin(&f, LangJP);
|
||||
wireclear();
|
||||
a.xic = aic;
|
||||
a.clientpre = 1;
|
||||
@@ -996,7 +987,6 @@ xim_adapter_callback_transfer(struct ct *t)
|
||||
CT_EQ_PTR(t, nil, preowner);
|
||||
release(&b);
|
||||
nexttrace(t, &f, Keyrelease, &b);
|
||||
cleanup:
|
||||
preowner = nil;
|
||||
ximend(&f);
|
||||
}
|
||||
@@ -1016,8 +1006,7 @@ xim_adapter_callback_owner_loss(struct ct *t)
|
||||
ic = (xcb_im_input_context_t*)(uintptr)51;
|
||||
memset(&state, 0, sizeof state);
|
||||
foreign = 0;
|
||||
if(!ximbegin(t, &f, LangJP))
|
||||
goto cleanup;
|
||||
ximbegin(&f, LangJP);
|
||||
wireclear();
|
||||
wirebind(0, ic, &state);
|
||||
state.xic = ic;
|
||||
@@ -1086,7 +1075,6 @@ xim_adapter_callback_owner_loss(struct ct *t)
|
||||
CT_CHECK(t, channbrecv(f.pump.trace, &trace) > 0);
|
||||
CT_EQ_INT(t, Keyrelease, trace.op);
|
||||
CT_EQ_PTR(t, &foreign, trace.owner);
|
||||
cleanup:
|
||||
preowner = nil;
|
||||
ximend(&f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user