On Wednesday 11 June 2008 14:25, Bernhard Fischer wrote:
> On Thu, Jun 05, 2008 at 07:44:10PM -0700, [EMAIL PROTECTED] wrote:
> >Author: vda
> >Date: 2008-06-05 19:44:10 -0700 (Thu, 05 Jun 2008)
> >New Revision: 22241
> >
> >Log:
> >Heed a warning: "string" was assigned to char*, changing that to const char*
> >
...
> 
> In file included from
> /there.pentium4/build_i686/staging_dir/usr/include/syslog.h:1,
>                  from sysklogd/syslogd.c:19:
> /there.pentium4/build_i686/staging_dir/usr/include/sys/syslog.h:77:
> error: conflicting types for 'prioritynames'
> sysklogd/logger.c:30: error: previous declaration of 'prioritynames' was
> here
> /there.pentium4/build_i686/staging_dir/usr/include/sys/syslog.h:128:
> error: conflicting types for 'facilitynames'
> sysklogd/logger.c:31: error: previous declaration of 'facilitynames' was
> here
> make[1]: *** [busybox_unstripped.o] Error 1
> 
> Please fix busybox/sysklogd/logger.c accordingly and make sure that this
> works when compiling against the 0.9.29 release (which doesn't have the
> change above).


Done.

I see why this sysklogd/logger.c hack was necessary, but
there is a cleaner way out of this mess. Not pretty,
but at least it does not attempt to redeclare a structure
to match libc's one...

Can you confirm that attached patch works for you?
--
vda
diff -d -urpN busybox.8/sysklogd/Kbuild busybox.9/sysklogd/Kbuild
--- busybox.8/sysklogd/Kbuild	2008-06-07 06:25:53.000000000 +0200
+++ busybox.9/sysklogd/Kbuild	2008-06-11 17:13:40.000000000 +0200
@@ -6,6 +6,6 @@
 
 lib-y:=
 lib-$(CONFIG_KLOGD)		+= klogd.o
-lib-$(CONFIG_LOGGER)		+= logger.o
+lib-$(CONFIG_LOGGER)		+= syslogd_and_logger.o
 lib-$(CONFIG_LOGREAD)		+= logread.o
-lib-$(CONFIG_SYSLOGD)		+= syslogd.o
+lib-$(CONFIG_SYSLOGD)		+= syslogd_and_logger.o
diff -d -urpN busybox.8/sysklogd/logger.c busybox.9/sysklogd/logger.c
--- busybox.8/sysklogd/logger.c	2008-06-07 06:25:53.000000000 +0200
+++ busybox.9/sysklogd/logger.c	2008-06-11 17:11:17.000000000 +0200
@@ -7,34 +7,13 @@
  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  */
 
