[v1] raw/ifpga: initialize variable to avoid compile error

Message ID 20220316072630.1916479-1-wei.huang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v1] raw/ifpga: initialize variable to avoid compile error |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Functional fail Functional Testing issues

Commit Message

Wei Huang March 16, 2022, 7:26 a.m. UTC
  Compile failed with cflag optimization=1 on Ubuntu20.04 with GCC10.3,
it reported vendor_id and dev_id may be used uninitialized in function
ifpga_rawdev_fill_info().
Actually it's not the truth, the variables are initialized in function
ifpga_get_dev_vendor_id(). To avoid such compile error, the variables
are initialized when they are defined.

Signed-off-by: Wei Huang <wei.huang@intel.com>
Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
Acked-by: Rosen Xu <rosen.xu@intel.com>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Gao, DaxueX March 16, 2022, 9:27 a.m. UTC | #1
> -----Original Message-----
> From: Wei Huang <wei.huang@intel.com>
> Sent: 2022年3月16日 15:27
> To: dev@dpdk.org; thomas@monjalon.net; Xu, Rosen <rosen.xu@intel.com>;
> nipun.gupta@nxp.com; hemant.agrawal@nxp.com
> Cc: stable@dpdk.org; Zhang, Tianfei <tianfei.zhang@intel.com>; Zhang, Qi Z
> <qi.z.zhang@intel.com>; Yigit, Ferruh <ferruh.yigit@intel.com>; Huang, Wei
> <wei.huang@intel.com>
> Subject: [PATCH v1] raw/ifpga: initialize variable to avoid compile error
> 
> Compile failed with cflag optimization=1 on Ubuntu20.04 with GCC10.3, it
> reported vendor_id and dev_id may be used uninitialized in function
> ifpga_rawdev_fill_info().
> Actually it's not the truth, the variables are initialized in function
> ifpga_get_dev_vendor_id(). To avoid such compile error, the variables are
> initialized when they are defined.
> 
> Signed-off-by: Wei Huang <wei.huang@intel.com>
> Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
> Acked-by: Rosen Xu <rosen.xu@intel.com>
> ---

Tested-by: Daxue Gao <daxuex.gao@intel.com>
  
Thomas Monjalon March 16, 2022, 9:40 a.m. UTC | #2
16/03/2022 10:27, Gao, DaxueX:
> From: Wei Huang <wei.huang@intel.com>
> > 
> > Compile failed with cflag optimization=1 on Ubuntu20.04 with GCC10.3, it
> > reported vendor_id and dev_id may be used uninitialized in function
> > ifpga_rawdev_fill_info().
> > Actually it's not the truth, the variables are initialized in function
> > ifpga_get_dev_vendor_id(). To avoid such compile error, the variables are
> > initialized when they are defined.
> > 
> > Signed-off-by: Wei Huang <wei.huang@intel.com>
> > Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
> > Acked-by: Rosen Xu <rosen.xu@intel.com>
> > ---
> 
> Tested-by: Daxue Gao <daxuex.gao@intel.com>

We need a "Fixes:" line to help backports, please.
  
Thomas Monjalon March 16, 2022, 7:34 p.m. UTC | #3
16/03/2022 10:40, Thomas Monjalon:
> 16/03/2022 10:27, Gao, DaxueX:
> > From: Wei Huang <wei.huang@intel.com>
> > > 
> > > Compile failed with cflag optimization=1 on Ubuntu20.04 with GCC10.3, it
> > > reported vendor_id and dev_id may be used uninitialized in function
> > > ifpga_rawdev_fill_info().
> > > Actually it's not the truth, the variables are initialized in function
> > > ifpga_get_dev_vendor_id(). To avoid such compile error, the variables are
> > > initialized when they are defined.
> > > 
> > > Signed-off-by: Wei Huang <wei.huang@intel.com>
> > > Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
> > > Acked-by: Rosen Xu <rosen.xu@intel.com>
> > 
> > Tested-by: Daxue Gao <daxuex.gao@intel.com>
> 
> We need a "Fixes:" line to help backports, please.

Added this:

Fixes: 9c006c45d0c5 ("raw/ifpga: scan PCIe BDF device tree")
Cc: stable@dpdk.org

Applied in last minute.
  

Patch

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 26c1366..6d4117c 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -225,7 +225,8 @@  static int ifpga_rawdev_fill_info(struct ifpga_rawdev *ifpga_dev)
 
 	unsigned int dom, bus, dev;
 	int func;
-	uint32_t dev_id, vendor_id;
+	uint32_t dev_id = 0;
+	uint32_t vendor_id = 0;
 
 	adapter = ifpga_dev ? ifpga_rawdev_get_priv(ifpga_dev->rawdev) : NULL;
 	if (!adapter)