Skip to content

Commit

Permalink
reiserfs: remove obsolete print_time function
Browse files Browse the repository at this point in the history
Before linux-2.4.6, print_time() was used to pretty-print an inode time
when running reiserfs in user space, after that it has become obsolete and
is still a bit incorrect: It behaves differently on 32-bit and 64-bit
machines, and uses a static buffer to hold a string, which could lead to
undefined behavior if we ever called this from multiple places
simultaneously.

Since we always want to treat the timestamps as 'unsigned' anyway, simply
printing them as an integer is both simpler and safer while avoiding the
deprecated time_t type.

Link: http://lkml.kernel.org/r/20180620142522.27639-3-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Arnd Bergmann authored and Linus Torvalds committed Aug 22, 2018
1 parent 34d0826 commit 5b1d149
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions fs/reiserfs/item_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,22 @@ static int sd_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize)
return 0;
}

static char *print_time(time_t t)
{
static char timebuf[256];

sprintf(timebuf, "%ld", t);
return timebuf;
}

static void sd_print_item(struct item_head *ih, char *item)
{
printk("\tmode | size | nlinks | first direct | mtime\n");
if (stat_data_v1(ih)) {
struct stat_data_v1 *sd = (struct stat_data_v1 *)item;

printk("\t0%-6o | %6u | %2u | %d | %s\n", sd_v1_mode(sd),
printk("\t0%-6o | %6u | %2u | %d | %u\n", sd_v1_mode(sd),
sd_v1_size(sd), sd_v1_nlink(sd),
sd_v1_first_direct_byte(sd),
print_time(sd_v1_mtime(sd)));
sd_v1_mtime(sd));
} else {
struct stat_data *sd = (struct stat_data *)item;

printk("\t0%-6o | %6llu | %2u | %d | %s\n", sd_v2_mode(sd),
printk("\t0%-6o | %6llu | %2u | %d | %u\n", sd_v2_mode(sd),
(unsigned long long)sd_v2_size(sd), sd_v2_nlink(sd),
sd_v2_rdev(sd), print_time(sd_v2_mtime(sd)));
sd_v2_rdev(sd), sd_v2_mtime(sd));
}
}

Expand Down

0 comments on commit 5b1d149

Please sign in to comment.