Re: [PATCH v8 09/13] exfat: add misc operations

From: Pali RohÃr
Date: Sun Dec 29 2019 - 09:00:12 EST


On Friday 20 December 2019 01:24:15 Namjae Jeon wrote:
> This adds the implementation of misc operations for exfat.
>
> Signed-off-by: Namjae Jeon <namjae.jeon@xxxxxxxxxxx>
> Signed-off-by: Sungjong Seo <sj1557.seo@xxxxxxxxxxx>
> ---
> fs/exfat/misc.c | 240 ++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 240 insertions(+)
> create mode 100644 fs/exfat/misc.c
>
> diff --git a/fs/exfat/misc.c b/fs/exfat/misc.c
> new file mode 100644
> index 000000000000..2fa182cd4ff2
> --- /dev/null
> +++ b/fs/exfat/misc.c

...

> +/* Convert linear UNIX date to a FAT time/date pair. */
> +void exfat_time_unix2fat(struct exfat_sb_info *sbi, struct timespec64 *ts,
> + struct exfat_date_time *tp)
> +{
> + time_t second = ts->tv_sec;
> + time_t day, month, year;
> + time_t ld; /* leap day */
> +
> + if (!sbi->options.tz_utc)
> + second -= sys_tz.tz_minuteswest * SECS_PER_MIN;
> +
> + /* Jan 1 GMT 00:00:00 1980. But what about another time zone? */
> + if (second < UNIX_SECS_1980) {
> + tp->second = 0;
> + tp->minute = 0;
> + tp->hour = 0;
> + tp->day = 1;
> + tp->month = 1;
> + tp->year = 0;
> + return;
> + }
> +#if (BITS_PER_LONG == 64)
> + if (second >= UNIX_SECS_2108) {
> + tp->second = 59;
> + tp->minute = 59;
> + tp->hour = 23;
> + tp->day = 31;
> + tp->month = 12;
> + tp->year = 127;
> + return;
> + }
> +#endif

Hello! Why is this code #if-ed? Kernel supports 64 bit long long
integers also for 32 bit platforms.

Function parameter struct timespec64 *ts is already 64 bit. so above
#if-code looks really suspicious.

> +
> + day = second / SECS_PER_DAY - DAYS_DELTA_DECADE;
> + year = day / 365;
> +
> + MAKE_LEAP_YEAR(ld, year);
> + if (year * 365 + ld > day)
> + year--;
> +
> + MAKE_LEAP_YEAR(ld, year);
> + day -= year * 365 + ld;

--
Pali RohÃr
pali.rohar@xxxxxxxxx

Attachment: signature.asc
Description: PGP signature