From: Long Li <longli@microsoft.com>
To: Andre Muezerie <andremue@linux.microsoft.com>,
"longli@linuxonhyperv.com" <longli@linuxonhyperv.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Wei Hu <weh@microsoft.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: RE: [PATCH] net/mana: avoid the use of variable length array
Date: Thu, 6 Mar 2025 22:01:57 +0000 [thread overview]
Message-ID: <SA6PR21MB4231D1CD2DC22EE5A5EBEB19CECA2@SA6PR21MB4231.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20250306021745.GA9956@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>
> Subject: Re: [PATCH] net/mana: avoid the use of variable length array
>
> On Tue, Mar 04, 2025 at 04:37:32PM -0800, longli@linuxonhyperv.com wrote:
> > From: Long Li <longli@microsoft.com>
> >
> > The pathname can be defined as name[MAX_PATH]. This makes the driver
> > compilable using MSVC.
> >
> > Signed-off-by: Long Li <longli@microsoft.com>
> > ---
> > drivers/net/mana/mana.c | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/net/mana/mana.c b/drivers/net/mana/mana.c index
> > c37c4e3444..d12dff6ce1 100644
> > --- a/drivers/net/mana/mana.c
> > +++ b/drivers/net/mana/mana.c
> > @@ -36,11 +36,8 @@ static rte_spinlock_t mana_shared_data_lock =
> > RTE_SPINLOCK_INITIALIZER;
> >
> > /* Allocate a buffer on the stack and fill it with a printf format
> > string. */ #define MANA_MKSTR(name, ...) \
> > - int mkstr_size_##name = snprintf(NULL, 0, "" __VA_ARGS__); \
> > - char name[mkstr_size_##name + 1]; \
> > - \
> > - memset(name, 0, mkstr_size_##name + 1); \
> > - snprintf(name, sizeof(name), "" __VA_ARGS__)
> > + char name[PATH_MAX]; \
> > + snprintf(name, PATH_MAX, "" __VA_ARGS__)
> >
> > int mana_logtype_driver;
> > int mana_logtype_init;
> > --
> > 2.34.1
>
> Did you try to remove the line below from mana/meson.build?
> That line prevents the compiler from complain about VLAs. If the driver is VLA-
> free after this fix it would be great if the compiler was allowed to complain about
> VLAs (default in DPDK project).
>
> If the code still compiles without this line then it should be safe to remove it:
>
> cflags += no_wvla_cflag
> --
> Andre Muezerie
I tried, it gives warnings on other two places using VLA:
[1688/3164] Compiling C object drivers/libtmp_rte_net_mana.a.p/net_mana_mr.c.o
../drivers/net/mana/mr.c: In function 'mana_new_pmd_mr':
../drivers/net/mana/mr.c:41:16: warning: ISO C90 forbids variable length array 'ranges' [-Wvla]
41 | struct mana_range ranges[pool->nb_mem_chunks];
| ^~~~~~~~~~
[1710/3164] Compiling C object drivers/libtmp_rte_net_mana.a.p/net_mana_rx.c.o
../drivers/net/mana/rx.c: In function 'mana_start_rx_queues':
../drivers/net/mana/rx.c:244:16: warning: ISO C90 forbids variable length array 'ind_tbl' [-Wvla]
244 | struct ibv_wq *ind_tbl[priv->num_queues];
| ^~~~~~
I'll fix them up and send a patch.
prev parent reply other threads:[~2025-03-06 22:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 0:37 longli
2025-03-05 9:00 ` Morten Brørup
2025-03-06 2:17 ` Andre Muezerie
2025-03-06 22:01 ` Long Li [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=SA6PR21MB4231D1CD2DC22EE5A5EBEB19CECA2@SA6PR21MB4231.namprd21.prod.outlook.com \
--to=longli@microsoft.com \
--cc=andremue@linux.microsoft.com \
--cc=dev@dpdk.org \
--cc=longli@linuxonhyperv.com \
--cc=stephen@networkplumber.org \
--cc=weh@microsoft.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 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).