Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <oscar.forner.martinez@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>

authored by

Oscar Forner Martinez and committed by
Jan Kara
e4a93be6 6744e90b

+4 -14
+4 -14
fs/isofs/util.c
··· 2 2 * linux/fs/isofs/util.c 3 3 */ 4 4 5 + #include <linux/time.h> 5 6 #include "isofs.h" 6 7 7 8 /* ··· 18 17 int iso_date(char * p, int flag) 19 18 { 20 19 int year, month, day, hour, minute, second, tz; 21 - int crtime, days, i; 20 + int crtime; 22 21 23 - year = p[0] - 70; 22 + year = p[0]; 24 23 month = p[1]; 25 24 day = p[2]; 26 25 hour = p[3]; ··· 32 31 if (year < 0) { 33 32 crtime = 0; 34 33 } else { 35 - int monlen[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; 36 - 37 - days = year * 365; 38 - if (year > 2) 39 - days += (year+1) / 4; 40 - for (i = 1; i < month; i++) 41 - days += monlen[i-1]; 42 - if (((year+2) % 4) == 0 && month > 2) 43 - days++; 44 - days += day - 1; 45 - crtime = ((((days * 24) + hour) * 60 + minute) * 60) 46 - + second; 34 + crtime = mktime64(year+1900, month, day, hour, minute, second); 47 35 48 36 /* sign extend */ 49 37 if (tz & 0x80)