Open elfring opened 1 year ago
How do you think about to integrate the following change possibilities besides further source code adjustments? :thinking:
diff --git a/ui/report.c b/ui/report.c
index 9301480..15f6767 100644
--- a/ui/report.c
+++ b/ui/report.c
@@ -45,6 +45,12 @@
#define MAXLOADBAL 5
#define MAX_FORMAT_STR 320
+#define LINE_BREAK_OUTPUT \
+ if (putchar('\n') != '\n') { \
+ perror("Output failed for a line break"); \
+ exit(EXIT_FAILURE); \
+ }
+
void report_open(
void)
@@ -385,7 +391,8 @@ void json_close(struct mtr_ctl *ctl)
if (ret == -1)
goto on_error;
- printf("\n"); // bash prompt should be on new line
+ // bash prompt should be on new line
+ LINE_BREAK_OUTPUT
json_decref(jreport);
return;
on_error:
@@ -500,7 +507,8 @@ void csv_close(
continue;
printf("%s,", data_fields[j].title);
}
- printf("\n");
+
+ LINE_BREAK_OUTPUT
}
#ifdef HAVE_IPINFO
if (!ctl->ipinfo_no) {
@@ -527,7 +535,9 @@ void csv_close(
printf(",%d", data_fields[j].net_xxx(at));
}
}
- printf("\n");
+
+ LINE_BREAK_OUTPUT
+
if (ctl->reportwide == 0)
continue;
@@ -580,7 +590,8 @@ void csv_close(
printf(",%d", data_fields[j].net_xxx(at));
}
}
- printf("\n");
+
+ LINE_BREAK_OUTPUT
}
}
}
Would you like to add more error handling for return values from functions like the following?