cmd: usb_mass_storage: Use NULL for pointer
[platform/kernel/u-boot.git] / cmd / itest.c
index fb4d797..e1896d9 100644 (file)
@@ -65,13 +65,13 @@ static long evalexp(char *s, int w)
                }
                switch (w) {
                case 1:
-                       l = (long)(*(unsigned char *)buf);
+                       l = (long)(*(u8 *)buf);
                        break;
                case 2:
-                       l = (long)(*(unsigned short *)buf);
+                       l = (long)(*(u16 *)buf);
                        break;
                case 4:
-                       l = (long)(*(unsigned long *)buf);
+                       l = (long)(*(u32 *)buf);
                        break;
                }
                unmap_physmem(buf, w);
@@ -80,7 +80,8 @@ static long evalexp(char *s, int w)
                l = simple_strtoul(s, NULL, 16);
        }
 
-       return l & ((1UL << (w * 8)) - 1);
+       /* avoid overflow on mask calculus */
+       return (w >= sizeof(long)) ? l : (l & ((1UL << (w * 8)) - 1));
 }
 
 static char * evalstr(char *s)