[dpdk-dev] [PATCH] hash: fix possible uninitialized variable
Dumitrescu, Cristian
cristian.dumitrescu at intel.com
Mon Dec 24 11:30:25 CET 2018
> -----Original Message-----
> From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> Sent: Sunday, December 23, 2018 7:44 AM
> To: Haiyang Tan <haiyangtan at tencent.com>
> Cc: Dumitrescu, Cristian <cristian.dumitrescu at intel.com>; dev at dpdk.org
> Subject: Re: [dpdk-dev] [PATCH] hash: fix possible uninitialized variable
>
> On Sat, 22 Dec 2018 04:10:59 -0800
> Haiyang Tan <haiyangtan at tencent.com> wrote:
>
> > The uninitialized field 'extra_flag' of hash_cuckoo_params may enable
> > certain feature silently. Typically, if bit0 of 'extra_flag' set, the
> > hardware transactional memory support will be enabled unexpectedly.
> >
> > Signed-off-by: Haiyang Tan <haiyangtan at tencent.com>
>
> 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_flags was recently added in librte_hash, but left behind in librte_table. For better readability, I suggest you send a quick patch that explicitly initializes the extra_flag with 0, what do you think?
struct rte_hash_parameters hash_cuckoo_params = {
...
.extra_flag = 0,
};
Regards,
Cristian
More information about the dev
mailing list