All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Randy L Tice <rtice@cisco.com>
Cc: dev@dpdk.org
Subject: Re: [PATCH 1/1] log: add name query functions
Date: Mon, 16 Nov 2026 11:05:59 -0800	[thread overview]
Message-ID: <20261116110559.1649b3f6@phoenix.local> (raw)
In-Reply-To: <179269447225.66.503181230751464930.0001-log-add-name-query-functions.patch@cisco.com>

On Thu, 22 Oct 2026 14:41:12 -0400
Randy L Tice <rtice@cisco.com> wrote:

> From: Randy L Tice <rtice@cisco.com>
> Date: Thu, 22 Oct 2026 14:34:31 -0400
> 
> Applications can query the numeric level for a log type, but cannot map
> a level or type identifier back to a human-readable name without parsing
> log dump output.
> 
> Add experimental helpers for retrieving the canonical level name and the
> registered log type name. Document ownership of the returned strings and
> add unit test coverage.
> 
> The original downstream implementation was authored by Walt Robinson
> <walrobin@cisco.com>.
> 
> Signed-off-by: Randy L Tice <rtice@cisco.com>
> ---

Finally got around to looking at this, I think it is OK.
But AI had a good suggestion about making error returns the same.

Review: [PATCH 1/1] log: add name query functions

Applies cleanly to main. Builds with -Dwerror=true including
app/test.

Warning
-------

Patch 1/1: inconsistent error convention between the two getters.

rte_log_get_type_name() returns NULL for an invalid type, but
rte_log_get_level_name() returns the string "unknown" for an invalid
level. A caller cannot tell an out-of-range level from a real one
without comparing against a magic string, and the public API now
inherits whatever eal_log_level2str() (an internal symbol) chooses
to return. Return NULL for both:

const char *
rte_log_get_level_name(uint32_t level)
{
	if (level > RTE_LOG_MAX)
		return NULL;

	return eal_log_level2str(level);
}

and in rte_log.h:

 * @return
 *   The name of the log level, or NULL if level is not valid.

The test then becomes:

	TEST_ASSERT_NULL(rte_log_get_level_name(UINT32_MAX),
		"invalid log level has a name\n");

  parent reply	other threads:[~2026-11-16 19:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-22 18:41 [PATCH 0/1] log: add name query functions Randy L Tice
2026-10-22 18:41 ` [PATCH 1/1] " Randy L Tice
2026-11-12 14:01   ` Randy L Tice
2026-11-16 19:05   ` Stephen Hemminger [this message]
2026-11-02 18:52 ` [PATCH 0/1] " Randy L Tice

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116110559.1649b3f6@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=rtice@cisco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.