Message ID | 20180319132906.1227-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | notifier: use fprintf() on initialization errors | expand |
On 19/03/2018 14:29, Christian Storm wrote: > On initialization errors, use fprintf() instead of the notifier > system's methods as those are not yet initialized, resulting in > no output on error conditions. > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > core/notifier.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/core/notifier.c b/core/notifier.c > index 14a6052..f60eb64 100644 > --- a/core/notifier.c > +++ b/core/notifier.c > @@ -229,7 +229,7 @@ static void *notifier_thread (void __attribute__ ((__unused__)) *data) > /* Initialize and bind to UDS */ > serverfd = socket(AF_UNIX, SOCK_DGRAM, 0); > if (serverfd < 0) { > - TRACE("Error creating notifier daemon"); > + fprintf(stderr, "Error creating notifier daemon, exiting."); > exit(2); > } > memset(¬ify_server, 0, sizeof(notify_server)); > @@ -243,8 +243,8 @@ static void *notifier_thread (void __attribute__ ((__unused__)) *data) > > if (bind(serverfd, (const struct sockaddr *) ¬ify_server, > sizeof(struct sockaddr_un)) < 0) { > + fprintf(stderr, "Error binding notifier socket: %s, exiting.\n", strerror(errno)); > close(serverfd); > - TRACE("Error bind notifier socket"); > exit(2); > } > > Reviewed-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/core/notifier.c b/core/notifier.c index 14a6052..f60eb64 100644 --- a/core/notifier.c +++ b/core/notifier.c @@ -229,7 +229,7 @@ static void *notifier_thread (void __attribute__ ((__unused__)) *data) /* Initialize and bind to UDS */ serverfd = socket(AF_UNIX, SOCK_DGRAM, 0); if (serverfd < 0) { - TRACE("Error creating notifier daemon"); + fprintf(stderr, "Error creating notifier daemon, exiting."); exit(2); } memset(¬ify_server, 0, sizeof(notify_server)); @@ -243,8 +243,8 @@ static void *notifier_thread (void __attribute__ ((__unused__)) *data) if (bind(serverfd, (const struct sockaddr *) ¬ify_server, sizeof(struct sockaddr_un)) < 0) { + fprintf(stderr, "Error binding notifier socket: %s, exiting.\n", strerror(errno)); close(serverfd); - TRACE("Error bind notifier socket"); exit(2); }
On initialization errors, use fprintf() instead of the notifier system's methods as those are not yet initialized, resulting in no output on error conditions. Signed-off-by: Christian Storm <christian.storm@siemens.com> --- core/notifier.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)