simplify yearday_to_daymonth()

This commit is contained in:
Rafaël Carré 2012-05-07 01:30:45 -04:00
parent 803408f186
commit dd57c01bef

View file

@ -333,25 +333,15 @@ static enum {
#if CONFIG_RTC #if CONFIG_RTC
static void yearday_to_daymonth(int yd, int y, int *d, int *m) 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 char t[] = { 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) bool leap = (y%4 == 0 && y%100 != 0) || y%400 == 0;
{ t[2] = leap ? 29 : 28;
t=tl;
}
else
{
t=tnl;
}
while(i<12 && yd >= t[i]) int i;
{ for (i = 0; i < 12 && yd >= t[i]; i++)
yd -= t[i]; yd -= t[i];
i++;
}
*d = yd+1; *d = yd+1;
*m = i; *m = i;
} }
@ -757,8 +747,7 @@ static void handle_scsi(struct command_block_wrapper* cbw)
struct storage_info info; struct storage_info info;
unsigned int length = cbw->data_transfer_length; unsigned int length = cbw->data_transfer_length;
unsigned int block_size = 0; unsigned int block_size, block_count;
unsigned int block_count = 0;
bool lun_present=true; bool lun_present=true;
unsigned char lun = cbw->lun; unsigned char lun = cbw->lun;
unsigned int block_size_mult = 1; unsigned int block_size_mult = 1;