[PATCH infiniband-diags] ibportstate.c: Fix unsigned comparison warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



src/ibportstate.c:450: warning: comparison of unsigned expression < 0 is always false
src/ibportstate.c:454: warning: comparison of unsigned expression < 0 is always false
src/ibportstate.c:458: warning: comparison of unsigned expression < 0 is always false
src/ibportstate.c:462: warning: comparison of unsigned expression < 0 is always false
src/ibportstate.c:483: warning: comparison of unsigned expression < 0 is always false
src/ibportstate.c:500: warning: comparison of unsigned expression < 0 is always false
src/ibportstate.c:504: warning: comparison of unsigned expression < 0 is always false

Signed-off-by: Hal Rosenstock <hal@xxxxxxxxxxxx>
---
diff --git a/src/ibportstate.c b/src/ibportstate.c
index 47e9133..cb47aa9 100644
--- a/src/ibportstate.c
+++ b/src/ibportstate.c
@@ -447,40 +447,40 @@ int main(int argc, char **argv)
 			val = strtoull(argv[i], 0, 0);
 			switch (j) {
 			case SPEED:
-				if (val < 0 || val > 15)
+				if (val > 15)
 					IBEXIT("invalid speed value %ld", val);
 				break;
 			case ESPEED:
-				if (val < 0 || val > 31)
+				if (val > 31)
 					IBEXIT("invalid extended speed value %ld", val);
 				break;
 			case FDR10SPEED:
-				if (val < 0 || val > 1)
+				if (val > 1)
 					IBEXIT("invalid fdr10 speed value %ld", val);
 				break;
 			case WIDTH:
-				if (val < 0 || (val > 15 && val != 255))
+				if ((val > 15 && val != 255))
 					IBEXIT("invalid width value %ld", val);
 				break;
 			case VLS:
-				if (val <= 0 || val > 5)
+				if (val == 0 || val > 5)
 					IBEXIT("invalid vls value %ld", val);
 				break;
 			case MTU:
-				if (val <= 0 || val > 5)
+				if (val == 0 || val > 5)
 					IBEXIT("invalid mtu value %ld", val);
 				break;
 			case LID:
-				if (val <= 0 || val >= 0xC000)
+				if (val == 0 || val >= 0xC000)
 					IBEXIT("invalid lid value 0x%lx", val);
 				break;
 			case SMLID:
-				if (val <= 0 || val >= 0xC000)
+				if (val == 0 || val >= 0xC000)
 					IBEXIT("invalid smlid value 0x%lx",
 						val);
 				break;
 			case LMC:
-				if (val < 0 || val > 7)
+				if (val > 7)
 					IBEXIT("invalid lmc value %ld", val);
 				break;
 			case MKEY:
@@ -497,11 +497,11 @@ int main(int argc, char **argv)
 				/* All 64-bit values are legal */
 				break;
 			case MKEYLEASE:
-				if (val < 0 || val > 0xFFFF)
+				if (val > 0xFFFF)
 					IBEXIT("invalid mkey lease time %ld", val);
 				break;
 			case MKEYPROT:
-				if (val < 0 || val > 3)
+				if (val > 3)
 					IBEXIT("invalid mkey protection bit setting %ld", val);
 			}
 			*port_args[j].val = val;
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux