Re: [PATCH 05/26] xfs_quota: convert time_to_string to use time64_t

Darrick J. Wong
2020-10-29T17:32:44Z

On Thu, Oct 29, 2020 at 09:47:12AM +0000, Christoph Hellwig wrote:
> On Mon, Oct 26, 2020 at 04:34:38PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > Rework the time_to_string helper to be capable of dealing with 64-bit
> > timestamps.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > quota/quota.c | 16 ++++++++++------
> > quota/quota.h | 2 +-
> > quota/report.c | 16 ++++++++++------
> > quota/util.c | 5 +++--
> > 4 files changed, 24 insertions(+), 15 deletions(-)
> >
> >
> > diff --git a/quota/quota.c b/quota/quota.c
> > index 9545cc430a93..8ba0995d9174 100644
> > --- a/quota/quota.c
> > +++ b/quota/quota.c
> > @@ -48,6 +48,7 @@ quota_mount(
> > uint flags)
> > {
> > fs_disk_quota_t d;
> > + time64_t timer;
> > char *dev = mount->fs_name;
> > char c[8], h[8], s[8];
> > uint qflags;
> > @@ -100,6 +101,7 @@ quota_mount(
> > }
> >
> > if (form & XFS_BLOCK_QUOTA) {
> > + timer = d.d_btimer;
> > qflags = (flags & HUMAN_FLAG);
> > if (d.d_blk_hardlimit && d.d_bcount > d.d_blk_hardlimit)
> > qflags |= LIMIT_FLAG;
> > @@ -111,16 +113,17 @@ quota_mount(
> > bbs_to_string(d.d_blk_softlimit, s, sizeof(s)),
> > bbs_to_string(d.d_blk_hardlimit, h, sizeof(h)),
> > d.d_bwarns,
> > - time_to_string(d.d_btimer, qflags));
> > + time_to_string(timer, qflags));
>
> What do the local variables buy us over just relying on the implicit cast
> to a larger integer type?

It's a setup to avoid long lines of nested function call crud once we
get to patch 23. Without the local variable, the fprintf turns into
this ugliness:

fprintf(fp, " %6s %6s %6s %02d %8s ",
bbs_to_string(d.d_bcount, c, sizeof(c)),
bbs_to_string(d.d_blk_softlimit, s, sizeof(s)),
bbs_to_string(d.d_blk_hardlimit, h, sizeof(h)),
d.d_bwarns,
time_to_string(decode_timer(&d, d.d_itimer,
d.d_itimer_hi),
qflags));

Which I guess is also fine but I kind of hate function call inside
function call inside function call combined with high indent levels.

--D