Re: [PATCH v3 2/2] Use common localtime/gmtime in fat_time_unix2fat()

From: OGAWA Hirofumi
Date: Sat Jul 25 2009 - 05:41:16 EST


Zhaolei <zhaolei@xxxxxxxxxxxxxx> writes:

> + if (sbi->options.tz_utc) {
> + gmtime_r(ts->tv_sec, &tm);
> + } else {
> + localtime_r(ts->tv_sec, &tm);
> + }

Missing error check.

> - /* Jan 1 GMT 00:00:00 1980. But what about another time zone? */
> - if (second < UNIX_SECS_1980) {
> + /* FAT can only support year between 1980 to 2107 */
> + if (tm.tm_year < 1980 - 1900) {
> *time = 0;
> *date = cpu_to_le16((0 << 9) | (1 << 5) | 1);
> if (time_cs)
> *time_cs = 0;
> return;
> }
> -#if BITS_PER_LONG == 64
> - if (second >= UNIX_SECS_2108) {
> + if (tm.tm_year > 2107 - 1900) {
> *time = cpu_to_le16((23 << 11) | (59 << 5) | 29);
> *date = cpu_to_le16((127 << 9) | (12 << 5) | 31);
> if (time_cs)
> *time_cs = 199;
> return;
> }
> -#endif

I think tm.tm_year is undefine in case of the error.

Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/