summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/usbstack/usb_storage.c29
1 files changed, 9 insertions, 20 deletions
diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c
index 2da3e85a34..c1f278b0ff 100644
--- a/firmware/usbstack/usb_storage.c
+++ b/firmware/usbstack/usb_storage.c
@@ -333,25 +333,15 @@ static enum {
#if CONFIG_RTC
static void yearday_to_daymonth(int yd, int y, int *d, int *m)
{
- static const char tnl[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- static const char tl[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
- const char *t;
- int i=0;
-
- if((y%4 == 0 && y%100 != 0) || y%400 == 0)
- {
- t=tl;
- }
- else
- {
- t=tnl;
- }
+ static char t[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+ bool leap = (y%4 == 0 && y%100 != 0) || y%400 == 0;
+ t[2] = leap ? 29 : 28;
+
+ int i;
+ for (i = 0; i < 12 && yd >= t[i]; i++)
+ yd -= t[i];
- while(i<12 && yd >= t[i])
- {
- yd-=t[i];
- i++;
- }
*d = yd+1;
*m = i;
}
@@ -757,8 +747,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
struct storage_info info;
unsigned int length = cbw->data_transfer_length;
- unsigned int block_size = 0;
- unsigned int block_count = 0;
+ unsigned int block_size, block_count;
bool lun_present=true;
unsigned char lun = cbw->lun;
unsigned int block_size_mult = 1;