[09/11] misc: syslog: Use static const for AF_UNIX address

Message ID 20210412211113.393120-9-adhemerval.zanella@linaro.org
State New
Headers show
Series
  • [01/11] support: Add xmkfifo
Related show

Commit Message

H.J. Lu via Libc-alpha April 12, 2021, 9:11 p.m.
Checked on x86_64-linux-gnu.
---
 misc/syslog.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

-- 
2.27.0

Comments

Andreas Schwab April 14, 2021, 3:03 p.m. | #1
Ok.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

Patch

diff --git a/misc/syslog.c b/misc/syslog.c
index b595889e1c..be12bcc91d 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -268,7 +268,12 @@  out:
     free (buf);
 }
 
-static struct sockaddr_un SyslogAddr;  /* AF_UNIX address of local logger  */
+/* AF_UNIX address of local logger  */
+static const struct sockaddr_un SyslogAddr =
+  {
+    .sun_family = AF_UNIX,
+    .sun_path = _PATH_LOG
+  };
 
 static void
 openlog_internal (const char *ident, int logstat, int logfac)
@@ -284,9 +289,6 @@  openlog_internal (const char *ident, int logstat, int logfac)
     {
       if (LogFile == -1)
         {
-          SyslogAddr.sun_family = AF_UNIX;
-          strncpy (SyslogAddr.sun_path, _PATH_LOG,
-                   sizeof (SyslogAddr.sun_path));
           if (LogStat & LOG_NDELAY)
             {
               LogFile = __socket (AF_UNIX, LogType | SOCK_CLOEXEC, 0);