+/*
+ * Done in syslogd_and_logger.c:
 #include "libbb.h"
-#ifndef CONFIG_SYSLOGD
 #define SYSLOG_NAMES
 #define SYSLOG_NAMES_CONST
 #include <syslog.h>
-#else
-/* brokenness alert. Everybody except dietlibc get's this wrong by neither
- * providing a typedef nor an extern for facilitynames and prioritynames
- * in syslog.h.
- */
-# include <syslog.h>
-# ifndef __dietlibc__
-/* We have to do this since the header file does neither provide a sane type
- * for this structure nor extern definitions.  Argh.... bad libc, bad, bad...
- */
-typedef struct _code {
-	char *c_name; /* FIXME: this should be const char *const c_name ! */
-	int c_val;
-} CODE;
-#  ifdef __UCLIBC__
-extern const CODE prioritynames[];
-extern const CODE facilitynames[];
-#  else
-extern CODE prioritynames[];
-extern CODE facilitynames[];
-#  endif
-# endif
-#endif
+*/
 
 /* Decode a symbolic name to a numeric value
  * this function is based on code
@@ -137,6 +116,7 @@ int logger_main(int argc, char **argv)
 
 	closelog();
 	return EXIT_SUCCESS;
+#undef strbuf
 }
 
 
diff -d -urpN busybox.8/sysklogd/logread.c busybox.9/sysklogd/logread.c
--- busybox.8/sysklogd/logread.c	2008-06-07 06:25:53.000000000 +0200
+++ busybox.9/sysklogd/logread.c	2008-06-11 17:09:51.000000000 +0200
@@ -16,6 +16,7 @@
 
 #define DEBUG 0
 
+/* our shared key (syslogd.c and logread.c must be in sync) */
 enum { KEY_ID = 0x414e4547 }; /* "GENA" */
 
 struct shbuf_ds {
diff -d -urpN busybox.8/sysklogd/syslogd_and_logger.c busybox.9/sysklogd/syslogd_and_logger.c
--- busybox.8/sysklogd/syslogd_and_logger.c	1970-01-01 01:00:00.000000000 +0100
+++ busybox.9/sysklogd/syslogd_and_logger.c	2008-06-11 17:14:00.000000000 +0200
@@ -0,0 +1,51 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * prioritynames[] and facilitynames[]
+ *
+ * Copyright (C) 2008 by Denys Vlasenko <[EMAIL PROTECTED]>
+ *
+ * Licensed under GPLv2, see file LICENSE in this tarball for details.
+ */
+
+#include "libbb.h"
+#define SYSLOG_NAMES
+#define SYSLOG_NAMES_CONST
+#include <syslog.h>
+
+#if 0
+/* For the record: with SYSLOG_NAMES <syslog.h> defines
+ * (not declares) the following:
+ */
+typedef struct _code {
+	/*const*/ char *c_name;
+	int c_val;
+} CODE;
+/*const*/ CODE prioritynames[] = {
+    { "alert", LOG_ALERT },
+...
+    { NULL, -1 }
+};
+/* same for facilitynames[] */
+
+/* This MUST occur only once per entire executable,
+ * therefore we can't just do it in syslogd.c and logger.c -
+ * there will be two copies of it.
+ *
+ * We cannot even do it in separate file and then just reference
+ * prioritynames[] from syslogd.c and logger.c - bare <syslog.h>
+ * will not emit extern decls for prioritynames[]! Attempts to
+ * emit "matching" struct _code declaration defeat the whole purpose
+ * of <syslog.h>.
+ *
+ * For now, syslogd.c and logger.c are simply compiled into
+ * one object file.
+ */
+#endif
+
+#if ENABLE_SYSLOGD
+#include "syslogd.c"
+#endif
+
+#if ENABLE_LOGGER
+#include "logger.c"
+#endif
diff -d -urpN busybox.8/sysklogd/syslogd.c busybox.9/sysklogd/syslogd.c
--- busybox.8/sysklogd/syslogd.c	2008-06-07 06:25:53.000000000 +0200
+++ busybox.9/sysklogd/syslogd.c	2008-06-11 17:14:37.000000000 +0200
@@ -13,10 +13,13 @@
  * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
  */
 
+/*
+ * Done in syslogd_and_logger.c:
 #include "libbb.h"
 #define SYSLOG_NAMES
 #define SYSLOG_NAMES_CONST
 #include <syslog.h>
+*/
 
 #include <paths.h>
 #include <sys/un.h>
@@ -192,8 +195,8 @@ enum {
 #error Please check CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE
 #endif
 
-/* our shared key */
-#define KEY_ID ((long)0x414e4547) /* "GENA" */
+/* our shared key (syslogd.c and logread.c must be in sync) */
+enum { KEY_ID = 0x414e4547 }; /* "GENA" */
 
 static void ipcsyslog_cleanup(void)
 {
@@ -211,7 +214,7 @@ static void ipcsyslog_cleanup(void)
 static void ipcsyslog_init(void)
 {
 	if (DEBUG)
-		printf("shmget(%lx, %d,...)\n", KEY_ID, G.shm_size);
+		printf("shmget(%x, %d,...)\n", (int)KEY_ID, G.shm_size);
 
 	G.shmid = shmget(KEY_ID, G.shm_size, IPC_CREAT | 0644);
 	if (G.shmid == -1) {
@@ -631,6 +634,7 @@ static void do_syslogd(void)
 			split_escape_and_log(recvbuf, sz);
 		}
 	} /* for (;;) */
+#undef recvbuf
 }
 
 int syslogd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -682,3 +686,10 @@ int syslogd_main(int argc ATTRIBUTE_UNUS
 	do_syslogd();
 	/* return EXIT_SUCCESS; */
 }
+
+#undef G
+#undef GLOBALS
+#undef INIT_G
+#undef OPTION_STR
+#undef OPTION_DECL
+#undef OPTION_PARAM
_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Reply via email to