diff mbox

linux-generic: dpdk: use memset() to initialize dev_info

Message ID 1463139647-10048-1-git-send-email-matias.elo@nokia.com
State Accepted
Commit 3589ee140d823019c550e953253c9dfc2021dc03
Headers show

Commit Message

Elo, Matias (Nokia - FI/Espoo) May 13, 2016, 11:40 a.m. UTC
Clang build fails due to a missing field in initializer
error. This is a known clang bug
(https://llvm.org/bugs/show_bug.cgi?id=21689). Circumvent
this by using memset() instead.

Signed-off-by: Matias Elo <matias.elo@nokia.com>
---
 platform/linux-generic/pktio/dpdk.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Bill Fischofer May 14, 2016, 9:41 p.m. UTC | #1
On Fri, May 13, 2016 at 6:40 AM, Matias Elo <matias.elo@nokia.com> wrote:

> Clang build fails due to a missing field in initializer

> error. This is a known clang bug

> (https://llvm.org/bugs/show_bug.cgi?id=21689). Circumvent

> this by using memset() instead.

>

> Signed-off-by: Matias Elo <matias.elo@nokia.com>

>


Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>



> ---

>  platform/linux-generic/pktio/dpdk.c | 12 +++++++++---

>  1 file changed, 9 insertions(+), 3 deletions(-)

>

> diff --git a/platform/linux-generic/pktio/dpdk.c

> b/platform/linux-generic/pktio/dpdk.c

> index e6af8fb..831dc26 100644

> --- a/platform/linux-generic/pktio/dpdk.c

> +++ b/platform/linux-generic/pktio/dpdk.c

> @@ -177,11 +177,13 @@ static int dpdk_netdev_is_valid(const char *s)

>

>  static uint32_t dpdk_vdev_mtu_get(uint8_t port_id)

>  {

> -       struct rte_eth_dev_info dev_info = {0};

> +       struct rte_eth_dev_info dev_info;

>         struct ifreq ifr;

>         int sockfd;

>         uint32_t mtu;

>

> +       memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));

> +

>         rte_eth_dev_info_get(port_id, &dev_info);

>         if_indextoname(dev_info.if_index, ifr.ifr_name);

>

> @@ -219,11 +221,13 @@ static uint32_t dpdk_mtu_get(pktio_entry_t

> *pktio_entry)

>

>  static int dpdk_vdev_promisc_mode_get(uint8_t port_id)

>  {

> -       struct rte_eth_dev_info dev_info = {0};

> +       struct rte_eth_dev_info dev_info;

>         struct ifreq ifr;

>         int sockfd;

>         int mode;

>

> +       memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));

> +

>         rte_eth_dev_info_get(port_id, &dev_info);

>         if_indextoname(dev_info.if_index, ifr.ifr_name);

>

> @@ -240,11 +244,13 @@ static int dpdk_vdev_promisc_mode_get(uint8_t

> port_id)

>

>  static int dpdk_vdev_promisc_mode_set(uint8_t port_id, int enable)

>  {

> -       struct rte_eth_dev_info dev_info = {0};

> +       struct rte_eth_dev_info dev_info;

>         struct ifreq ifr;

>         int sockfd;

>         int mode;

>

> +       memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));

> +

>         rte_eth_dev_info_get(port_id, &dev_info);

>         if_indextoname(dev_info.if_index, ifr.ifr_name);

>

> --

> 1.9.1

>

> _______________________________________________

> lng-odp mailing list

> lng-odp@lists.linaro.org

> https://lists.linaro.org/mailman/listinfo/lng-odp

>
Maxim Uvarov May 16, 2016, 12:58 p.m. UTC | #2
Merged,
Maxim.

