[v4,05/11] eal: introduce maximum log level macro
Checks
Commit Message
RTE_DIM(...) and RTE_LOG_DEBUG were used to get the highest log level.
For better clarity a new constant RTE_LOG_MAX is introduced
and mapped to RTE_LOG_DEBUG.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
lib/librte_eal/common/eal_common_log.c | 8 ++++----
lib/librte_eal/common/eal_common_options.c | 2 +-
lib/librte_eal/include/rte_log.h | 1 +
3 files changed, 6 insertions(+), 5 deletions(-)
@@ -140,7 +140,7 @@ rte_log_set_level(uint32_t type, uint32_t level)
{
if (type >= rte_logs.dynamic_types_len)
return -1;
- if (level > RTE_LOG_DEBUG)
+ if (level > RTE_LOG_MAX)
return -1;
rte_logs.dynamic_types[type].loglevel = level;
@@ -155,7 +155,7 @@ rte_log_set_level_regexp(const char *regex, uint32_t level)
regex_t r;
size_t i;
- if (level > RTE_LOG_DEBUG)
+ if (level > RTE_LOG_MAX)
return -1;
if (regcomp(&r, regex, 0) != 0)
@@ -219,7 +219,7 @@ rte_log_set_level_pattern(const char *pattern, uint32_t level)
{
size_t i;
- if (level > RTE_LOG_DEBUG)
+ if (level > RTE_LOG_MAX)
return -1;
for (i = 0; i < rte_logs.dynamic_types_len; i++) {
@@ -323,7 +323,7 @@ rte_log_register_type_and_pick_level(const char *name, uint32_t level_def)
return type;
TAILQ_FOREACH(opt_ll, &opt_loglevel_list, next) {
- if (opt_ll->level > RTE_LOG_DEBUG)
+ if (opt_ll->level > RTE_LOG_MAX)
continue;
if (opt_ll->pattern) {
@@ -1249,7 +1249,7 @@ eal_parse_log_priority(const char *level)
return -1;
/* look for named values, skip 0 which is not a valid level */
- for (i = 1; i < RTE_DIM(levels); i++) {
+ for (i = 1; i <= RTE_LOG_MAX; i++) {
if (strncmp(levels[i], level, len) == 0)
return i;
}
@@ -72,6 +72,7 @@ extern "C" {
#define RTE_LOG_NOTICE 6U /**< Normal but significant condition. */
#define RTE_LOG_INFO 7U /**< Informational. */
#define RTE_LOG_DEBUG 8U /**< Debug-level messages. */
+#define RTE_LOG_MAX RTE_LOG_DEBUG /**< Most detailed log level. */
/**
* Change the stream that will be used by the logging system.