fs: isofs: Fix bug in the way to check if the year is a leap year
PATCH v2 1/1 fs: isofs: Fix bug in the way to check if the year is a leap year
Changed the whole algorithm for a call to mktime64 that takes care of all that details.
Signed-off-by Oscar Forner Martinez <[email protected]>
--- fs/isofs/util.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
fs/isofs/util.c +2 -12
@@ -2,6 +2,7 @@* linux/fs/isofs/util.c */ +#include <linux/time.h> #include "isofs.h" /*
@@ -31,18 +32,7 @@ int iso_date(char * p, int flag)if (year <0 ) { crtime =0 ; }else { -int monlen[12 ] = {31 ,28 ,31 ,30 ,31 ,30 ,31 ,31 ,30 ,31 ,30 ,31 }; - - days = year *365 ; -if (year >2 ) - days += (year+1 ) /4 ; -for (i =1 ; i < month; i++) - days += monlen[i-1 ]; -if (((year+2 ) %4 ) ==0 && month >2 ) - days++; - days += day -1 ; - crtime = ((((days *24 ) + hour) *60 + minute) *60 ) - + second; + crtime =mktime64 (year+1970 , month, day, hour, minute, second);/* sign extend */ if (tz &0x80 )
Signature · 1 line
1.9.1
Re: [PATCH v2] isofs: Fix bug in the way to check if the year is a leap year
I have sent that e-mail three days ago. As nobody is the maintainer It is only send for the general list. This is just a reminder for someone who can check it.
Quoted 43 lines · Oscar Forner Martinez
Changed the whole algorithm for a call to mktime64 that takes care of all that details.
Signed-off-by Oscar Forner Martinez <[email protected]>---
fs/isofs/util.c| 14 ++------------1 file changed, 2 insertions(+), 12 deletions(-)fs/isofs/util.c +2
-12@@ -2,6 +2,7 @@* linux/fs/isofs/util.c */ +#include <linux/time.h> #include "isofs.h" /* @@ -31,18 +32,7 @@ int iso_date(char * p, int flag)if (year <0 ) { crtime =0 ; }else { -int monlen[12 ] = {31 ,28 ,31 ,30 ,31 ,30 ,31 ,31 ,30 ,31 ,30 ,31 }; - - days = year *365 ; -if (year >2 ) - days += (year+1 ) /4 ; -for (i =1 ; i < month; i++) - days += monlen[i-1 ]; -if (((year+2 ) %4 ) ==0 && month >2 ) - days++; - days += day -1 ; - crtime = ((((days *24 ) + hour) *60 + minute) *60 ) - + second; + crtime =mktime64 (year+1970 , month, day, hour, minute, second);/* sign extend */ if (tz &0x80 )Signature · 1 line
1.9.1