On 05/15/16 00:41, Bill Fischofer wrote:
>
>
> On Fri, May 13, 2016 at 6:40 AM, Matias Elo <matias.elo@nokia.com 
> <mailto:matias.elo@nokia.com>> wrote:
>
>     Clang build fails due to a missing field in initializer
>     error. This is a known clang bug
>     (https://llvm.org/bugs/show_bug.cgi?id=21689). Circumvent
>     this by using memset() instead.
>
>     Signed-off-by: Matias Elo <matias.elo@nokia.com
>     <mailto:matias.elo@nokia.com>>
>
>
> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>>
>
>     ---
>      platform/linux-generic/pktio/dpdk.c | 12 +++++++++---
>      1 file changed, 9 insertions(+), 3 deletions(-)
>
>     diff --git a/platform/linux-generic/pktio/dpdk.c
>     b/platform/linux-generic/pktio/dpdk.c
>     index e6af8fb..831dc26 100644
>     --- a/platform/linux-generic/pktio/dpdk.c
>     +++ b/platform/linux-generic/pktio/dpdk.c
>     @@ -177,11 +177,13 @@ static int dpdk_netdev_is_valid(const char *s)
>
>      static uint32_t dpdk_vdev_mtu_get(uint8_t port_id)
>      {
>     -       struct rte_eth_dev_info dev_info = {0};
>     +       struct rte_eth_dev_info dev_info;
>             struct ifreq ifr;
>             int sockfd;
>             uint32_t mtu;
>
>     +       memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
>     +
>             rte_eth_dev_info_get(port_id, &dev_info);
>             if_indextoname(dev_info.if_index, ifr.ifr_name);
>
>     @@ -219,11 +221,13 @@ static uint32_t dpdk_mtu_get(pktio_entry_t
>     *pktio_entry)
>
>      static int dpdk_vdev_promisc_mode_get(uint8_t port_id)
>      {
>     -       struct rte_eth_dev_info dev_info = {0};
>     +       struct rte_eth_dev_info dev_info;
>             struct ifreq ifr;
>             int sockfd;
>             int mode;
>
>     +       memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
>     +
>             rte_eth_dev_info_get(port_id, &dev_info);
>             if_indextoname(dev_info.if_index, ifr.ifr_name);
>
>     @@ -240,11 +244,13 @@ static int
>     dpdk_vdev_promisc_mode_get(uint8_t port_id)
>
>      static int dpdk_vdev_promisc_mode_set(uint8_t port_id, int enable)
>      {
>     -       struct rte_eth_dev_info dev_info = {0};
>     +       struct rte_eth_dev_info dev_info;
>             struct ifreq ifr;
>             int sockfd;
>             int mode;
>
>     +       memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
>     +
>             rte_eth_dev_info_get(port_id, &dev_info);
>             if_indextoname(dev_info.if_index, ifr.ifr_name);
>
>     --
>     1.9.1
>
>     _______________________________________________
>     lng-odp mailing list
>     lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>     https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c
index e6af8fb..831dc26 100644
--- a/platform/linux-generic/pktio/dpdk.c
+++ b/platform/linux-generic/pktio/dpdk.c
@@ -177,11 +177,13 @@  static int dpdk_netdev_is_valid(const char *s)
 
 static uint32_t dpdk_vdev_mtu_get(uint8_t port_id)
 {
-	struct rte_eth_dev_info dev_info = {0};
+	struct rte_eth_dev_info dev_info;
 	struct ifreq ifr;
 	int sockfd;
 	uint32_t mtu;
 
+	memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
+
 	rte_eth_dev_info_get(port_id, &dev_info);
 	if_indextoname(dev_info.if_index, ifr.ifr_name);
 
@@ -219,11 +221,13 @@  static uint32_t dpdk_mtu_get(pktio_entry_t *pktio_entry)
 
 static int dpdk_vdev_promisc_mode_get(uint8_t port_id)
 {
-	struct rte_eth_dev_info dev_info = {0};
+	struct rte_eth_dev_info dev_info;
 	struct ifreq ifr;
 	int sockfd;
 	int mode;
 
+	memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
+
 	rte_eth_dev_info_get(port_id, &dev_info);
 	if_indextoname(dev_info.if_index, ifr.ifr_name);
 
@@ -240,11 +244,13 @@  static int dpdk_vdev_promisc_mode_get(uint8_t port_id)
 
 static int dpdk_vdev_promisc_mode_set(uint8_t port_id, int enable)
 {
-	struct rte_eth_dev_info dev_info = {0};
+	struct rte_eth_dev_info dev_info;
 	struct ifreq ifr;
 	int sockfd;
 	int mode;
 
+	memset(&dev_info, 0, sizeof(struct rte_eth_dev_info));
+
 	rte_eth_dev_info_get(port_id, &dev_info);
 	if_indextoname(dev_info.if_index, ifr.ifr_name);