From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f47.google.com (mail-wg0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id 9F274C34E for ; Mon, 6 Apr 2015 21:14:26 +0200 (CEST) Received: by wgyo15 with SMTP id o15so24245145wgy.2 for ; Mon, 06 Apr 2015 12:14:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=qMZ+SSiTDQ5X7d/d9v2Zs+5KKpjKqMA8ykFDjyU3yEQ=; b=NHPbOMRZJ89VhztVhrWqTCdoJgPZDE1y03GhdhgOyZIbYb6bl9nZ7PJYfCBzmti7Yg aO5uCvAWbvWczzsK0qLW+V7DrrGe6IEGyjY2pPoRzAJfZQ1NJ9kZXHC+QWzqaIdPWZTh 20y5guBwWuLNbNFu8k68tt/oBNsONnpDkvs46yNo2vxDnwzOqVezJf+38Ti9qko+2z1g yipKYxsDvThIDZ9z1jtZHIybVwCBQK8Q08+2xmefhDgB9gMI2bmr/yIAQeexrD4ivAIT 4gBZe/Qdq3gdYy24vfR5bGq68d+7dw0ox1yyP4mE4kv9EDpLWvBzfaRsoqOx5FYD/qw9 0RAA== X-Gm-Message-State: ALoCoQnWjzoyDrNeY0MaBq7sU8fD7Yco7AkAKPi0EZEPm3wAQ6BUxJS4CMVwcRqM0igKw5YxpOfB X-Received: by 10.180.189.69 with SMTP id gg5mr31898102wic.93.1428347666426; Mon, 06 Apr 2015 12:14:26 -0700 (PDT) Received: from alcyon.dev.6wind.com (6wind.net2.nerim.net. [213.41.180.237]) by mx.google.com with ESMTPSA id gy8sm7682862wib.13.2015.04.06.12.14.25 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2015 12:14:25 -0700 (PDT) From: David Marchand To: dev@dpdk.org Date: Mon, 6 Apr 2015 21:14:20 +0200 Message-Id: <1428347660-9861-1-git-send-email-david.marchand@6wind.com> X-Mailer: git-send-email 1.7.10.4 Subject: [dpdk-dev] [PATCH] eal: fix log level check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Apr 2015 19:14:26 -0000 From: Jean Dao According to the api, rte_log() / rte_vlog() are supposed to check the log level and type but they were not doing so. This check was only done in the RTE_LOG macro while this macro is only there to remove log messages at build time. rte_log() always calls rte_vlog(), so move the check to rte_vlog() only. Signed-off-by: Jean Dao Signed-off-by: David Marchand --- lib/librte_eal/common/eal_common_log.c | 8 +++++--- lib/librte_eal/common/include/rte_log.h | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index ff44d23..fe3d7d5 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -265,14 +265,15 @@ rte_log_dump_history(FILE *out) * defined by the previous call to rte_openlog_stream(). */ int -rte_vlog(__attribute__((unused)) uint32_t level, - __attribute__((unused)) uint32_t logtype, - const char *format, va_list ap) +rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) { int ret; FILE *f = rte_logs.file; unsigned lcore_id; + if ((level > rte_logs.level) || !(logtype & rte_logs.type)) + return 0; + /* save loglevel and logtype in a global per-lcore variable */ lcore_id = rte_lcore_id(); if (lcore_id < RTE_MAX_LCORE) { @@ -288,6 +289,7 @@ rte_vlog(__attribute__((unused)) uint32_t level, /* * Generates a log message The message will be sent in the stream * defined by the previous call to rte_openlog_stream(). + * No need to check level here, done by rte_vlog(). */ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...) diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h index f83a0d9..3b467c1 100644 --- a/lib/librte_eal/common/include/rte_log.h +++ b/lib/librte_eal/common/include/rte_log.h @@ -299,9 +299,7 @@ int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap) * - Negative on error. */ #define RTE_LOG(l, t, ...) \ - (void)(((RTE_LOG_ ## l <= RTE_LOG_LEVEL) && \ - (RTE_LOG_ ## l <= rte_logs.level) && \ - (RTE_LOGTYPE_ ## t & rte_logs.type)) ? \ + (void)((RTE_LOG_ ## l <= RTE_LOG_LEVEL) ? \ rte_log(RTE_LOG_ ## l, \ RTE_LOGTYPE_ ## t, # t ": " __VA_ARGS__) : \ 0) -- 1.7.10.4