diff mbox series

[ibsim,05/23] sim_cmd.c: fix ‘orig’ may be used uninitialized

Message ID 20190102131318.5765-5-honli@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series [ibsim,01/23] move sim_cmd_file into ibsim/sim_cmd.c | expand

Commit Message

Honggang LI Jan. 2, 2019, 1:13 p.m. UTC
cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables  -Wall -g -Werror -Wno-deprecated-declarations -fpic -I. -I../include -I/usr/include -c -o sim_cmd.o sim_cmd.c
sim_cmd.c: In function ‘do_cmd’:
sim_cmd.c:911:11: error: ‘orig’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
  nodeid = expand_name(orig, name, &sp);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
sim_cmd.c:897:19: note: ‘orig’ was declared here
  char *s = line, *orig, *sp, *nodeid, *attr, *field, *field_trim, *end_ptr;

Signed-off-by: Honggang Li <honli@redhat.com>
---
 ibsim/sim_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Hal Rosenstock Jan. 3, 2019, 3:40 p.m. UTC | #1
On 1/2/2019 8:13 AM, Honggang Li wrote:
> cc -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables  -Wall -g -Werror -Wno-deprecated-declarations -fpic -I. -I../include -I/usr/include -c -o sim_cmd.o sim_cmd.c
> sim_cmd.c: In function ‘do_cmd’:
> sim_cmd.c:911:11: error: ‘orig’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   nodeid = expand_name(orig, name, &sp);
>            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> sim_cmd.c:897:19: note: ‘orig’ was declared here
>   char *s = line, *orig, *sp, *nodeid, *attr, *field, *field_trim, *end_ptr;
> 
> Signed-off-by: Honggang Li <honli@redhat.com>

Thanks. Applied.

-- Hal
diff mbox series

Patch

diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index 92343525645b..fa5ff9baea6b 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -894,7 +894,7 @@  static int parse_vl_num(char *attr, char *field, int *vl)
 
 static int do_perf_counter_set(FILE *f, char *line)
 {
-	char *s = line, *orig, *sp, *nodeid, *attr, *field, *field_trim, *end_ptr;
+	char *s = line, *orig = NULL, *sp, *nodeid, *attr, *field, *field_trim, *end_ptr;
 	Node *node;
 	int portnum, vl;
 	uint64_t value;