summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2014-11-26 16:49:39 +0100
committerPali Rohár <pali.rohar@gmail.com>2014-11-26 16:49:39 +0100
commitbb90caec1be476ce4093e72029537c8ccd38f5b3 (patch)
treeb2f851519a6c80a2a9ebe98d389602cb2dfd4d31 /src
parentc86e130ab1af4b6161b2a71a2449d2e02109800f (diff)
download0xFFFF-bb90caec1be476ce4093e72029537c8ccd38f5b3.tar.bz2
all: Fix overflow in shift operators
Diffstat (limited to 'src')
-rw-r--r--src/disk.c2
-rw-r--r--src/mkii.c8
-rw-r--r--src/operations.c2
-rw-r--r--src/usb-device.c4
4 files changed, 8 insertions, 8 deletions
diff --git a/src/disk.c b/src/disk.c
index 86394f4..7370f13 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -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) {
diff --git a/src/mkii.c b/src/mkii.c
index 5030a89..e2fb23f 100644
--- a/src/mkii.c
+++ b/src/mkii.c
@@ -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;
}
diff --git a/src/operations.c b/src/operations.c
index 85d1e3d..59bf212 100644
--- a/src/operations.c
+++ b/src/operations.c
@@ -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);
}
diff --git a/src/usb-device.c b/src/usb-device.c
index 4fb011a..a4b1f8b 100644
--- a/src/usb-device.c
+++ b/src/usb-device.c
@@ -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");