diff mbox series

pktgen: Remove VLA usage

Message ID 20180309054340.GA14439@embeddedgus
State Accepted, archived
Delegated to: David Miller
Headers show
Series pktgen: Remove VLA usage | expand

Commit Message

Gustavo A. R. Silva March 9, 2018, 5:43 a.m. UTC
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(-)

Comments

David Miller March 9, 2018, 4:58 p.m. UTC | #1
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.
Gustavo A. R. Silva March 9, 2018, 6:33 p.m. UTC | #2
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
diff mbox series

Patch

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;