[dpdk-dev] Build is broken in dpdk-next-net

Neil Horman nhorman at tuxdriver.com
Sat Mar 31 17:27:55 CEST 2018


On Sat, Mar 31, 2018 at 05:09:47PM +0200, Gaëtan Rivet wrote:
> On Sat, Mar 31, 2018 at 09:33:43AM -0400, Neil Horman wrote:
> > On Fri, Mar 30, 2018 at 10:47:09PM +0800, Tonghao Zhang wrote:
> > > I rebuild it on ubuntu 17.10 and cash it. I use the 'RTE_SET_USED' to fix it.
> > > 
> > > 
> > > diff --git a/lib/librte_vhost/fd_man.c b/lib/librte_vhost/fd_man.c
> > > index 771675718..f11803191 100644
> > > --- a/lib/librte_vhost/fd_man.c
> > > +++ b/lib/librte_vhost/fd_man.c
> > > @@ -279,7 +279,8 @@ fdset_pipe_read_cb(int readfd, void *dat __rte_unused,
> > >                    int *remove __rte_unused)
> > >  {
> > >         char charbuf[16];
> > > -       read(readfd, charbuf, sizeof(charbuf));
> > > +       int r = read(readfd, charbuf, sizeof(charbuf));
> > > +       RTE_SET_USED(r);
> > >  }
> > > 
> > >  void
> > > @@ -319,5 +320,6 @@ fdset_pipe_init(struct fdset *fdset)
> > >  void
> > >  fdset_pipe_notify(struct fdset *fdset)
> > >  {
> > > -       write(fdset->u.writefd, "1", 1);
> > > +       int r = write(fdset->u.writefd, "1", 1);
> > > +       RTE_SET_USED(r);
> > >  }
> > > 
> > 
> > A better option might be to use _Pragma
> > 
> > Something like this perhaps
> > 
> > #define ALLOW_UNUSED(x) \
> > _Pragma(push) \
> > _Pragma(diagnostic ignored "-Wunused-result") \
> > #x;\
> > _Pragma(pop)
> > 
> > This is of course untested, so it probably needs some tweaking, but this method
> > avoids the need to declare an additional stack variable, which i don't think can
> > be eliminated due to the cast.  I believe that this method should also work
> > accross compilers (the gcc and clang compilers support this, and i think the
> > intel compiler should as well)
> > 
> > Neil
> > 
> 
> It would be nice to avoid the definition of a useless variable.
> An alternative could be
> 
>    if (read() < 0) {
>        /* Failure here is acceptable for such and such reason. */
>    }
> 
> to ensure all-around compatibility, and the definition or another macro.
> Just a suggestion.
> 
That would be a good alternative, but I think its effectiveness is dependent on
when the compiler does with the return value check. Without any code inside the
conditional, the compiler may optimize the check out, meaning the warning will
still be asserted.  If it doesn't optimize the check out, then you have a
useless compare and jump instruction left in the code path.

Best
Neil



More information about the dev mailing list