Skip to contentSkip to conversation

pktgen: Remove VLA usage

PATCH In review Gustavo A. R. Silva 3 participants 3 messages Mar 9, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pktgen: Remove VLA usage

In preparation to enabling -Wvla, remove VLA usage and replace it with a fixed-length array instead.

---
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(-)
net/core/pktgen.c +1 -1
index d81bddd..e2d6ae3 100644
@@ -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;
Signature · 1 line
2.7.4
maintainer
#1 lore raw

From: "Gustavo A. R. Silva" <[email protected]>
Date: Thu, 8 Mar 2018 23:43:40 -0600

Quoted 10 lines

In preparation to enabling -Wvla, remove VLA usage and replace it with a fixed-length array instead.

---
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.

#2 lore raw
Quoted 10 lines · David Miller

From: "Gustavo A. R. Silva" <[email protected]>
Date: Thu, 8 Mar 2018 23:43:40 -0600

Quoted 7 lines

In preparation to enabling -Wvla, remove VLA usage and replace it with a fixed-length array instead.

---
David,

Quoted 9 lines
Quoted 3 lines

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.

Quoted 2 lines

So your patch is fine, applied to net-next, thanks.

Awesome.

Thanks, David.
--
Gustavo