diff mbox

[4/6] Fix maybe uninitialized issue

Message ID 20180720025038.9365-5-honli@redhat.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Honggang LI July 20, 2018, 2:50 a.m. UTC
From: Honggang Li <honli@redhat.com>

make[2]: Entering directory '/home/honli/upstream-repos/opensm/opensm'
depbase=`echo osm_sa_mcmember_record.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DHAVE_CONFIG_H -I. -I../include -I../include/opensm  -I./../include -I./../../libibumad/include -I/usr/local/include   -Werror -Wall -Wwrite-strings -g -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE=1 -g -O2 -MT osm_sa_mcmember_record.o -MD -MP -MF $depbase.Tpo -c -o osm_sa_mcmember_record.o osm_sa_mcmember_record.c &&\
mv -f $depbase.Tpo $depbase.Po
osm_sa_mcmember_record.c: In function ‘osm_mcmr_rcv_process’:
osm_sa_mcmember_record.c:1579:3: error: ‘port_gid’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   memcpy(&(match_rec.port_gid), &port_gid, sizeof(ib_gid_t));
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
osm_sa_mcmember_record.c:1478:11: note: ‘port_gid’ was declared here
  ib_gid_t port_gid;
           ^~~~~~~~
cc1: all warnings being treated as errors

Signed-off-by: Honggang Li <honli@redhat.com>
---
 opensm/osm_sa_mcmember_record.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Hal Rosenstock July 25, 2018, 11:45 a.m. UTC | #1
On 7/19/2018 10:50 PM, Honggang LI wrote:
> From: Honggang Li <honli@redhat.com>
> 
> make[2]: Entering directory '/home/honli/upstream-repos/opensm/opensm'
> depbase=`echo osm_sa_mcmember_record.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
> gcc -DHAVE_CONFIG_H -I. -I../include -I../include/opensm  -I./../include -I./../../libibumad/include -I/usr/local/include   -Werror -Wall -Wwrite-strings -g -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE=1 -g -O2 -MT osm_sa_mcmember_record.o -MD -MP -MF $depbase.Tpo -c -o osm_sa_mcmember_record.o osm_sa_mcmember_record.c &&\
> mv -f $depbase.Tpo $depbase.Po
> osm_sa_mcmember_record.c: In function ‘osm_mcmr_rcv_process’:
> osm_sa_mcmember_record.c:1579:3: error: ‘port_gid’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    memcpy(&(match_rec.port_gid), &port_gid, sizeof(ib_gid_t));
>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> osm_sa_mcmember_record.c:1478:11: note: ‘port_gid’ was declared here
>   ib_gid_t port_gid;
>            ^~~~~~~~
> cc1: all warnings being treated as errors
> 
> Signed-off-by: Honggang Li <honli@redhat.com>
> ---
>  opensm/osm_sa_mcmember_record.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/opensm/osm_sa_mcmember_record.c b/opensm/osm_sa_mcmember_record.c
> index dc805bcf64f8..db2188e5de5a 100644
> --- a/opensm/osm_sa_mcmember_record.c
> +++ b/opensm/osm_sa_mcmember_record.c
> @@ -1478,6 +1478,8 @@ static void mcmr_by_comp_mask(osm_sa_t * sa, const ib_member_rec_t * p_rcvd_rec,
>  	ib_gid_t port_gid;
>  	boolean_t proxy_join = FALSE;
>  
> +	memset(&port_gid, 0, sizeof(port_gid));
> +
>  	OSM_LOG_ENTER(sa->p_log);
>  
>  	OSM_LOG(sa->p_log, OSM_LOG_DEBUG,
> 

Thanks. Applied.

Note just moved memset down after OSM_LOG call.

-- Hal
--
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 mbox

Patch

diff --git a/opensm/osm_sa_mcmember_record.c b/opensm/osm_sa_mcmember_record.c
index dc805bcf64f8..db2188e5de5a 100644
--- a/opensm/osm_sa_mcmember_record.c
+++ b/opensm/osm_sa_mcmember_record.c
@@ -1478,6 +1478,8 @@  static void mcmr_by_comp_mask(osm_sa_t * sa, const ib_member_rec_t * p_rcvd_rec,
 	ib_gid_t port_gid;
 	boolean_t proxy_join = FALSE;
 
+	memset(&port_gid, 0, sizeof(port_gid));
+
 	OSM_LOG_ENTER(sa->p_log);
 
 	OSM_LOG(sa->p_log, OSM_LOG_DEBUG,