[dpdk-dev,v2] log: fix pattern matching

Message ID 20180516140928.76570-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ferruh Yigit May 16, 2018, 2:09 p.m. UTC
  loglevel set wrong when ":" is used as separator, like
--log-type="user:debug"

This is because fnmatch returns zero on success. Fixed fnmatch return
value check.

Fixes: 7f0bb634a140 ("log: add ability to match log type with globbing")
Cc: stephen@networkplumber.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
v2:
* s/seperator/separator/ in commit log
---
 lib/librte_eal/common/eal_common_log.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon May 21, 2018, 1:52 p.m. UTC | #1
16/05/2018 16:09, Ferruh Yigit:
> loglevel set wrong when ":" is used as separator, like
> --log-type="user:debug"
> 
> This is because fnmatch returns zero on success. Fixed fnmatch return
> value check.
> 
> Fixes: 7f0bb634a140 ("log: add ability to match log type with globbing")
> Cc: stephen@networkplumber.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c
index c660ca659..818118944 100644
--- a/lib/librte_eal/common/eal_common_log.c
+++ b/lib/librte_eal/common/eal_common_log.c
@@ -184,7 +184,7 @@  rte_log_set_level_pattern(const char *pattern, uint32_t level)
 		if (rte_logs.dynamic_types[i].name == NULL)
 			continue;
 
-		if (fnmatch(pattern, rte_logs.dynamic_types[i].name, 0))
+		if (fnmatch(pattern, rte_logs.dynamic_types[i].name, 0) == 0)
 			rte_logs.dynamic_types[i].loglevel = level;
 	}