aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMosder <xmosder12@gmail.com>2026-07-23 20:04:32 +0200
committerMosder <xmosder12@gmail.com>2026-07-23 20:04:32 +0200
commit4add8c9c34c48f01de58b3b41e79a768063f7acf (patch)
tree4a6bd52cc14c1b058626dbd76268287af4ba6636
parentf6751b7ed605af54a78156fbaa9194accaa012dc (diff)
feat: redirected runtime errors to stderr
-rw-r--r--analyzer/analyzer.c2
-rw-r--r--analyzer/utils/memory.c8
-rw-r--r--csv_table_gen.c2
3 files changed, 6 insertions, 6 deletions
diff --git a/analyzer/analyzer.c b/analyzer/analyzer.c
index bd24613..aa4a645 100644
--- a/analyzer/analyzer.c
+++ b/analyzer/analyzer.c
@@ -59,7 +59,7 @@ void analyze_file(char *path) {
// handle errors
if (handle == NULL) {
- printf("Couldn't open the specified file:\n%s\n", errbuf);
+ fprintf(stderr, "Couldn't open the specified file:\n%s\n", errbuf);
return;
}
diff --git a/analyzer/utils/memory.c b/analyzer/utils/memory.c
index 0a43bd3..91c5f18 100644
--- a/analyzer/utils/memory.c
+++ b/analyzer/utils/memory.c
@@ -11,12 +11,12 @@ void *safe_malloc(size_t size) {
if (p)
return p;
if (i < MAX_ALLOC_ATTEMPTS - 1) {
- printf("Failed malloc. Retrying in 1s...\n");
+ fprintf(stderr, "Failed malloc. Retrying in 1s...\n");
sleep(1);
}
}
- printf("ERROR: Failed malloc %d times. Exiting...", MAX_ALLOC_ATTEMPTS);
+ fprintf(stderr, "FATAL: Failed malloc %d times. Exiting...", MAX_ALLOC_ATTEMPTS);
exit(EXIT_FAILURE);
}
@@ -29,12 +29,12 @@ void *safe_realloc(void *ptr, size_t size) {
if (p)
return p;
if (i < MAX_ALLOC_ATTEMPTS - 1) {
- printf("Failed realloc. Retrying in 1s...\n");
+ fprintf(stderr, "Failed realloc. Retrying in 1s...\n");
sleep(1);
}
}
- printf("ERROR: Failed realloc %d times. Exiting...", MAX_ALLOC_ATTEMPTS);
+ fprintf(stderr, "FATAL: Failed realloc %d times. Exiting...", MAX_ALLOC_ATTEMPTS);
exit(EXIT_FAILURE);
}
diff --git a/csv_table_gen.c b/csv_table_gen.c
index 0bfd51a..ae80b78 100644
--- a/csv_table_gen.c
+++ b/csv_table_gen.c
@@ -80,7 +80,7 @@ void create_c(char *path, char *h_path, char *from, char *to, char from_to_array
fprintf(fp, "const char *get_%s_from_%s(int %s) {\n", to, from, from);
fprintf(fp, " if (%s >= 0 && %s < %s)\n", from, from, arr_len_name);
fprintf(fp, " return %s[%s];\n", arr_name, from);
- fprintf(fp, " printf(\"%s = %%d is outside of table range [0; %%d]\\n\", %s, %s - 1);\n", from, from, arr_len_name);
+ fprintf(fp, " fprintf(stderr, \"%s = %%d is outside of table range [0; %%d]\\n\", %s, %s - 1);\n", from, from, arr_len_name);
fprintf(fp, " return \"null\";\n");
fprintf(fp, "}");