Skip to contentSkip to conversation

Review recent changes in tc_util.c

PATCH New Phil Sutter 1 participant 3 messages Nov 15, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Review recent changes in tc_util.c

This silences a spurious compiler warning with gcc-7 and eliminates a needless conditional identified while investigating the warning.

Phil Sutter (2):
tc_util: Drop needless pointer check
tc_util: Silence spurious compiler warning

 tc/tc_util.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
Signature · 1 line
2.13.1
#1 lore raw

PATCH 1/2 tc_util: Drop needless pointer check

The function parse_action_control_slash() returns early if 'p' is NULL, so after the first call to action_a2n(), 'p' is guaranteed not to be NULL. Otherwise, the assignment '*p = 0' above would dereference the NULL pointer already anyway, so just drop this check here.

---
 tc/tc_util.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tc/tc_util.c +1 -2
index b39e5508235ed..b01362533cd56 100644
@@ -631,8 +631,7 @@ int parse_action_control_slash(int *argc_p, char ***argv_p,
 							 allow_num);
 	*p = 0;
 	if (action_a2n(*argv, &result1, allow_num)) {
-		if (p)
-			*p = '/';
+		*p = '/';
 		return -1;
 	}
 
Signature · 1 line
2.13.1
#2 lore raw

PATCH 2/2 tc_util: Silence spurious compiler warning

In reply to Phil Sutter

GCC version 7.2.1 complains that 'result1' may be used uninitialized in parse_action_control_slash_spaces(). This should not be possible in practice, so the actual value 'result1' is initialized with does not matter.

---
 tc/tc_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tc/tc_util.c +1 -1
index b01362533cd56..55cdec5dfbe0a 100644
@@ -573,7 +573,7 @@ static int parse_action_control_slash_spaces(int *argc_p, char ***argv_p,
 {
 	int argc = *argc_p;
 	char **argv = *argv_p;
-	int result1, result2;
+	int result1 = -1, result2;
 	int *result_p = &result1;
 	int ok = 0;
 	int ret;
Signature · 1 line
2.13.1