* [PATCH] pktgen: Remove VLA usage
@ 2018-03-09 5:43 Gustavo A. R. Silva
2018-03-09 16:58 ` David Miller
0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-09 5:43 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, linux-kernel, Gustavo A. R. Silva
In preparation to enabling -Wvla, remove VLA usage and replace it
with a fixed-length array instead.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
David,
I'm not sure how often this function is being called and,
depending on the frequency it may be worth to use
dynamic memory allocation instead?
Thanks
--
Gustavo
net/core/pktgen.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index d81bddd..e2d6ae3 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -907,7 +907,7 @@ static ssize_t pktgen_if_write(struct file *file,
if (debug) {
size_t copy = min_t(size_t, count, 1023);
- char tb[copy + 1];
+ char tb[1024];
if (copy_from_user(tb, user_buffer, copy))
return -EFAULT;
tb[copy] = 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pktgen: Remove VLA usage
2018-03-09 5:43 [PATCH] pktgen: Remove VLA usage Gustavo A. R. Silva
@ 2018-03-09 16:58 ` David Miller
2018-03-09 18:33 ` Gustavo A. R. Silva
0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2018-03-09 16:58 UTC (permalink / raw)
To: gustavo; +Cc: netdev, linux-kernel, garsilva
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Thu, 8 Mar 2018 23:43:40 -0600
> In preparation to enabling -Wvla, remove VLA usage and replace it
> with a fixed-length array instead.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> David,
>
> I'm not sure how often this function is being called and,
> depending on the frequency it may be worth to use
> dynamic memory allocation instead?
It happens every time a config setting is made via the sysfs
files when debug is enabled.
This is not something that happens often.
So your patch is fine, applied to net-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pktgen: Remove VLA usage
2018-03-09 16:58 ` David Miller
@ 2018-03-09 18:33 ` Gustavo A. R. Silva
0 siblings, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-03-09 18:33 UTC (permalink / raw)
To: David Miller, gustavo; +Cc: netdev, linux-kernel
On 03/09/2018 10:58 AM, David Miller wrote:
> From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
> Date: Thu, 8 Mar 2018 23:43:40 -0600
>
>> In preparation to enabling -Wvla, remove VLA usage and replace it
>> with a fixed-length array instead.
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> David,
>>
>> I'm not sure how often this function is being called and,
>> depending on the frequency it may be worth to use
>> dynamic memory allocation instead?
>
> It happens every time a config setting is made via the sysfs
> files when debug is enabled.
>
> This is not something that happens often.
>
I got it.
> So your patch is fine, applied to net-next, thanks.
>
Awesome.
Thanks, David.
--
Gustavo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-09 18:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-09 5:43 [PATCH] pktgen: Remove VLA usage Gustavo A. R. Silva
2018-03-09 16:58 ` David Miller
2018-03-09 18:33 ` Gustavo A. R. Silva
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).