variant length array?

Wenda Ni wonda.ni at gmail.com
Tue Apr 5 15:29:25 EDT 2016


Hi all,

I come across the following code in a kernel module code. It defines an
array whose length is variant at runtime, depending on the actual inputs.
It seems that kernel compiler supports this, which is obvious an error in
the standard ANSI C. Do I have the correct understanding on it?

Thank you.


u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt, struct sk_buff *skb)
{
         ...
         int hdr_size = sizeof(struct udphdr) +
                 (skb->protocol == htons(ETH_P_IP) ?
                 sizeof(struct iphdr) : sizeof(struct ipv6hdr));
         u8 tmp[hdr_size + RXE_BTH_BYTES];
         ...
}

Cheers,

Wenda Ni, Ph.D.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160405/faf2fc9e/attachment.html 


More information about the Kernelnewbies mailing list