DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tiwei Bie <tiwei.bie@intel.com>
To: "Lu, Wenzhuo" <wenzhuo.lu@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get
Date: Mon, 6 Feb 2017 13:26:55 +0800	[thread overview]
Message-ID: <20170206052655.GA2390@debian> (raw)
In-Reply-To: <6A0DE07E22DDAD4C9103DF62FEBC09093B56145A@shsmsx102.ccr.corp.intel.com>

On Mon, Feb 06, 2017 at 01:17:30PM +0800, Lu, Wenzhuo wrote:
> > -----Original Message-----
> > From: Bie, Tiwei
> > Sent: Monday, February 6, 2017 12:57 PM
> > To: Lu, Wenzhuo
> > Cc: dev@dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up rte_eth_dev_info_get
> > 
> > On Mon, Feb 06, 2017 at 11:45:41AM +0800, Lu, Wenzhuo wrote:
> > > Hi Tiwei,
> > >
> > > > -----Original Message-----
> > > > From: Bie, Tiwei
> > > > Sent: Monday, February 6, 2017 11:08 AM
> > > > To: Lu, Wenzhuo
> > > > Cc: dev@dpdk.org
> > > > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up
> > > > rte_eth_dev_info_get
> > > >
> > > > On Mon, Feb 06, 2017 at 10:59:42AM +0800, Lu, Wenzhuo wrote:
> > > > > Hi Tiwei,
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Bie, Tiwei
> > > > > > Sent: Monday, February 6, 2017 10:51 AM
> > > > > > To: Lu, Wenzhuo
> > > > > > Cc: dev@dpdk.org
> > > > > > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up
> > > > > > rte_eth_dev_info_get
> > > > > >
> > > > > > On Mon, Feb 06, 2017 at 10:41:28AM +0800, Lu, Wenzhuo wrote:
> > > > > > > Hi Tiwei,
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: Bie, Tiwei
> > > > > > > > Sent: Monday, February 6, 2017 10:31 AM
> > > > > > > > To: Lu, Wenzhuo
> > > > > > > > Cc: dev@dpdk.org
> > > > > > > > Subject: Re: [dpdk-dev] [PATCH v2] net/ixgbe: clean up
> > > > > > > > rte_eth_dev_info_get
> > > > > > > >
> > > > > > > > On Mon, Feb 06, 2017 at 10:09:32AM +0800, Wenzhuo Lu wrote:
> > > > > > > > [...]
> > > > > > > > >  static void ixgbe_dcb_init(struct ixgbe_hw *hw, struct
> > > > > > > > > ixgbe_dcb_config *dcb_config); -static int
> > > > > > > > > is_ixgbe_pmd(const char *driver_name);
> > > > > > > > > +static int is_device_supported(struct rte_eth_dev *dev,
> > > > > > > > > +struct eth_driver *drv);
> > > > > > > > >
> > > > > > > >
> > > > > > > > Should be:
> > > > > > > > static bool is_device_supported(struct rte_eth_dev *dev,
> > > > > > > > struct eth_driver *drv);
> > > > > > > O, forget to change it. Thanks.
> > > > > > >
> > > > > > > >
> > > > > > > > >  /* For Virtual Function support */  static int
> > > > > > > > > eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev); @@
> > > > > > > > > -4380,16 +4380,14 @@ static int
> > > > > > > > ixgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev
> > > > > > > > *dev,
> > > > > > > > >  	ixgbe_add_rar(dev, addr, 0, 0);  }
> > > > > > > > >
> > > > > > > > > -static int
> > > > > > > > > -is_ixgbe_pmd(const char *driver_name)
> > > > > > > > > +static bool
> > > > > > > > > +is_device_supported(struct rte_eth_dev *dev, struct
> > > > > > > > > +eth_driver
> > > > > > > > > +*drv)
> > > > > > > > >  {
> > > > > > > > > -	if (!strstr(driver_name, "ixgbe"))
> > > > > > > > > -		return -ENOTSUP;
> > > > > > > > > +	if (strcmp(dev->driver->pci_drv.driver.name,
> > > > > > > > > +		   drv->pci_drv.driver.name))
> > > > > > > > > +		return FALSE;
> > > > > > > > >
> > > > > > > >
> > > > > > > > It would be better to use `false' instead of `FALSE'.
> > > > > > > I see both 'false' and 'FALSE' are defined and used. Is there
> > > > > > > any reason that
> > > > > > 'false' is better?
> > > > > > >
> > > > > >
> > > > > > I think `true' and `false' are standard keywords defined and
> > > > > > reserved by C. So I think it would be better to use them if the
> > > > > > return type is
> > > > `bool'.
> > > > > O, there's no 'bool' in C. You have to define it. The same for 'false' and
> > 'true'.
> > > > >
> > > >
> > > > The `bool', `true' and `false' are all standard keywords defined and
> > > > reserved by C, although the stdbool.h is not used in ixgbe.
> > > >
> > > > C adds this support by introducing a new header stdbool.h:
> > > >
> > > > #ifndef __bool_true_false_are_defined
> > > > #define __bool_true_false_are_defined   1
> > > >
> > > > #ifndef __cplusplus
> > > >
> > > > #define false   0
> > > > #define true    1
> > > >
> > > > #define bool    _Bool
> > > > #if __STDC_VERSION__ < 199901L && __GNUC__ < 3 &&
> > > > !defined(__INTEL_COMPILER)
> > > > typedef int     _Bool;
> > > > #endif
> > > O, you're talking about C99. _Bool is a  keyword added by it. 'bool', 'true',
> > 'false' are  not. That's why this header file have to define them.
> > >
> > 
> > C99 added all those as keyword, although doesn't implement all of them as
> > the builtin type (e.g. int). All of them are standard keywords defined by C99.
> > The `bool', `true' and `false' are defined in section 7.16 of the C99 spec [1] and
> > implemented as macros:
> > 
> > 7.16 Boolean type and values <stdbool.h>
> > 
> > 1 The header <stdbool.h> defines four macros.
> > 
> > 2 The macro
> >           bool
> > expands to _Bool.
> > 
> > 3 The remaining three macros are suitable for use in #if preprocessing
> > directives. They are
> >           true
> > which expands to the integer constant 1,
> >           false
> > which expands to the integer constant 0, and
> >           __bool_true_false_are_defined
> > which expands to the integer constant 1.
> > 
> > 4 Notwithstanding the provisions of 7.1.3, a program may undefine and
> > perhaps then redefine the macros bool, true, and false.222)
> > 
> > Footnotes
> > 
> > 222) See ''future library directions'' (7.26.7).
> > 
> > [1] http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf
> O, I see the divergence. It's about the term 'keyword'. I only count '6.4.1 Keywords'. 
> Anyway, as both 'false'/'true' and 'FALSE'/'TRUE' are defined. I don’t know why we cannot use any of them. If 'FALSE'/'TRUE' is not preferred, better create a new patch to clean them up.
> 

I didn't say we cannot use FALSE/TRUE, I just suggested that false/true
would be better. :-)

I think the reason why introduce _Bool as builtin keyword and implement
others as macros is to provide applications the ability to redefine them
for compatibility issues. I think new code should follow the spec if
possible. :-)

Best regards,
Tiwei Bie

  reply	other threads:[~2017-02-06  5:27 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25  2:39 [dpdk-dev] [PATCH] " Wenzhuo Lu
2017-01-25  3:16 ` Tiwei Bie
2017-01-25  5:13   ` Lu, Wenzhuo
2017-01-25  5:24     ` Tiwei Bie
2017-01-30 12:15       ` Ferruh Yigit
2017-02-03  6:50         ` Lu, Wenzhuo
2017-02-03 11:52           ` Ferruh Yigit
2017-02-01 16:24 ` Ananyev, Konstantin
2017-02-01 17:40   ` Ferruh Yigit
2017-02-01 18:10     ` Ananyev, Konstantin
2017-02-01 18:18       ` Ferruh Yigit
2017-02-03  9:21       ` Iremonger, Bernard
2017-02-03  9:49         ` Ananyev, Konstantin
2017-02-03 10:02           ` Iremonger, Bernard
2017-02-03 12:00             ` Ferruh Yigit
2017-02-06  2:09 ` [dpdk-dev] [PATCH v2] " Wenzhuo Lu
2017-02-06  2:30   ` Tiwei Bie
2017-02-06  2:41     ` Lu, Wenzhuo
2017-02-06  2:51       ` Tiwei Bie
2017-02-06  2:59         ` Lu, Wenzhuo
2017-02-06  3:08           ` Tiwei Bie
2017-02-06  3:45             ` Lu, Wenzhuo
2017-02-06  4:57               ` Tiwei Bie
2017-02-06  5:17                 ` Lu, Wenzhuo
2017-02-06  5:26                   ` Tiwei Bie [this message]
2017-02-07  6:33 ` [dpdk-dev] [PATCH v3] " Wenzhuo Lu
2017-02-07 14:08   ` Ferruh Yigit
2017-02-07 14:09     ` Ferruh Yigit
2017-02-08  0:54       ` Lu, Wenzhuo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170206052655.GA2390@debian \
    --to=tiwei.bie@intel.com \
    --cc=dev@dpdk.org \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).