Skip to content

Commit 253b3d3

Browse files
committed
refactor: modify usage function to return exit code instead of calling exit for MSVC compatibility
1 parent 183e69f commit 253b3d3

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

tools/arkilian-dlq.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
#include <string.h>
2525
#include "sqlite3.h"
2626

27-
static void usage(void) {
27+
// Returns the usage exit code (2); does not exit() — callers propagate the
28+
// return value so MSVC sees the code path as reachable (no C4702).
29+
static int usage(void) {
2830
fprintf(stderr,
2931
"usage: arkilian-dlq <db.sqlite> --count\n"
3032
" arkilian-dlq <db.sqlite> --list [--limit N] [--id N]\n"
3133
" arkilian-dlq <db.sqlite> --replay [--id N] [--dry-run]\n");
32-
exit(2);
34+
return 2;
3335
}
3436

3537
static int open_db(const char *path, sqlite3 **db, int readonly) {
@@ -192,7 +194,7 @@ static int cmd_replay(const char *path, long long only_id, int dry_run) {
192194
}
193195

194196
int main(int argc, char **argv) {
195-
if (argc < 3) usage();
197+
if (argc < 3) return usage();
196198
const char *path = argv[1];
197199
const char *cmd = argv[2];
198200
int limit = 0;
@@ -203,12 +205,11 @@ int main(int argc, char **argv) {
203205
if (strcmp(argv[i], "--limit") == 0 && i + 1 < argc) limit = atoi(argv[++i]);
204206
else if (strcmp(argv[i], "--id") == 0 && i + 1 < argc) only_id = atoll(argv[++i]);
205207
else if (strcmp(argv[i], "--dry-run") == 0) dry_run = 1;
206-
else usage();
208+
else return usage();
207209
}
208210

209211
if (strcmp(cmd, "--count") == 0) return cmd_count(path);
210212
if (strcmp(cmd, "--list") == 0) return cmd_list(path, limit, only_id);
211213
if (strcmp(cmd, "--replay") == 0) return cmd_replay(path, only_id, dry_run);
212-
usage();
213-
return 2;
214+
return usage();
214215
}

0 commit comments

Comments
 (0)