Message ID | 1348836538.3626.21.camel@x61.thuisdomein (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Roland Dreier |
Headers | show |
You could use: u16 uninitialized_var(vlan); instead. Although this in the special QP data flow, I still prefer to avoid adding extra code (even setting initial values at procedure entry). The line above will also do the job. "uninitialized_var" is used elsewhere in the driver. See, for example, mlx4_ib_post_send() in the same file (qp.c). -Jack On Friday 28 September 2012 14:48, Paul Bolle wrote: > Building qp.o (part of the "Mellanox ConnectX HCA support" driver) > triggers this GCC warning: > drivers/infiniband/hw/mlx4/qp.c: In function ‘mlx4_ib_post_send’: > drivers/infiniband/hw/mlx4/qp.c:1828:30: warning: ‘vlan’ may be used uninitialized in this function [-Wmaybe-uninitialized] > drivers/infiniband/hw/mlx4/qp.c:1718:6: note: ‘vlan’ was declared here > > Looking at the code it is clear 'vlan' is only set and used if 'is_eth' > is non-zero. But there's no harm in initializing 'vlan' to 0 (which > matches ib_get_cached_gid()'s default return) to silence GCC. > > Signed-off-by: Paul Bolle <pebolle@tiscali.nl> > --- > 0) I noticed this warning while building v3.6-rc7 on current Fedora 17, > using Fedora's default config. > > 1) Compile tested only. I tested against v3.6-rc7, with commit > a41262bb5721f2b708ee8b23f67be2f2e16a2fab ("IB/mlx4: SR-IOV IB context > objects and proxy/tunnel SQP") from linux-next cherry-picked, to take > into account a trivial context change in linux-next. > > drivers/infiniband/hw/mlx4/qp.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c > index a862251..71fdda6 100644 > --- a/drivers/infiniband/hw/mlx4/qp.c > +++ b/drivers/infiniband/hw/mlx4/qp.c > @@ -1715,7 +1715,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr, > int is_eth; > int is_vlan = 0; > int is_grh; > - u16 vlan; > + u16 vlan = 0; > int err = 0; > > send_size = 0; -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, 2012-10-10 at 09:23 +0200, Jack Morgenstein wrote: > You could use: > > u16 uninitialized_var(vlan); > > instead. I guess we'd better just wait and see whether uninitialized_var() survives before discussing your suggestion (see the thread starting at https://lkml.org/lkml/2012/10/26/508 ). > Although this in the special QP data flow, I still prefer to avoid adding extra code (even setting > initial values at procedure entry). The line above will also do the job. "uninitialized_var" > is used elsewhere in the driver. See, for example, mlx4_ib_post_send() in the same file (qp.c). Paul Bolle -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 10/29/12 10:50, Paul Bolle wrote: > On Wed, 2012-10-10 at 09:23 +0200, Jack Morgenstein wrote: >> You could use: >> >> u16 uninitialized_var(vlan); >> >> instead. > > I guess we'd better just wait and see whether uninitialized_var() > survives before discussing your suggestion (see the thread starting at > https://lkml.org/lkml/2012/10/26/508 ). > >> Although this in the special QP data flow, I still prefer to avoid adding extra code (even setting >> initial values at procedure entry). The line above will also do the job. "uninitialized_var" >> is used elsewhere in the driver. See, for example, mlx4_ib_post_send() in the same file (qp.c). (replying to an e-mail of a few months ago) If there are no further objections I'd like to see this patch to go upstream. It fixes an annoying compiler warning and I don't think that this patch has a negative performance impact. Thanks, Bart. -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index a862251..71fdda6 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c @@ -1715,7 +1715,7 @@ static int build_mlx_header(struct mlx4_ib_sqp *sqp, struct ib_send_wr *wr, int is_eth; int is_vlan = 0; int is_grh; - u16 vlan; + u16 vlan = 0; int err = 0; send_size = 0;
Building qp.o (part of the "Mellanox ConnectX HCA support" driver) triggers this GCC warning: drivers/infiniband/hw/mlx4/qp.c: In function ‘mlx4_ib_post_send’: drivers/infiniband/hw/mlx4/qp.c:1828:30: warning: ‘vlan’ may be used uninitialized in this function [-Wmaybe-uninitialized] drivers/infiniband/hw/mlx4/qp.c:1718:6: note: ‘vlan’ was declared here Looking at the code it is clear 'vlan' is only set and used if 'is_eth' is non-zero. But there's no harm in initializing 'vlan' to 0 (which matches ib_get_cached_gid()'s default return) to silence GCC. Signed-off-by: Paul Bolle <pebolle@tiscali.nl> --- 0) I noticed this warning while building v3.6-rc7 on current Fedora 17, using Fedora's default config. 1) Compile tested only. I tested against v3.6-rc7, with commit a41262bb5721f2b708ee8b23f67be2f2e16a2fab ("IB/mlx4: SR-IOV IB context objects and proxy/tunnel SQP") from linux-next cherry-picked, to take into account a trivial context change in linux-next. drivers/infiniband/hw/mlx4/qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)