reply: [PATCH] hash: fix possible uninitialized variable
Quoted 43 lines
-----Original Message-----
From: Dumitrescu, Cristian <[email protected]>
发送时间: 2018年12月24日 18:30
收件人: Stephen Hemminger <[email protected]>;
haiyangtan <[email protected]>
Cc: [email protected]
Subject: RE: [dpdk-dev] [PATCH] hash: fix possible uninitialized variable(Internet mail)Quoted 14 lines
-----Original Message-----
From: Stephen Hemminger [mailto:[email protected]]
Sent: Sunday, December 23, 2018 7:44 AM
To: Haiyang Tan <[email protected]>
Cc: Dumitrescu, Cristian <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH] hash: fix possible uninitialized variableQuoted 4 lines · On Sat, 22 Dec 2018 04:10:59 -0800 Haiyang Tan <[email protected]> wrote:
The uninitialized field '
extra_flag' ofhash_cuckoo_paramsmay enable certain feature silently. Typically, if bit0 of 'extra_flag' set, the hardware transactional memory support will be enabled unexpectedly.Quoted 8 lines
Quoted 1 line
Signed-off-by Haiyang Tan <[email protected]>This is not necessary. Structure initializations will fill in the other elements with zero.
https://gcc.gnu.org/onlinedocs/gcc-4.9.0/gcc/Designated-Inits.html
Omitted field members are implicitly initialized the same as objects that
have static storage duration.Agree with Stephen, this is part of the C language.
Haiyang, are you experiencing a real issue in your app or is your proposal triggered purely by code review?
Haiyang, it seems that the
extra_flagswas recently added inlibrte_hash, but left behind inlibrte_table. For better readability, I suggest you send a quick patch that explicitly initializes theextra_flagwith 0, what do you think?
Quoted 8 lines
struct rte_hash_parameters hash_cuckoo_params = { ... .extra_flag = 0, };Regards,
Cristian
Hi Stephen and Cristian, I have checked C99 standard and get the same conclusion which mentioned in stephen's email,
So this patch is unnecessary and please ignore it.
BR!
Haiyang