Re: [PATCH 03/10] net/tap: clarify TUN/TAP flag assignment

Stephen Hemminger
2026-02-16T00:47:39Z

On Sun, 15 Feb 2026 22:45:53 +0100
Morten Brørup <mb@smartsharesystems.com> wrote:

> >
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> > drivers/net/tap/rte_eth_tap.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/tap/rte_eth_tap.c
> > b/drivers/net/tap/rte_eth_tap.c
> > index aa236cf967..31c8c185e9 100644
> > --- a/drivers/net/tap/rte_eth_tap.c
> > +++ b/drivers/net/tap/rte_eth_tap.c
> > @@ -154,8 +154,11 @@ tun_alloc(struct pmd_internals *pmd, int
> > is_keepalive, int persistent)
> > * Do not set IFF_NO_PI as packet information header will be
> > needed
> > * to check if a received packet has been truncated.
> > */
> > - ifr.ifr_flags = (pmd->type == ETH_TUNTAP_TYPE_TAP) ?
> > - IFF_TAP : IFF_TUN | IFF_POINTOPOINT;
>
> For unconditional assignment, I prefer ternary expression over if/else.
> If you want to improve readability instead of relying on operator precedence, suggest:
>
> ifr.ifr_flags = (pmd->type == ETH_TUNTAP_TYPE_TAP) ?
> IFF_TAP : (IFF_TUN | IFF_POINTOPOINT);

I was pre-conditioned by MS style guide lines that always called out
excessive use of ternary as confusing