From: Stephen Hemminger <stephen@networkplumber.org>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: "Van Haaren, Harry" <harry.van.haaren@intel.com>,
dev@dpdk.org, "Richardson, Bruce" <bruce.richardson@intel.com>,
Jerin Jacob <jerin.jacob@caviumnetworks.com>
Subject: Re: [PATCH] event: fix warning from useless snprintf
Date: Sat, 15 Jun 2024 09:04:42 -0700 [thread overview]
Message-ID: <20240615090442.6894a894@hermes.local> (raw)
In-Reply-To: <1864322.ucjEoNaZvj@thomas>
On Sat, 15 Jun 2024 13:43:16 +0200
Thomas Monjalon <thomas@monjalon.net> wrote:
> 24/04/2024 21:10, Stephen Hemminger:
> > On Wed, 24 Apr 2024 17:12:39 +0000
> > "Van Haaren, Harry" <harry.van.haaren@intel.com> wrote:
> > > From: Stephen Hemminger <stephen@networkplumber.org>
> > > > "Van Haaren, Harry" <harry.van.haaren@intel.com> wrote:
> > > > > > From: Stephen Hemminger <stephen@networkplumber.org>
> > > > > >
> > > > > > With Gcc-14, this warning is generated:
> > > > > > ../drivers/event/sw/sw_evdev.c:263:3: warning: 'snprintf' will always be truncated;
> > > > > > specified size is 12, but format string expands to at least 13 [-Wformat-truncation]
> > > > > > 263 | snprintf(buf, sizeof(buf), "sw%d_iq_%d_rob", dev_id, i);
> > > > > > | ^
> > > > > >
> > > > > > Yet the whole printf to the buf is unnecessary. The type string argument
> > > > > > has never been implemented, and should just be NULL. Removing the
> > > > > > unnecessary snprintf, then means IQ_ROB_NAMESIZE can be removed.
> > > > >
> > > > > I understand that today the "type" value isn't implemented, but across the DPDK codebase it
> > > > > seems like others are filling in "type" to be some debug-useful name/string. If it was added
> > > > > in future it'd be nice to have the ROB/IQ memory identified by name, like the rest of DPDK components.
> > > >
> > > > No, don't bother. This is a case of https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it
> > >
> > > I agree that YAGNI perhaps applied when designing the APIs, but the "type" parameter is there now...
> > > Should we add a guidance of "when reworking code, always pass NULL as the type parameter to rte_malloc functions" somewhere in the programmers guide, to align community with this "pass NULL for type" initiative?
> > >
> > > <snip>
> > >
> > > Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
> > >
> >
> > Did look into Mi-Malloc https://github.com/microsoft/mimalloc
> > it is fast and more complete and good work with huge pages.
> > The way to handle tagging allocations having the library automatically handle it
> > based on the place allocation is called from. Having user do it is not that helpful.
>
> But today we have rte_malloc.
> And the type is used in tracing.
> I think having a meaningful name from the caller is not a bad idea.
>
>
Ok still useful for tracing, but documentation is incorrect (dump stats doesn't use it), and the
type field doesn't need to be passed as argument to heap code.
prev parent reply other threads:[~2024-06-15 16:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-24 3:45 Stephen Hemminger
2024-04-24 8:45 ` Van Haaren, Harry
2024-04-24 16:13 ` Stephen Hemminger
2024-04-24 17:12 ` Van Haaren, Harry
2024-04-24 19:10 ` Stephen Hemminger
2024-05-27 17:21 ` Jerin Jacob
2024-06-15 11:43 ` Thomas Monjalon
2024-06-15 16:04 ` Stephen Hemminger [this message]
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=20240615090442.6894a894@hermes.local \
--to=stephen@networkplumber.org \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@intel.com \
--cc=jerin.jacob@caviumnetworks.com \
--cc=thomas@monjalon.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).