[dpdk-dev] 回复: [dpdk-stable] [PATCH] crypto/qat: fix uninitilized compiler warning

Feifei Wang Feifei.Wang2 at arm.com
Fri May 14 10:30:18 CEST 2021


> -----邮件原件-----
> 发件人: David Marchand <david.marchand at redhat.com>
> 发送时间: 2021年5月14日 16:14
> 收件人: Feifei Wang <Feifei.Wang2 at arm.com>
> 抄送: John Griffin <john.griffin at intel.com>; Fiona Trahe
> <fiona.trahe at intel.com>; Deepak Kumar Jain <deepak.k.jain at intel.com>;
> Herbert Guan <Herbert.Guan at arm.com>; Jerin Jacob
> <jerin.jacob at caviumnetworks.com>; dev <dev at dpdk.org>; nd
> <nd at arm.com>; dpdk stable <stable at dpdk.org>; Ruifeng Wang
> <Ruifeng.Wang at arm.com>
> 主题: Re: [dpdk-stable] [PATCH] crypto/qat: fix uninitilized compiler warning
> 
> On Fri, May 14, 2021 at 10:01 AM Feifei Wang <Feifei.Wang2 at arm.com>
> wrote:
> > > > @@ -1190,8 +1190,8 @@ static int partial_hash_compute(enum
> > > icp_qat_hw_auth_algo hash_alg,
> > > >                         uint8_t *data_out)  {
> > > >         int digest_size;
> > > > -       uint8_t digest[qat_hash_get_digest_size(
> > > > -                       ICP_QAT_HW_AUTH_ALGO_DELIMITER)];
> > > > +       uint8_t *digest = (uint8_t *)calloc(qat_hash_get_digest_size(
> > > > +                               ICP_QAT_HW_AUTH_ALGO_DELIMITER),
> > > > + sizeof(uint8_t));
> > >
> > > calloc can fail.
> > > cast is unneded.
> > >
> > > A simple uint8_t digest[...] = { 0 } would do the job.
> >
> > Thanks for your comment. Actually, we have tried to use this simple
> method:
> >  uint8_t
> > digest[qat_hash_get_digest_size(ICP_QAT_HW_AUTH_ALGO_DELIMITER)]
> =
> > {0};
> >
> > And it will report compile error:
> > ../drivers/crypto/qat/qat_sym_session.c:1194:4: error: variable-sized
> object may not be initialized
> >  1194 |    ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0};
> >       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > ../drivers/crypto/qat/qat_sym_session.c:1194:40: warning: excess
> elements in array initializer
> >  1194 |    ICP_QAT_HW_AUTH_ALGO_DELIMITER)] = {0};
> >       |                                        ^
> > ../drivers/crypto/qat/qat_sym_session.c:1194:40: note: (near
> > initialization for ‘digest’)
> > ninja: build stopped: subcommand failed.
> >
> > I think this is because compiler cannot know the size of digest due to
> > function 'qat_hash_get_digest_size' during  compiling time.
> 
> Ok, I had not noticed the function call.
> 
> Please check dynamic allocation succeeds.
> + free this temp buffer before leaving this helper function.

Thanks for this comments, I will add check and free operations for this dynamic allocation
in the next version

Best Regards
Feifei 
> 
> 
> --
> David marchand



More information about the dev mailing list