[dpdk-dev] [PATCH 4/4] eal: add assert macro for debug

Stephen Hemminger stephen at networkplumber.org
Sat Apr 23 00:42:39 CEST 2016


On Fri, 22 Apr 2016 15:08:50 -0700
Yuanhan Liu <yuanhan.liu at linux.intel.com> wrote:

> On Fri, Apr 22, 2016 at 11:14:35PM +0200, Thomas Monjalon wrote:
> > 2016-04-22 12:51, Yuanhan Liu:
> > > On Fri, Apr 22, 2016 at 03:44:00PM +0200, Thomas Monjalon wrote:
> > > > --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
> > > > +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> > > > @@ -662,8 +662,8 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
> > > >  
> > > >  		PMD_RX_LOG(DEBUG, "rxd idx: %d ring idx: %d.", idx, ring_idx);
> > > >  
> > > > -		VMXNET3_ASSERT(rcd->len <= rxd->len);
> > > > -		VMXNET3_ASSERT(rbi->m);
> > > > +		RTE_ASSERT(rcd->len <= rxd->len);
> > > > +		RTE_ASSERT(rbi->m);
> > > 
> > > Seems this piece of code introduces a build error:
> > > 
> > >     drivers/net/vmxnet3/vmxnet3_rxtx.c: In function ‘vmxnet3_recv_pkts’:
> > >     drivers/net/vmxnet3/vmxnet3_rxtx.c:635:18: error: variable ‘rxd’ set but not used
> > >       Vmxnet3_RxDesc *rxd;
> > >                       ^
> > 
> > Indeed it can be seen with gcc when debug is disabled.
> > It can be fixed this way:
> > 
> > --- a/drivers/net/vmxnet3/vmxnet3_rxtx.c
> > +++ b/drivers/net/vmxnet3/vmxnet3_rxtx.c
> > @@ -658,6 +658,7 @@ vmxnet3_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
> >                 idx = rcd->rxdIdx;
> >                 ring_idx = (uint8_t)((rcd->rqID == rxq->qid1) ? 0 : 1);
> >                 rxd = (Vmxnet3_RxDesc *)rxq->cmd_ring[ring_idx].base + idx;
> > +               RTE_SET_USED(rxd); /* used only for assert when enabled */
> 
> How about adding the __rte_unused tag at where we declare it?
> 
> 	--yliu

Why not just kill the useless assert's all together? They really only helped during the short
time developer is debugging this code.


More information about the dev mailing list