commit af1c53e3ad9d28bdce9efff97036f75bd3363834
parent 2107427f4eb88e07afb9b1b3c9775c6d172668ab
Author: Andreas Gruhler <andreas.gruhler@adfinis.com>
Date: Sat, 22 Jun 2024 09:18:54 +0200
feat: improve error handling
Diffstat:
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/diary.c b/src/diary.c
@@ -825,7 +825,10 @@ int main(int argc, char** argv) {
mousemask(oldmask, NULL);
}
- system(ecmd);
+ int ret = system(ecmd);
+ if (ret == -1) {
+ perror("Failure while running edit command in main()");
+ }
if (!CONFIG.no_mouse) {
mousemask(ALL_MOUSE_EVENTS, &oldmask);
@@ -939,6 +942,9 @@ int main(int argc, char** argv) {
free(config_file_path);
free(CONFIG.dir);
endwin();
- system("clear");
+ int ret = system("clear");
+ if (ret == -1) {
+ perror("Failure while running clear command in main()");
+ }
return 0;
}
diff --git a/src/import.c b/src/import.c
@@ -16,10 +16,10 @@ void ics_import(const char* ics_input, WINDOW* header, WINDOW* cal, WINDOW* asid
char* ics = malloc(ics_bytes + 1);
size_t read = fread(ics, 1, ics_bytes, pfile);
- if (read < ics_bytes) {
+ if (read != ics_bytes) {
perror("Error while reading in ics_import()");
fclose(pfile);
- return;
+ return;
}
fclose(pfile);