diff options
author | EuAndreh <eu@euandre.org> | 2024-04-06 11:37:04 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-04-06 11:37:04 -0300 |
commit | 3b32f5a1abbec9655a93a184ed0a3c5e6e5134fd (patch) | |
tree | 03969b7b76835f2507ccd1a8aeb057bb1d7f7201 /tests/slurp.c | |
parent | src/: Remove unused "infallible" tag (diff) | |
download | pindaiba-3b32f5a1abbec9655a93a184ed0a3c5e6e5134fd.tar.gz pindaiba-3b32f5a1abbec9655a93a184ed0a3c5e6e5134fd.tar.xz |
Start "rc = -1" instead of 0
Diffstat (limited to 'tests/slurp.c')
-rw-r--r-- | tests/slurp.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/tests/slurp.c b/tests/slurp.c index 7b5936f..6ea8618 100644 --- a/tests/slurp.c +++ b/tests/slurp.c @@ -7,7 +7,7 @@ int slurp_for_tests(const char *const FNAME, char **strref) { - int rc = 0; + int rc = -1; FILE *file = NULL; char *str = NULL; @@ -15,45 +15,40 @@ slurp_for_tests(const char *const FNAME, char **strref) { file = fopen(FNAME, "r"); if (!file) { perror("fopen(FNAME, \"r\")"); - rc = -1; goto out; } if (fseek(file, 0L, SEEK_END)) { perror("fseek(file, 0L, SEEK_END)"); - rc = -1; goto out; } const long lsize = ftell(file); if (lsize == -1) { perror("ftell(file)"); - rc = -1; goto out; } const size_t size = (size_t)lsize + sizeof(char); if (fseek(file, 0L, SEEK_SET)) { perror("fseek(file, 0L, SEEK_SET)"); - rc = -1; goto out; } str = malloc(size); if (!str) { perror("malloc(...)"); - rc = -1; goto out; } if (fread(str, sizeof(char), size - 1, file) != size - 1) { perror("fread(...)"); - rc = -1; goto out; } str[size - 1] = '\0'; *strref = str; + rc = 0; out: if (file) { if (fclose(file)) { |