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>
This commit is contained in:
parent
c16b1a9ccf
commit
678f4bda35
@ -394,8 +394,9 @@ static void llc_sap_mcast(struct llc_sap *sap,
|
|||||||
const struct llc_addr *laddr,
|
const struct llc_addr *laddr,
|
||||||
struct sk_buff *skb)
|
struct sk_buff *skb)
|
||||||
{
|
{
|
||||||
int i = 0, count = 256 / sizeof(struct sock *);
|
int i = 0;
|
||||||
struct sock *sk, *stack[count];
|
struct sock *sk;
|
||||||
|
struct sock *stack[256 / sizeof(struct sock *)];
|
||||||
struct llc_sock *llc;
|
struct llc_sock *llc;
|
||||||
struct hlist_head *dev_hb = llc_sk_dev_hash(sap, skb->dev->ifindex);
|
struct hlist_head *dev_hb = llc_sk_dev_hash(sap, skb->dev->ifindex);
|
||||||
|
|
||||||
@ -408,7 +409,7 @@ static void llc_sap_mcast(struct llc_sap *sap,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
sock_hold(sk);
|
sock_hold(sk);
|
||||||
if (i < count)
|
if (i < ARRAY_SIZE(stack))
|
||||||
stack[i++] = sk;
|
stack[i++] = sk;
|
||||||
else {
|
else {
|
||||||
llc_do_mcast(sap, skb, stack, i);
|
llc_do_mcast(sap, skb, stack, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user