Skip to contentSkip to conversation

sunrpc: silence uninitialized variable warning

PATCH New Dan Carpenter 1 participant 1 message Feb 18, 2017

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

PATCH 1/1 sunrpc: silence uninitialized variable warning

kstrtouint() can return a couple different error codes so the check for "ret = -EINVAL" is wrong and static analysis tools correctly complain that we can use "num" without initializing it. It's not super harmful because we check the bounds. But it's also easy enough to fix.

net/sunrpc/xprtsock.c +3 -1
index 956c7bce80d1..311ce92384b7 100644
@@ -3209,7 +3209,9 @@ static int param_set_uint_minmax(const char *val,
 	if (!val)
 		return -EINVAL;
 	ret = kstrtouint(val, 0, &num);
-	if (ret = -EINVAL || num < min || num > max)
+	if (ret)
+		return ret;
+	if (num < min || num > max)
 		return -EINVAL;
 	*((unsigned int *)kp->arg) = num;
 	return 0;