From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <thomas.monjalon@6wind.com>
Received: from mail-qg0-f51.google.com (mail-qg0-f51.google.com
 [209.85.192.51]) by dpdk.org (Postfix) with ESMTP id 24B9A2C64
 for <dev@dpdk.org>; Mon,  4 Apr 2016 16:12:32 +0200 (CEST)
Received: by mail-qg0-f51.google.com with SMTP id c6so22218568qga.1
 for <dev@dpdk.org>; Mon, 04 Apr 2016 07:12:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=6wind-com.20150623.gappssmtp.com; s=20150623;
 h=from:to:cc:subject:date:message-id:organization:user-agent
 :in-reply-to:references:mime-version:content-transfer-encoding;
 bh=HZ7vn67l0e4JLeYO0QUi2yl08NhD/LGH3wBx+DJvytc=;
 b=fvQdbh5RdARheunnPL2aZlL30QIYf8oaiALQKkLWhS3IfCo7mg3wlf8XZdwBhbpm+T
 iNTOh6awKc4JBf9bt9k4Yul4SUphzrXSfiqyQx2v9ZHUaPrg5eVYV2e/AZC4CGmev4wl
 IykhbtKgbxztux/woMcqRvBON7RQOJgMVdx8JnXB2GcvF99QW18woxY8F2yY6RVSVrC0
 /jbH9ggc41B0AtfWLk0YiGUOdz8jlkZJwz+7iDeyLEdjcvD3vuk5Comlfr+C2EDzlArE
 Hxe0bkHfjZ+uoBIKEzaKZ3stevd91ptf6CTmStuPXQPmglZu8h+OKTdKmJd1YOGsDgSJ
 MTug==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:organization
 :user-agent:in-reply-to:references:mime-version
 :content-transfer-encoding;
 bh=HZ7vn67l0e4JLeYO0QUi2yl08NhD/LGH3wBx+DJvytc=;
 b=HjqoHIgo62+UgGoexdKUQ0sqlNlcbkmt444TJRL/SEjaVPtyLWzWyjZpQAH+cZFjch
 G9kl2OS54y39+lIQBUxQF3SxC2PvfKKbluAr200o8rBIdOp6yqv1mg5iyS5/VrwvEU84
 oQINwq1wiosSmzaTD9XZACY9wcOtmV+6f1kIv669XYJ//rY60epeKycyJiJD01//ujCv
 +i9LftCbjyn0W/cTGGb8n7qs010b0BHJtaQ0LU1i0tWPRYSrwYx2qZMi4aQLTZ9gfngy
 GfHDg+qXA9A+3sBTxnZelycUiyAcxD0ma0nEpWQfvgybEEDgqyooiemiLNdp5rah5fqo
 EXpw==
X-Gm-Message-State: AD7BkJJDJql0Y3k12wnqNfeM6VONZsZxxdOEbk6zJJr7lutNepcf7E8V0yjcIvaZlX3pjfNg
X-Received: by 10.194.24.39 with SMTP id r7mr17451700wjf.86.1459779151433;
 Mon, 04 Apr 2016 07:12:31 -0700 (PDT)
Received: from xps13.localnet (91.111.75.86.rev.sfr.net. [86.75.111.91])
 by smtp.gmail.com with ESMTPSA id a1sm29296564wje.43.2016.04.04.07.12.30
 (version=TLSv1/SSLv3 cipher=OTHER);
 Mon, 04 Apr 2016 07:12:30 -0700 (PDT)
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: Keith Wiles <keith.wiles@intel.com>
Cc: dev@dpdk.org, huawei.xie@intel.com, yuanhan.liu@linux.intel.com,
 adrien.mazarguil@6wind.com
Date: Mon, 04 Apr 2016 16:10:54 +0200
Message-ID: <22459074.ccNYgpjxy1@xps13>
Organization: 6WIND
User-Agent: KMail/4.14.10 (Linux/4.1.6-1-ARCH; KDE/4.14.11; x86_64; ; )
In-Reply-To: <1459538419-81284-1-git-send-email-keith.wiles@intel.com>
References: <1459538419-81284-1-git-send-email-keith.wiles@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"
Subject: Re: [dpdk-dev] [PATCH] gcc compiler option -Og warnings fix
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 04 Apr 2016 14:12:32 -0000

