devices: Fix an off by one error in the maximum device checks
authorAlan Cox <alan@linux.intel.com>
Sat, 22 Apr 2017 08:26:21 +0000 (09:26 +0100)
committerAlan Cox <alan@linux.intel.com>
Sat, 22 Apr 2017 08:26:21 +0000 (09:26 +0100)
If we have 1 major then the highest permitted device is 0,255 not 1, 255.

This only ever showed up if you either mknod a device once bigger than that
supported or attempt to boot a device one higher than the limit.

33 files changed:
Kernel/platform-68hc11test/devices.c
Kernel/platform-atarist/devices.c
Kernel/platform-coco2/devices.c
Kernel/platform-coco2cart/devices.c
Kernel/platform-coco3/devices.c
Kernel/platform-dragon-nx32/devices.c
Kernel/platform-dragon/devices.c
Kernel/platform-micropack/devices.c
Kernel/platform-msp430fr5969/devices.c
Kernel/platform-msx1/devices.c
Kernel/platform-msx2/devices.c
Kernel/platform-mtx/devices.c
Kernel/platform-multicomp09/devices.c
Kernel/platform-n8vem-mark4/devices.c
Kernel/platform-nc100/devices.c
Kernel/platform-p112/devices.c
Kernel/platform-pcw8256/devices.c
Kernel/platform-pdp11/devices.c
Kernel/platform-plus3/devices.c
Kernel/platform-px4plus/devices.c
Kernel/platform-socz80/devices.c
Kernel/platform-tgl6502/devices.c
Kernel/platform-trs80/devices.c
Kernel/platform-ubee/devices.c
Kernel/platform-v65/devices.c
Kernel/platform-v68-banked/devices.c
Kernel/platform-v68-softmmu/devices.c
Kernel/platform-v68/devices.c
Kernel/platform-z80pack-lite/devices.c
Kernel/platform-z80pack/devices.c
Kernel/platform-z80pack32/devices.c
Kernel/platform-zeta-v2/devices.c
Kernel/platform-zx128/devices.c

index df1dcdd..6c15d6e 100644 (file)
@@ -27,7 +27,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index fe99fe2..50f0f27 100644 (file)
@@ -28,7 +28,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 5c3689b..f62ec4a 100644 (file)
@@ -37,7 +37,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 3bcb457..d0c5488 100644 (file)
@@ -39,7 +39,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 79445ca..27c6c4a 100644 (file)
@@ -38,7 +38,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-  if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+  if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
     return false;
   else
     return true;
index 4b37f75..afa4c6c 100644 (file)
@@ -42,7 +42,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index a188243..960fbcb 100644 (file)
@@ -34,7 +34,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index c16f208..2bdf907 100644 (file)
@@ -28,7 +28,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 4543283..e61ca41 100644 (file)
@@ -33,7 +33,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index d8e373a..25ffd32 100644 (file)
@@ -29,7 +29,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 7a19fe6..b4658c0 100644 (file)
@@ -32,7 +32,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
         return false;
     else
         return true;
index edddf36..937c665 100644 (file)
@@ -35,7 +35,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index ad72e3d..a3073d6 100644 (file)
@@ -41,7 +41,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-  if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+  if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
     return false;
   else
     return true;
index ca43cee..0e6ad7f 100644 (file)
@@ -24,7 +24,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
         return false;
     else
         return true;
index 6fb58e2..887b350 100644 (file)
@@ -28,7 +28,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index a4d2250..c70ee3f 100644 (file)
@@ -30,7 +30,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 8058595..07dacde 100644 (file)
@@ -29,7 +29,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 7abcab5..3e98824 100644 (file)
@@ -26,7 +26,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 51e43f3..568fe2a 100644 (file)
@@ -30,7 +30,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index fbd7369..a6fd8a3 100644 (file)
@@ -29,7 +29,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index cdf1ef8..2366f0c 100644 (file)
@@ -36,7 +36,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 614690b..994f5f9 100644 (file)
@@ -27,7 +27,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 1b80402..3c71885 100644 (file)
@@ -35,7 +35,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 7d4f7ca..50f3069 100644 (file)
@@ -27,7 +27,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index fe94a0b..8f2563d 100644 (file)
@@ -27,7 +27,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 3c1bef5..623668c 100644 (file)
@@ -28,7 +28,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 5c79733..42e7187 100644 (file)
@@ -28,7 +28,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 3c1bef5..623668c 100644 (file)
@@ -28,7 +28,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index d67f11a..759b4c1 100644 (file)
@@ -29,7 +29,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index fb8b563..9d3c0ed 100644 (file)
@@ -30,7 +30,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index c60640f..31151c6 100644 (file)
@@ -28,7 +28,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;
index 63bbb7d..322c8af 100644 (file)
@@ -40,7 +40,7 @@ bool validdev(uint16_t dev)
 {
        /* This is a bit uglier than needed but the right hand side is
         a constant this way */
-       if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+       if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
                return false;
        else
                return true;
index b8abe9b..9b31225 100644 (file)
@@ -43,7 +43,7 @@ bool validdev(uint16_t dev)
 {
     /* This is a bit uglier than needed but the right hand side is
        a constant this way */
-    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) + 255)
+    if(dev > ((sizeof(dev_tab)/sizeof(struct devsw)) << 8) - 1)
        return false;
     else
         return true;