From: Martin Mares Date: Fri, 13 Feb 2009 23:08:17 +0000 (+0100) Subject: Logging: Use LOG_STREAM_DEFAULT to refer to the default stream. X-Git-Tag: holmes-import~93 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=e035cf46a10ac16b197f812507c58b81405edb19;p=libucw.git Logging: Use LOG_STREAM_DEFAULT to refer to the default stream. This keeps the casts removing constness hidden. --- diff --git a/ucw/log-file.c b/ucw/log-file.c index 6a060baa..c74db01b 100644 --- a/ucw/log-file.c +++ b/ucw/log-file.c @@ -110,7 +110,7 @@ log_file(const char *name) { struct log_stream *old = s->p; log_rm_substream(def, old); - if (old != (struct log_stream *) &log_stream_default) + if (old != LOG_STREAM_DEFAULT) log_close_stream(old); } dup2(ls->idata, 2); // Let fd2 be an alias for the log file diff --git a/ucw/log.c b/ucw/log.c index f3c6aa14..1f7eea9d 100644 --- a/ucw/log.c +++ b/ucw/log.c @@ -64,7 +64,7 @@ log_stream_by_flags(uns flags) { int n = LS_GET_STRNUM(flags); if (n < 0 || n >= log_streams_after || log_streams.ptr[n]->regnum == -1) - return (n ? NULL : (struct log_stream *) &log_stream_default); + return (n ? NULL : LOG_STREAM_DEFAULT); return log_streams.ptr[n]; } @@ -88,7 +88,7 @@ vmsg(uns cat, const char *fmt, va_list args) if (!ls) { msg((LS_INTERNAL_MASK&cat)|L_WARN, "No log_stream with number %d! Logging to the default log.", LS_GET_STRNUM(cat)); - ls = (struct log_stream *) &log_stream_default; + ls = LOG_STREAM_DEFAULT; } /* Get the current time */ @@ -139,7 +139,7 @@ vmsg(uns cat, const char *fmt, va_list args) if (log_pass_msg(0, ls, &m)) { /* Error (such as infinite loop) occurred */ - log_pass_msg(0, (struct log_stream *) &log_stream_default, &m); + log_pass_msg(0, LOG_STREAM_DEFAULT, &m); } if (m.raw_msg != msgbuf) @@ -160,7 +160,7 @@ log_pass_msg(int depth, struct log_stream *ls, struct log_msg *m) struct log_msg errm = *m; errm.flags = L_ERROR | (m->flags & LS_INTERNAL_MASK); errm.raw_msg = "Loop in the log_stream system detected."; - log_pass_msg(0, (struct log_stream *) &log_stream_default, &errm); + log_pass_msg(0, LOG_STREAM_DEFAULT, &errm); } /* Filter by level and hook function */ diff --git a/ucw/log.h b/ucw/log.h index 306c5c94..dcef4ae9 100644 --- a/ucw/log.h +++ b/ucw/log.h @@ -53,6 +53,7 @@ struct log_stream /* the default logger */ extern const struct log_stream log_stream_default; +#define LOG_STREAM_DEFAULT ((struct log_stream *) &log_stream_default) /* A message is processed as follows: * 1. Discard if message level not in levels