Message ID | 20180320075706.6521-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Headers | show |
Series | [v2] notifier: don't initialize socket strucures twice | expand |
On 20/03/2018 08:57, Christian Storm wrote: > struct sockaddr_un notify_server is initialized via addr_init() > at notify_init()'s start and on initialization in notifier_thread(). > As once is sufficient, remove the initialization in notifier_thread(). > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > core/notifier.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/core/notifier.c b/core/notifier.c > index f60eb64..1a79a95 100644 > --- a/core/notifier.c > +++ b/core/notifier.c > @@ -210,8 +210,11 @@ static void addr_init(struct sockaddr_un *addr, const char *path) > { > memset(addr, 0, sizeof(struct sockaddr_un)); > addr->sun_family = AF_UNIX; > + /* > + * Use Linux-specific abstract sockets for this internal interface > + */ > strcpy(&addr->sun_path[1], path); > - addr->sun_path[0] = 0; > + addr->sun_path[0] = '\0'; > } > > /* > @@ -232,14 +235,6 @@ static void *notifier_thread (void __attribute__ ((__unused__)) *data) > fprintf(stderr, "Error creating notifier daemon, exiting."); > exit(2); > } > - memset(¬ify_server, 0, sizeof(notify_server)); > - notify_server.sun_family = AF_UNIX; > - strcpy(notify_server.sun_path, "#NotifyServer"); > - > - /* > - * Use Abstract Socket Address because this is an internal interface > - */ > - notify_server.sun_path[0] = 0; > > if (bind(serverfd, (const struct sockaddr *) ¬ify_server, > sizeof(struct sockaddr_un)) < 0) { > Reviewed-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
diff --git a/core/notifier.c b/core/notifier.c index f60eb64..1a79a95 100644 --- a/core/notifier.c +++ b/core/notifier.c @@ -210,8 +210,11 @@ static void addr_init(struct sockaddr_un *addr, const char *path) { memset(addr, 0, sizeof(struct sockaddr_un)); addr->sun_family = AF_UNIX; + /* + * Use Linux-specific abstract sockets for this internal interface + */ strcpy(&addr->sun_path[1], path); - addr->sun_path[0] = 0; + addr->sun_path[0] = '\0'; } /* @@ -232,14 +235,6 @@ static void *notifier_thread (void __attribute__ ((__unused__)) *data) fprintf(stderr, "Error creating notifier daemon, exiting."); exit(2); } - memset(¬ify_server, 0, sizeof(notify_server)); - notify_server.sun_family = AF_UNIX; - strcpy(notify_server.sun_path, "#NotifyServer"); - - /* - * Use Abstract Socket Address because this is an internal interface - */ - notify_server.sun_path[0] = 0; if (bind(serverfd, (const struct sockaddr *) ¬ify_server, sizeof(struct sockaddr_un)) < 0) {
struct sockaddr_un notify_server is initialized via addr_init() at notify_init()'s start and on initialization in notifier_thread(). As once is sufficient, remove the initialization in notifier_thread(). Signed-off-by: Christian Storm <christian.storm@siemens.com> --- core/notifier.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)