public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: isofs: Fix bug in the way to check if the year is a leap year
@ 2015-01-02 16:08 Oscar Forner Martinez
  2015-01-02 17:10 ` Al Viro
  0 siblings, 1 reply; 3+ messages in thread
From: Oscar Forner Martinez @ 2015-01-02 16:08 UTC (permalink / raw)
  To: linux-kernel; +Cc: Oscar Forner Martinez

The way to check if the year is a leap year was incomplete.
It was checking only if the year can be divided by 4, that is
necessary but not a sufficient condition. It has to check as well
if the year can not be divided by 100 or if the year can be
divided by 400.

Signed-off-by: Oscar Forner Martinez <oscar.forner.martinez@gmail.com>
---
 fs/isofs/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/isofs/util.c b/fs/isofs/util.c
index 01e1ee7..d2dd602 100644
--- a/fs/isofs/util.c
+++ b/fs/isofs/util.c
@@ -38,7 +38,7 @@ int iso_date(char * p, int flag)
 			days += (year+1) / 4;
 		for (i = 1; i < month; i++)
 			days += monlen[i-1];
-		if (((year+2) % 4) == 0 && month > 2)
+		if (((year+2) % 4) == 0 && month > 2 && ((((year+2) % 100) != 0) || (((year+2) % 400) == 0)))
 			days++;
 		days += day - 1;
 		crtime = ((((days * 24) + hour) * 60 + minute) * 60)
-- 
2.2.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-01-02 22:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-02 16:08 [PATCH] fs: isofs: Fix bug in the way to check if the year is a leap year Oscar Forner Martinez
2015-01-02 17:10 ` Al Viro
     [not found]   ` <CADZ0XgJMzsgSBZEJdQ5FqEWVB+Y_ZHD0Vy5HFy-hbWVjwqy7KA@mail.gmail.com>
2015-01-02 22:03     ` Al Viro

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox