udf: Simplify calls to udf_disk_stamp_to_time
authorDeepa Dinamani <deepa.kernel@gmail.com>
Thu, 10 May 2018 15:26:17 +0000 (08:26 -0700)
committerDeepa Dinamani <deepa.kernel@gmail.com>
Fri, 25 May 2018 22:31:14 +0000 (15:31 -0700)
Subsequent patches in the series convert inode timestamps
to use struct timespec64 instead of struct timespec as
part of solving the y2038 problem.

commit fd3cfad374d4 ("udf: Convert udf_disk_stamp_to_time() to use mktime64()")
eliminated the NULL return condition from udf_disk_stamp_to_time().
udf_time_to_disk_time() is always called with a valid dest pointer and
the return value is ignored.
Further, caller can as well check the dest pointer being passed in rather
than return argument.
Make both the functions return void.

This will make the inode timestamp conversion simpler.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Cc: jack@suse.com
----
Changes from v1:
* fixed the pointer error pointed by Jan

fs/udf/inode.c
fs/udf/super.c
fs/udf/udfdecl.h
fs/udf/udftime.c

index c80765d..df2378d 100644 (file)
@@ -1443,15 +1443,9 @@ reread:
                inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
                        (inode->i_sb->s_blocksize_bits - 9);
 
-               if (!udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime))
-                       inode->i_atime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&inode->i_mtime,
-                                           fe->modificationTime))
-                       inode->i_mtime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime))
-                       inode->i_ctime = sbi->s_record_time;
+               udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime);
+               udf_disk_stamp_to_time(&inode->i_mtime, fe->modificationTime);
+               udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime);
 
                iinfo->i_unique = le64_to_cpu(fe->uniqueID);
                iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
@@ -1461,18 +1455,10 @@ reread:
                inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
                    (inode->i_sb->s_blocksize_bits - 9);
 
-               if (!udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime))
-                       inode->i_atime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&inode->i_mtime,
-                                           efe->modificationTime))
-                       inode->i_mtime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime))
-                       iinfo->i_crtime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime))
-                       inode->i_ctime = sbi->s_record_time;
+               udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime);
+               udf_disk_stamp_to_time(&inode->i_mtime, efe->modificationTime);
+               udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime);
+               udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime);
 
                iinfo->i_unique = le64_to_cpu(efe->uniqueID);
                iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
index 7949c33..8449e51 100644 (file)
@@ -864,6 +864,9 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
        struct buffer_head *bh;
        uint16_t ident;
        int ret = -ENOMEM;
+#ifdef UDFFS_DEBUG
+       struct timestamp *ts;
+#endif
 
        outstr = kmalloc(128, GFP_NOFS);
        if (!outstr)
@@ -882,15 +885,15 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
 
        pvoldesc = (struct primaryVolDesc *)bh->b_data;
 
-       if (udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
-                             pvoldesc->recordingDateAndTime)) {
+       udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
+                             pvoldesc->recordingDateAndTime);
 #ifdef UDFFS_DEBUG
-               struct timestamp *ts = &pvoldesc->recordingDateAndTime;
-               udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
-                         le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
-                         ts->minute, le16_to_cpu(ts->typeAndTimezone));
+       ts = &pvoldesc->recordingDateAndTime;
+       udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
+                 le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
+                 ts->minute, le16_to_cpu(ts->typeAndTimezone));
 #endif
-       }
+
 
        ret = udf_dstrCS0toUTF8(outstr, 31, pvoldesc->volIdent, 32);
        if (ret < 0)
index 68e8a64..08e515c 100644 (file)
@@ -252,8 +252,8 @@ extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
 extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
 
 /* udftime.c */
-extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
+extern void udf_disk_stamp_to_time(struct timespec *dest,
                                                struct timestamp src);
-extern struct timestamp *udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
+extern void udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
 
 #endif                         /* __UDF_DECL_H */
index 0927a4b..67b33ac 100644 (file)
@@ -40,7 +40,7 @@
 #include <linux/kernel.h>
 #include <linux/time.h>
 
-struct timespec *
+void
 udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
 {
        u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone);
@@ -67,10 +67,9 @@ udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
         * recorded with bogus sub-second values.
         */
        dest->tv_nsec %= NSEC_PER_SEC;
-       return dest;
 }
 
-struct timestamp *
+void
 udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
 {
        long seconds;
@@ -79,9 +78,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
 
        offset = -sys_tz.tz_minuteswest;
 
-       if (!dest)
-               return NULL;
-
        dest->typeAndTimezone = cpu_to_le16(0x1000 | (offset & 0x0FFF));
 
        seconds = ts.tv_sec + offset * 60;
@@ -97,7 +93,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
                                        dest->centiseconds * 10000) / 100;
        dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
                              dest->hundredsOfMicroseconds * 100);
-       return dest;
 }
 
 /* EOF */