From bcd71806b4066b413ee8c3e5a252c1866c9a7e97 Mon Sep 17 00:00:00 2001 From: Yaniv Kaul Date: Sat, 7 Sep 2019 11:28:58 +0300 Subject: logging.c: check for log level before checking for args. In many cases, we will not be logging at all, since the log level is irrelevant. In that case, we can just bail out. Worth doing this check before the args check, which may not be needed in this case. Change-Id: Ia90a38bb2a49b09bfea5b5abc8b5d0c3bab4e9ac updates: bz#1193929 Signed-off-by: Yaniv Kaul --- libglusterfs/src/logging.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index a0f501ec739..431ae979cba 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -1940,20 +1940,11 @@ _gf_msg(const char *domain, const char *file, const char *function, int ret = 0; char *msgstr = NULL; va_list ap; - xlator_t *this = NULL; + xlator_t *this = THIS; glusterfs_ctx_t *ctx = NULL; char *callstr = NULL; int log_inited = 0; - /* in args check */ - if (!domain || !file || !function || !fmt) { - fprintf(stderr, "logging: %s:%s():%d: invalid argument\n", __FILE__, - __PRETTY_FUNCTION__, __LINE__); - return -1; - } - - this = THIS; - if (this == NULL) return -1; @@ -1967,6 +1958,13 @@ _gf_msg(const char *domain, const char *file, const char *function, if (skip_logging(this, level)) goto out; + /* in args check */ + if (!domain || !file || !function || !fmt) { + fprintf(stderr, "logging: %s:%s():%d: invalid argument\n", __FILE__, + __PRETTY_FUNCTION__, __LINE__); + return -1; + } + /* form the message */ va_start(ap, fmt); ret = vasprintf(&msgstr, fmt, ap); -- cgit