summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-05-20 18:02:56 +0200
committerThomas Haller <thaller@redhat.com>2016-05-22 11:25:48 +0200
commitf8cc73150fb2244191f6ba5ca046a3e5d5f03845 (patch)
treeec788c1aca3f9635e17ed76d84fda0769082b512
parent0209e01eff24316de4169f80cf52e8191b4efeda (diff)
downloadNetworkManager-f8cc73150fb2244191f6ba5ca046a3e5d5f03845.tar.gz
logging: add check for logging level in nm_logging_enabled()
With this check, the function is safe to use even with invalid logging levels. But it can still be inlined as for most cases @level is a (enum) constant and the check can be evaluated at compile time. Oddly enough, on a default build with ./autogen.sh && make && strip ./src/NetworkManager this patch decreases the size of the binary by 8k.
-rw-r--r--src/nm-logging.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/nm-logging.h b/src/nm-logging.h
index c134670501..1cb5a5a5d9 100644
--- a/src/nm-logging.h
+++ b/src/nm-logging.h
@@ -164,7 +164,8 @@ static inline gboolean
nm_logging_enabled (NMLogLevel level, NMLogDomain domain)
{
nm_assert (((guint) level) < G_N_ELEMENTS (_nm_logging_enabled_state));
- return !!(_nm_logging_enabled_state[level] & domain);
+ return (((guint) level) < G_N_ELEMENTS (_nm_logging_enabled_state))
+ && !!(_nm_logging_enabled_state[level] & domain);
}
const char *nm_logging_all_levels_to_string (void);