summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/logging.c
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-09-07 11:28:58 +0300
committerAtin Mukherjee <amukherj@redhat.com>2019-09-16 06:40:11 +0000
commitbcd71806b4066b413ee8c3e5a252c1866c9a7e97 (patch)
tree8fd4d24c092e3271e1dac4a7bff74b99acc4623f /libglusterfs/src/logging.c
parent0214c32954fcb9384a074c0cfc9e40252a19852e (diff)
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 <ykaul@redhat.com>
Diffstat (limited to 'libglusterfs/src/logging.c')
-rw-r--r--libglusterfs/src/logging.c18
1 files 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);