diff options
| author | Onur Gündüz <ogunduz@gmail.com> | 2026-06-10 13:26:34 +0200 |
|---|---|---|
| committer | Onur Gündüz <ogunduz@gmail.com> | 2026-06-14 08:27:03 +0200 |
| commit | 6761987b0e2f28391836521b2342e0422ec0c3c6 (patch) | |
| tree | 5660affe9234d1db99a59f25207c6b8ce60fcfbf /tests | |
| parent | c7a7a30219dbb61d7c378d2c123ebaf58a5541b9 (diff) | |
| download | ffwd-6761987b0e2f28391836521b2342e0422ec0c3c6.tar.gz ffwd-6761987b0e2f28391836521b2342e0422ec0c3c6.zip | |
tests: fix goto-over-initialization cleanup in test_workspace, analyze tests in gate
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_workspace.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tests/test_workspace.c b/tests/test_workspace.c index 7a6ed03..ef5c68c 100644 --- a/tests/test_workspace.c +++ b/tests/test_workspace.c @@ -74,12 +74,6 @@ int main(int argc, char **argv) return 1; } - size_t initial_ws_bytes = pplx_workspace_nbytes(batch_ws); - if (initial_ws_bytes == 0) { - fprintf(stderr, "workspace byte accounting returned zero\n"); - goto fail; - } - const char *texts[] = { "query: what is the capital of France?", "document: Paris is the capital of France.", @@ -87,10 +81,18 @@ int main(int argc, char **argv) "document: Istanbul is a major city in Turkey." }; const int batch = (int)(sizeof(texts) / sizeof(texts[0])); + /* Initialized before the first `goto fail` so the cleanup loop never + * sees indeterminate pointers. */ int *ids[4] = {0}; int ntok[4] = {0}; pplx_input_t inputs[4]; + size_t initial_ws_bytes = pplx_workspace_nbytes(batch_ws); + if (initial_ws_bytes == 0) { + fprintf(stderr, "workspace byte accounting returned zero\n"); + goto fail; + } + for (int i = 0; i < batch; i++) { ids[i] = qwen_tokenizer_encode(tok, texts[i], &ntok[i]); if (!ids[i] || ntok[i] <= 0) { |
