summaryrefslogtreecommitdiff
path: root/firmware/usbstack
diff options
context:
space:
mode:
authorRafaël Carré <funman@videolan.org>2012-05-07 01:30:45 -0400
committerRafaël Carré <funman@videolan.org>2012-05-07 01:30:45 -0400
commitdd57c01bef9bd24fc8000175f61bf6071901289a (patch)
treed95d188460cbb4401adf3b7f5309f51d862d6a1b /firmware/usbstack
parent803408f18657bcd501737ad29e98a1b4cca0ec37 (diff)
downloadrockbox-dd57c01bef9bd24fc8000175f61bf6071901289a.tar.gz
rockbox-dd57c01bef9bd24fc8000175f61bf6071901289a.zip
simplify yearday_to_daymonth()
Diffstat (limited to 'firmware/usbstack')
-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;