summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 {
333#if CONFIG_RTC 333#if CONFIG_RTC
334static void yearday_to_daymonth(int yd, int y, int *d, int *m) 334static void yearday_to_daymonth(int yd, int y, int *d, int *m)
335{ 335{
336 static const char tnl[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 336 static char t[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
337 static const char tl[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 337
338 const char *t; 338 bool leap = (y%4 == 0 && y%100 != 0) || y%400 == 0;
339 int i=0; 339 t[2] = leap ? 29 : 28;
340 340
341 if((y%4 == 0 && y%100 != 0) || y%400 == 0) 341 int i;
342 { 342 for (i = 0; i < 12 && yd >= t[i]; i++)
343 t=tl; 343 yd -= t[i];
344 }
345 else
346 {
347 t=tnl;
348 }
349 344
350 while(i<12 && yd >= t[i])
351 {
352 yd-=t[i];
353 i++;
354 }
355 *d = yd+1; 345 *d = yd+1;
356 *m = i; 346 *m = i;
357} 347}
@@ -757,8 +747,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
757 747
758 struct storage_info info; 748 struct storage_info info;
759 unsigned int length = cbw->data_transfer_length; 749 unsigned int length = cbw->data_transfer_length;
760 unsigned int block_size = 0; 750 unsigned int block_size, block_count;
761 unsigned int block_count = 0;
762 bool lun_present=true; 751 bool lun_present=true;
763 unsigned char lun = cbw->lun; 752 unsigned char lun = cbw->lun;
764 unsigned int block_size_mult = 1; 753 unsigned int block_size_mult = 1;