Print errors to stderr

A lot of error reporting used a simple `printf` call which by default
prints to stdout. This was changed so that all error reporting is done
by an `fprintf(stderr, ...)` call.
This commit is contained in:
Nikos Tsipinakis 2017-02-20 17:48:11 +02:00
parent fccdce0819
commit 37628f3dc4
2 changed files with 16 additions and 14 deletions

View File

@ -94,7 +94,7 @@ void handle_method_call(GDBusConnection * connection,
on_get_server_information(connection, sender, parameters, on_get_server_information(connection, sender, parameters,
invocation); invocation);
} else { } else {
printf("WARNING: sender: %s; unknown method_name: %s\n", sender, fprintf(stderr, "WARNING: sender: %s; unknown method_name: %s\n", sender,
method_name); method_name);
} }
} }
@ -354,7 +354,7 @@ static void on_get_server_information(GDBusConnection * connection,
void notification_closed(notification * n, int reason) void notification_closed(notification * n, int reason)
{ {
if (!dbus_conn) { if (!dbus_conn) {
printf("DEBUG: notification_closed but not (yet) connected\n"); fprintf(stderr, "ERROR: notification_closed but not (yet) connected\n");
return; return;
} }
@ -368,7 +368,7 @@ void notification_closed(notification * n, int reason)
"NotificationClosed", body, &err); "NotificationClosed", body, &err);
if (err) { if (err) {
printf("notification_closed ERROR\n"); fprintf(stderr, "notification_closed ERROR\n");
} }
} }
@ -385,7 +385,7 @@ void action_invoked(notification * n, const char *identifier)
"ActionInvoked", body, &err); "ActionInvoked", body, &err);
if (err) { if (err) {
printf("ActionInvoked ERROR\n"); fprintf(stderr, "ActionInvoked ERROR\n");
} }
} }

View File

@ -223,10 +223,10 @@ int load_ini_file(FILE * fp)
if (*start == '[') { if (*start == '[') {
char *end = strchr(start + 1, ']'); char *end = strchr(start + 1, ']');
if (!end) { if (!end) {
printf fprintf(stderr,
("Warning: invalid config file at line %d\n", "Warning: invalid config file at line %d\n",
line_num); line_num);
printf("Missing ']'\n"); fprintf(stderr, "Missing ']'\n");
continue; continue;
} }
@ -241,9 +241,10 @@ int load_ini_file(FILE * fp)
char *equal = strchr(start + 1, '='); char *equal = strchr(start + 1, '=');
if (!equal) { if (!equal) {
printf("Warning: invalid config file at line %d\n", fprintf(stderr,
"Warning: invalid config file at line %d\n",
line_num); line_num);
printf("Missing '='\n"); fprintf(stderr, "Missing '='\n");
continue; continue;
} }
@ -255,10 +256,10 @@ int load_ini_file(FILE * fp)
if (quote) { if (quote) {
char *closing_quote = strchr(quote + 1, '"'); char *closing_quote = strchr(quote + 1, '"');
if (!closing_quote) { if (!closing_quote) {
printf fprintf(stderr,
("Warning: invalid config file at line %d\n", "Warning: invalid config file at line %d\n",
line_num); line_num);
printf("Missing '\"'\n"); fprintf(stderr, "Missing '\"'\n");
continue; continue;
} }
} else { } else {
@ -269,9 +270,10 @@ int load_ini_file(FILE * fp)
value = g_strstrip(value); value = g_strstrip(value);
if (!current_section) { if (!current_section) {
printf("Warning: invalid config file at line: %d\n", fprintf(stderr,
"Warning: invalid config file at line: %d\n",
line_num); line_num);
printf("Key value pair without a section\n"); fprintf(stderr, "Key value pair without a section\n");
continue; continue;
} }