Skip to contentSkip to conversation

ocfs2: remove some impossible checks

PATCH In review Dan Carpenter 2 participants 2 messages Nov 7, 2013

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

PATCH 1/1 ocfs2: remove some impossible checks

pv_major and pv_minor are unsigned char type so these checks are just noise.

fs/ocfs2/stack_user.c +1 -5
index 4599de7..eca3f93 100644
@@ -808,11 +808,7 @@ static int lvb_to_version(char *lvb, struct ocfs2_protocol_version *ver)
 		&ocfs2_user_plugin.sp_max_proto;
 
 	memcpy(&pv, lvb, sizeof(struct ocfs2_protocol_version));
-	if ((pv.pv_major = LONG_MIN) || (pv.pv_major = LONG_MAX) ||
-	    (pv.pv_major > (u8)-1) || (pv.pv_major < 1))
-		return -ERANGE;
-	if ((pv.pv_minor = LONG_MIN) || (pv.pv_minor = LONG_MAX) ||
-	    (pv.pv_minor > (u8)-1) || (pv.pv_minor < 0))
+	if (pv.pv_major < 1)
 		return -ERANGE;
 	if ((pv.pv_major != max->pv_major) ||
 	    (pv.pv_minor > max->pv_minor))
#1 lore raw
Quoted 4 lines · Dan Carpenter

pv_major and pv_minor are unsigned char type so these checks are just noise.

Thanks. I will incorporate these changes alongwith Mark Fasheh's review comments

Quoted 19 lines
fs/ocfs2/stack_user.c +1 -5
index 4599de7..eca3f93 100644
@@ -808,11 +808,7 @@ static int lvb_to_version(char *lvb, struct ocfs2_protocol_version *ver)
  		&ocfs2_user_plugin.sp_max_proto;
 
  	memcpy(&pv, lvb, sizeof(struct ocfs2_protocol_version));
-	if ((pv.pv_major = LONG_MIN) || (pv.pv_major = LONG_MAX) ||
-	    (pv.pv_major > (u8)-1) || (pv.pv_major < 1))
-		return -ERANGE;
-	if ((pv.pv_minor = LONG_MIN) || (pv.pv_minor = LONG_MAX) ||
-	    (pv.pv_minor > (u8)-1) || (pv.pv_minor < 0))
+	if (pv.pv_major < 1)
  		return -ERANGE;
  	if ((pv.pv_major != max->pv_major) ||
  	    (pv.pv_minor > max->pv_minor))
Signature · 1 line
Goldwyn