]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
misc: syslog: Use static const for AF_UNIX address
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Sun, 11 Apr 2021 02:42:12 +0000 (23:42 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Thu, 15 Apr 2021 14:32:40 +0000 (11:32 -0300)
Checked on x86_64-linux-gnu.

misc/syslog.c

index e228860d22fe080aaa09f08b1ed027bbdc5654ec..ee83b1bb7631d3abc1815c0399b9ec629a95d3ad 100644 (file)
@@ -302,8 +302,12 @@ __vsyslog_internal(int pri, const char *fmt, va_list ap,
                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)
@@ -317,9 +321,6 @@ openlog_internal(const char *ident, int logstat, int logfac)
        int retry = 0;
        while (retry < 2) {
                if (LogFile == -1) {
-                       SyslogAddr.sun_family = AF_UNIX;
-                       (void)strncpy(SyslogAddr.sun_path, _PATH_LOG,
-                                     sizeof(SyslogAddr.sun_path));
                        if (LogStat & LOG_NDELAY) {
                          LogFile = __socket(AF_UNIX, LogType | SOCK_CLOEXEC, 0);
                          if (LogFile == -1)