Patchwork [10/25] Swap sys/syslog.h with syslog.h.

login
register
mail settings
Submitter Zack Weinberg
Date June 26, 2019, 5:50 p.m.
Message ID <20190626175029.4699-1-zackw@panix.com>
Download mbox | patch
Permalink /patch/33427/
State New
Headers show

Comments

Zack Weinberg - June 26, 2019, 5:50 p.m.
Our installed syslog.h is a trivial wrapper around sys/syslog.h, which
is where all the actual declarations are.  This is backward from
POSIX, which specifies syslog.h and its contents, and does not specify
sys/syslog.h.  This arrangement appears to have been inherited from
some BSD-phylum C library, and probably pre-dates any standardization
of syslog.

This patch swaps the contents of syslog.h and sys/syslog.h, so that
the actual declarations appear under the standardized name.  Since it
is necessary to adjust all of syslog.h’s bits headers, I also added
multiple-include guards to those files that didn’t already have
them.  (All installed headers should have multiple-include guards,
even if they are internal and only used in one public header.  The
“never include this file directly” #error convention doesn’t protect
against including the internal header a second time after its parent
header has already been included.)

	* misc/sys/syslog.h: Exchange contents with...
	* misc/syslog.h: ...this file.  Adjust multiple-include guards.

	* include/sys/syslog.h: Exchange contents with...
	* include/syslog.h: ...this file.  Adjust multiple-include guards.

	* bits/syslog-path.h, misc/bits/syslog-ldbl.h
	* misc/bits/syslog.h: Allow inclusion by syslog.h, not sys/syslog.h.
	Add multiple-include guard where not already present.

	* scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES):
        Update.
---
 bits/syslog-path.h                   |   8 +-
 include/sys/syslog.h                 |  19 +--
 include/{sys => }/syslog.h           |   5 +-
 misc/bits/syslog-ldbl.h              |   9 +-
 misc/bits/syslog.h                   |   9 +-
 misc/sys/syslog.h                    | 218 +--------------------------
 misc/{sys => }/syslog.h              |   4 +-
 scripts/check-obsolete-constructs.py |   2 +-
 8 files changed, 29 insertions(+), 245 deletions(-)
 rewrite include/sys/syslog.h (93%)
 copy include/{sys => }/syslog.h (81%)
 rewrite misc/sys/syslog.h (99%)
 copy misc/{sys => }/syslog.h (99%)

Patch

diff --git a/bits/syslog-path.h b/bits/syslog-path.h
index 5b97fa7db5..5677f468b5 100644
--- a/bits/syslog-path.h
+++ b/bits/syslog-path.h
@@ -16,13 +16,13 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _SYS_SYSLOG_H
-# error "Never include this file directly.  Use <sys/syslog.h> instead"
-#endif
-
 #ifndef _BITS_SYSLOG_PATH_H
 #define _BITS_SYSLOG_PATH_H 1
 
+#ifndef _SYSLOG_H
+# error "Never include <bits/syslog-path.h> directly.  Use <syslog.h> instead"
+#endif
+
 #define	_PATH_LOG	"/dev/log"
 
 #endif /* bits/syslog-path.h */
diff --git a/include/sys/syslog.h b/include/sys/syslog.h
dissimilarity index 93%
index 89d3479ebc..7d6e3bc46c 100644
--- a/include/sys/syslog.h
+++ b/include/sys/syslog.h
@@ -?,? +1,3 @@
+#ifndef _SYSLOG_H
+#include <misc/sys/syslog.h>
+#endif
diff --git a/include/sys/syslog.h b/include/syslog.h
similarity index 81%
copy from include/sys/syslog.h
copy to include/syslog.h
index 89d3479ebc..5dc6e76b7e 100644
--- a/include/sys/syslog.h
+++ b/include/syslog.h
@@ -1,6 +1,5 @@ 
-#ifndef _LIBC_SYS_SYSLOG_H
-#define _LIBC_SYS_SYSLOG_H 1
-#include <misc/sys/syslog.h>
+#ifndef _SYSLOG_H
+# include <misc/syslog.h>
 #ifndef _ISOMAC
 
 libc_hidden_proto (syslog)
diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h
index e3117552ae..4c2eea74e6 100644
--- a/misc/bits/syslog-ldbl.h
+++ b/misc/bits/syslog-ldbl.h
@@ -16,8 +16,11 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _SYS_SYSLOG_H
-# error "Never include <bits/syslog-ldbl.h> directly; use <sys/syslog.h> instead."
+#ifndef _BITS_SYSLOG_LDBL_H
+#define _BITS_SYSLOG_LDBL_H 1
+
+#ifndef _SYSLOG_H
+# error "Never include <bits/syslog-ldbl.h> directly; use <syslog.h> instead."
 #endif
 
 __LDBL_REDIR_DECL (syslog)
@@ -33,3 +36,5 @@  __LDBL_REDIR_DECL (__syslog_chk)
 __LDBL_REDIR_DECL (__vsyslog_chk)
 # endif
 #endif
+
+#endif /* bits/syslog-ldbl.h */
diff --git a/misc/bits/syslog.h b/misc/bits/syslog.h
index 86d94536ee..e796955c1c 100644
--- a/misc/bits/syslog.h
+++ b/misc/bits/syslog.h
@@ -16,8 +16,11 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef _SYS_SYSLOG_H
-# error "Never include <bits/syslog.h> directly; use <sys/syslog.h> instead."
+#ifndef _BITS_SYSLOG_H
+#define _BITS_SYSLOG_H 1
+
+#ifndef _SYSLOG_H
+# error "Never include <bits/syslog.h> directly; use <syslog.h> instead."
 #endif
 
 
@@ -47,3 +50,5 @@  vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
   __vsyslog_chk (__pri,  __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
 }
 #endif
+
+#endif /* bits/syslog.h */
diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h
dissimilarity index 99%
index ee01478c4b..9fc15930fb 100644
--- a/misc/sys/syslog.h
+++ b/misc/sys/syslog.h
@@ -?,? +1,3 @@
+#ifndef _SYSLOG_H
+# include <syslog.h>
+#endif
diff --git a/misc/sys/syslog.h b/misc/syslog.h
similarity index 99%
copy from misc/sys/syslog.h
copy to misc/syslog.h
index ee01478c4b..406133ba71 100644
--- a/misc/sys/syslog.h
+++ b/misc/syslog.h
@@ -29,8 +29,8 @@ 
  *	@(#)syslog.h	8.1 (Berkeley) 6/2/93
  */
 
-#ifndef _SYS_SYSLOG_H
-#define _SYS_SYSLOG_H 1
+#ifndef _SYSLOG_H
+#define _SYSLOG_H 1
 
 #include <features.h>
 #define __need___va_list
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 5efe824b8d..c437c8e00b 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -635,12 +635,12 @@  HEADER_ALLOWED_INCLUDES = {
     "memory.h":                    [ "string.h" ],
     "poll.h":                      [ "sys/poll.h" ],
     "re_comp.h":                   [ "regex.h" ],
-    "syslog.h":                    [ "sys/syslog.h" ],
     "sys/bitypes.h":               [ "sys/types.h" ],
     "sys/dir.h":                   [ "dirent.h" ],
     "sys/errno.h":                 [ "errno.h" ],
     "sys/fcntl.h":                 [ "fcntl.h" ],
     "sys/signal.h":                [ "signal.h" ],
+    "sys/syslog.h":                [ "syslog.h" ],
     "sys/termios.h":               [ "termios.h" ],
     "sys/unistd.h":                [ "unistd.h" ],
     "syscall.h":                   [ "sys/syscall.h" ],