2016-04-01 14:20, Keith Wiles:
> The new compiler option -Og causes a few warning on variables
> being used before being set warnings.

Sometimes the compiler is wrong. It seems this option makes it
even wronger. Why not use -Wno-error with -Og?

More details below:

>  lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
>  lib/librte_lpm/rte_lpm6.c                 | 1 +
>  lib/librte_vhost/vhost_rxtx.c             | 4 ++--

There are also some warnings in mlx drivers, solved with patch below:

--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -5415,7 +5415,7 @@ mlx4_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
        int err = 0;
        struct ibv_context *attr_ctx = NULL;
        struct ibv_device_attr device_attr;
-       unsigned int vf;
+       unsigned int vf = 0;
        int idx;
        int i;
 
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -260,8 +260,8 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
        int err = 0;
        struct ibv_context *attr_ctx = NULL;
        struct ibv_device_attr device_attr;
-       unsigned int vf;
-       unsigned int mps;
+       unsigned int vf = 0;
+       unsigned int mps = 0;
        int idx;
        int i;

> --- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
> @@ -152,7 +152,7 @@ pci_get_uio_dev(struct rte_pci_device *dev, char *dstbuf,
>  			   unsigned int buflen, int create)
>  {
>  	struct rte_pci_addr *loc = &dev->addr;
> -	unsigned int uio_num;
> +	unsigned int uio_num = 0;

This one is OK to fix.

> --- a/lib/librte_lpm/rte_lpm6.c
> +++ b/lib/librte_lpm/rte_lpm6.c
> @@ -381,6 +381,7 @@ add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl,
>  	int8_t bitshift;
>  	uint8_t bits_covered;
>  
> +	*tbl_next = NULL;
>  	/*
>  	 * Calculate index to the table based on the number and position
>  	 * of the bytes being inspected in this step.

It would be more logical to set this variable in the right condition branch:
--- a/lib/librte_lpm/rte_lpm6.c
+++ b/lib/librte_lpm/rte_lpm6.c
@@ -429,6 +429,7 @@ add_step(struct rte_lpm6 *lpm, struct rte_lpm6_tbl_entry *tbl,
                        }
                }
 
+               *tbl_next = NULL;
                return 0;
        }

> --- a/lib/librte_vhost/vhost_rxtx.c
> +++ b/lib/librte_vhost/vhost_rxtx.c
> @@ -295,7 +295,7 @@ virtio_dev_rx(struct virtio_net *dev, uint16_t queue_id,
>  	for (i = 0; i < count; i++) {
>  		uint16_t desc_idx = desc_indexes[i];
>  		uint16_t used_idx = (res_start_idx + i) & (vq->size - 1);
> -		uint32_t copied;
> +		uint32_t copied = 0;

This variable is not used if copy_mbuf_to_desc fails, so it is always
initialised before being used.
We can workaround the silly compiler while avoiding a performance hit
by resetting the variable only in the error case of copy_mbuf_to_desc:

--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -147,8 +147,10 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq,
        struct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, 0, 0, 0, 0, 0}, 0};
 
        desc = &vq->desc[desc_idx];
-       if (unlikely(desc->len < vq->vhost_hlen))
+       if (unlikely(desc->len < vq->vhost_hlen)) {
+               *copied = 0;
                return -1;
+       }

>  		err = copy_mbuf_to_desc(dev, vq, pkts[i], desc_idx, &copied);
> @@ -531,7 +531,7 @@ virtio_dev_merge_rx(struct virtio_net *dev, uint16_t queue_id,
>  {
>  	struct vhost_virtqueue *vq;
>  	uint32_t pkt_idx = 0, nr_used = 0;
> -	uint16_t start, end;
> +	uint16_t start = 0, end = 0;

I don't understand this one because the variables are not used if
reserve_avail_buf_mergeable fails.
I don't see any smart workaround.
Huawei, Yuanhan, can we expect a little slowdown with this change?