* [ulogd2 PATCH 3/4] ulogd: Use (FILE *)(-1) as dummy logfile when logging to syslog
@ 2015-05-16 13:37 Felix Janda
2015-05-16 15:01 ` Jan Engelhardt
0 siblings, 1 reply; 3+ messages in thread
From: Felix Janda @ 2015-05-16 13:37 UTC (permalink / raw)
To: netfilter-devel
Fixes compilation error with musl libc:
ulogd.c:86:13: error: storage size of 'syslog_dummy' isn't known
static FILE syslog_dummy;
Signed-off-by: Felix Janda <felix.janda@posteo.de>
---
src/ulogd.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/ulogd.c b/src/ulogd.c
index e7cde39..093f7ec 100644
--- a/src/ulogd.c
+++ b/src/ulogd.c
@@ -83,7 +83,7 @@ static char *ulogd_logfile = NULL;
static const char *ulogd_configfile = ULOGD_CONFIGFILE;
static const char *ulogd_pidfile = NULL;
static int ulogd_pidfile_fd = -1;
-static FILE syslog_dummy;
+#define SYSLOG_DUMMY ((FILE *)(-1))
static int info_mode = 0;
@@ -427,7 +427,7 @@ void __ulogd_log(int level, char *file, int line, const char *format, ...)
if (level < loglevel_ce.u.value)
return;
- if (logfile == &syslog_dummy) {
+ if (logfile == SYSLOG_DUMMY) {
/* FIXME: this omits the 'file' string */
va_start(ap, format);
vsyslog(ulogd2syslog_level(level), format, ap);
@@ -950,7 +950,7 @@ static int logfile_open(const char *name)
logfile = stdout;
} else if (!strcmp(name, "syslog")) {
openlog("ulogd", LOG_PID, LOG_DAEMON);
- logfile = &syslog_dummy;
+ logfile = SYSLOG_DUMMY;
} else {
logfile = fopen(ulogd_logfile, "a");
if (!logfile) {
@@ -1240,7 +1240,7 @@ static void sigterm_handler(int signal)
unload_plugins();
#endif
- if (logfile != NULL && logfile != stdout && logfile != &syslog_dummy) {
+ if (logfile != NULL && logfile != stdout && logfile != SYSLOG_DUMMY) {
fclose(logfile);
logfile = NULL;
}
@@ -1262,7 +1262,7 @@ static void signal_handler(int signal)
switch (signal) {
case SIGHUP:
/* reopen logfile */
- if (logfile != stdout && logfile != &syslog_dummy) {
+ if (logfile != stdout && logfile != SYSLOG_DUMMY) {
fclose(logfile);
logfile = fopen(ulogd_logfile, "a");
if (!logfile) {
--
2.3.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [ulogd2 PATCH 3/4] ulogd: Use (FILE *)(-1) as dummy logfile when logging to syslog
2015-05-16 13:37 [ulogd2 PATCH 3/4] ulogd: Use (FILE *)(-1) as dummy logfile when logging to syslog Felix Janda
@ 2015-05-16 15:01 ` Jan Engelhardt
2015-05-16 15:36 ` Felix Janda
0 siblings, 1 reply; 3+ messages in thread
From: Jan Engelhardt @ 2015-05-16 15:01 UTC (permalink / raw)
To: Felix Janda; +Cc: netfilter-devel
On Saturday 2015-05-16 15:37, Felix Janda wrote:
>-static FILE syslog_dummy;
>+#define SYSLOG_DUMMY ((FILE *)(-1))
^This will likely introduce a "cast to pointer from integer of different
size" warning on LP64 targets.
syslog_dummy = fopen("/dev/null", "w");
would be, at the cost of one more open fd, a "nice" solution,
since syslog_dummy is guaranteed to be unique, without making
any assumptions about any magic value(s) being unused.
That, or turn the assumptive macro into
#define SYSLOG_DUMMY ((FILE *)(intptr_t)-1)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ulogd2 PATCH 3/4] ulogd: Use (FILE *)(-1) as dummy logfile when logging to syslog
2015-05-16 15:01 ` Jan Engelhardt
@ 2015-05-16 15:36 ` Felix Janda
0 siblings, 0 replies; 3+ messages in thread
From: Felix Janda @ 2015-05-16 15:36 UTC (permalink / raw)
To: Jan Engelhardt; +Cc: netfilter-devel
Jan Engelhardt wrote:
> On Saturday 2015-05-16 15:37, Felix Janda wrote:
>
> >-static FILE syslog_dummy;
> >+#define SYSLOG_DUMMY ((FILE *)(-1))
>
> ^This will likely introduce a "cast to pointer from integer of different
> size" warning on LP64 targets.
>
> syslog_dummy = fopen("/dev/null", "w");
>
> would be, at the cost of one more open fd, a "nice" solution,
> since syslog_dummy is guaranteed to be unique, without making
> any assumptions about any magic value(s) being unused.
This seems seems like a cleaner approach.
Preparing a new patch...
> That, or turn the assumptive macro into
> #define SYSLOG_DUMMY ((FILE *)(intptr_t)-1)
Thanks,
Felix
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-16 15:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-16 13:37 [ulogd2 PATCH 3/4] ulogd: Use (FILE *)(-1) as dummy logfile when logging to syslog Felix Janda
2015-05-16 15:01 ` Jan Engelhardt
2015-05-16 15:36 ` Felix Janda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).