mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oscar Forner Martinez <oscar.forner.martinez@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Oscar Forner Martinez <oscar.forner.martinez@gmail.com>
Subject: [PATCH v2] fs: isofs: Fix bug in the way to check if the year is a leap year
Date: Sun,  4 Jan 2015 12:42:25 +0000	[thread overview]
Message-ID: <1420375345-3967-1-git-send-email-oscar.forner.martinez@gmail.com> (raw)

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>
---
 fs/isofs/util.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/fs/isofs/util.c b/fs/isofs/util.c
index 01e1ee7..a3f953a 100644
--- a/fs/isofs/util.c
+++ b/fs/isofs/util.c
@@ -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)
-- 
1.9.1


             reply	other threads:[~2015-01-04 12:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-04 12:42 Oscar Forner Martinez [this message]
2015-01-07 11:15 ` [PATCH v2] " Òscar Forner Martínez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420375345-3967-1-git-send-email-oscar.forner.martinez@gmail.com \
    --to=oscar.forner.martinez@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®