summaryrefslogtreecommitdiffstats
path: root/net/llc
diff options
context:
space:
mode:
authorSalvatore Mesoraca <s.mesoraca16@gmail.com>2018-03-11 17:12:04 -0400
committerDavid S. Miller <davem@davemloft.net>2018-03-12 11:14:06 -0400
commit678f4bda35483473ae7ad674ece4c7c43a000888 (patch)
treef10b13a12ad1ea7f4790a6fa3ec6a064d22c7208 /net/llc
parentc16b1a9ccf70630004f3700532313ca0bcf3e663 (diff)
net: llc: drop VLA in llc_sap_mcast()
Avoid a VLA[1] by using a real constant expression instead of a variable. The compiler should be able to optimize the original code and avoid using an actual VLA. Anyway this change is useful because it will avoid a false positive with -Wvla, it might also help the compiler generating better code. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Salvatore Mesoraca <s.mesoraca16@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/llc')
-rw-r--r--net/llc/llc_sap.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c
index d90928f50226..a7f7b8ff4729 100644
--- a/net/llc/llc_sap.c
+++ b/net/llc/llc_sap.c
@@ -394,8 +394,9 @@ static void llc_sap_mcast(struct llc_sap *sap,
394 const struct llc_addr *laddr, 394 const struct llc_addr *laddr,
395 struct sk_buff *skb) 395 struct sk_buff *skb)
396{ 396{
397 int i = 0, count = 256 / sizeof(struct sock *); 397 int i = 0;
398 struct sock *sk, *stack[count]; 398 struct sock *sk;
399 struct sock *stack[256 / sizeof(struct sock *)];
399 struct llc_sock *llc; 400 struct llc_sock *llc;
400 struct hlist_head *dev_hb = llc_sk_dev_hash(sap, skb->dev->ifindex); 401 struct hlist_head *dev_hb = llc_sk_dev_hash(sap, skb->dev->ifindex);
401 402
@@ -408,7 +409,7 @@ static void llc_sap_mcast(struct llc_sap *sap,
408 continue; 409 continue;
409 410
410 sock_hold(sk); 411 sock_hold(sk);
411 if (i < count) 412 if (i < ARRAY_SIZE(stack))
412 stack[i++] = sk; 413 stack[i++] = sk;
413 else { 414 else {
414 llc_do_mcast(sap, skb, stack, i); 415 llc_do_mcast(sap, skb, stack, i);