all: Fix overflow in shift operators

This commit is contained in:
Pali Rohár committed 2014-11-26 16:49:39 +01:00
1 parent c86e130ab1
commit bb90caec1b
4 files changed
+8 -8

No files matched your search

+1 -1
View File
@@ -36,7 +36,7 @@
#include "usb-device.h"
#include "printf-utils.h"
static char global_buf[1 << 22]; /* 4MB */
static char global_buf[1UL << 22]; /* 4MB */
int disk_open_dev(int maj, int min, int partition, int readonly) {
+4 -4
View File
@@ -145,7 +145,7 @@ int mkii_init(struct usb_device_info * dev) {
}
type = image_type_from_string(ptr);
if ( type != IMAGE_UNKNOWN ) {
dev->data |= (1 << type);
dev->data |= (1UL << type);
printf(" %s", ptr);
}
ptr = newptr;
@@ -156,9 +156,9 @@ int mkii_init(struct usb_device_info * dev) {
memset(buf, 0, sizeof(buf));
usb_get_string_simple(dev->udev, usb_device(dev->udev)->config[dev->flash_device->configuration].iConfiguration, buf, sizeof(buf));
if ( strncmp(buf, "Firmware Upgrade Configuration", sizeof("Firmware Upgrade Configuration")) == 0 )
dev->data |= (1 << 31);
dev->data |= (1UL << 31);
printf("Mode: %s\n", (dev->data & (1<<31)) ? "Update" : "PC Suite");
printf("Mode: %s\n", (dev->data & (1UL << 31)) ? "Update" : "PC Suite");
return 0;
@@ -198,7 +198,7 @@ int mkii_flash_image(struct usb_device_info * dev, struct image * image) {
ERROR("Not implemented yet");
return -1;
if ( ! ( dev->data & (1 << image->type) ) ) {
if ( ! ( dev->data & (1UL << image->type) ) ) {
ERROR("Flashing image %s is not supported in current device configuration", image_type_to_string(image->type));
return -1;
}
+1 -1
View File
@@ -180,7 +180,7 @@ int dev_flash_image(struct device_info * dev, struct image * image) {
usb_switch_to_update(dev->usb);
return -EAGAIN;
} else if ( protocol == FLASH_MKII ) {
if ( dev->usb->data & (1 << image->type) )
if ( dev->usb->data & (1UL << image->type) )
return mkii_flash_image(dev->usb, image);
}
+2 -2
View File
@@ -384,7 +384,7 @@ void usb_switch_to_update(struct usb_device_info * dev) {
leave_cold_flash(dev);
else if ( dev->flash_device->protocol == FLASH_NOLO )
nolo_boot_device(dev, "update");
else if ( dev->flash_device->protocol == FLASH_MKII && ! ( dev->data & ( 1 << 31 ) ) )
else if ( dev->flash_device->protocol == FLASH_MKII && ! ( dev->data & ( 1UL << 31 ) ) )
mkii_reboot_device(dev);
else if ( dev->flash_device->protocol == FLASH_DISK )
printf_and_wait("Unplug USB cable, turn device off, press ENTER and plug USB cable again");
@@ -401,7 +401,7 @@ void usb_switch_to_disk(struct usb_device_info * dev) {
nolo_boot_device(dev, NULL);
printf_and_wait("Wait until device start, choose USB Mass Storage Mode and press ENTER");
} else if ( dev->flash_device->protocol == FLASH_MKII ) {
if ( dev->data & ( 1 << 31 ) )
if ( dev->data & ( 1UL << 31 ) )
mkii_reboot_device(dev);
else
printf_and_wait("Unplug USB cable, plug again, choose USB Mass Storage Mode and press ENTER");