From: Eryu Guan <eguan@redhat.com>
To: Dave Chinner <david@fromorbit.com>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH] common: cleanups after common/rc split
Date: Fri, 2 Dec 2016 11:35:04 +0800 [thread overview]
Message-ID: <20161202033504.GF29149@eguan.usersys.redhat.com> (raw)
In-Reply-To: <20161202032935.GH11750@dastard>
On Fri, Dec 02, 2016 at 02:29:35PM +1100, Dave Chinner wrote:
> On Thu, Dec 01, 2016 at 12:22:13PM +0800, Eryu Guan wrote:
> > Fix code style issues after the common/rc split, e.g. use tab
> > indention, fix if-then-else format, fix while-do and for-do format
> > and various whitespace issues. No functional changes.
>
> Couple of quick things....
>
> > + OPTS=" "
> > + DBOPTS=" "
> > + USAGE="Usage: xfs_check [-fsvV] [-l logdev] [-i ino]... [-b bno]... special"
> > +
> > + while getopts "b:fi:l:stvV" c; do
> > + case $c in
> > + s) OPTS=$OPTS"-s ";;
> > + t) OPTS=$OPTS"-t ";;
> > + v) OPTS=$OPTS"-v ";;
> > + i) OPTS=$OPTS"-i "$OPTARG" ";;
> > + b) OPTS=$OPTS"-b "$OPTARG" ";;
> > + f) DBOPTS=$DBOPTS" -f";;
> > + l) DBOPTS=$DBOPTS" -l "$OPTARG" ";;
> > + V) $XFS_DB_PROG -p xfs_check -V
> > + return $?
> > + ;;
> > + esac
>
> It saves space and makes it easier to read if you don't indent the
> individual cases but do indent the code so multi-line operations
> don't end up with weird space indenting:
>
> case $c in
> s) OPTS=$OPTS"-s ";;
> t) OPTS=$OPTS"-t ";;
> v) OPTS=$OPTS"-v ";;
> ....
> V) $XFS_DB_PROG -p xfs_check -V
> return $?
> ;;
>
Yes, this looks better.
> > @@ -198,23 +197,23 @@ _test_xfs_logprint()
> >
> > _scratch_xfs_check()
> > {
> > - SCRATCH_OPTIONS=""
> > - [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
> > - SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
> > - [ "$LARGE_SCRATCH_DEV" = yes ] && \
> > - SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
> > - _xfs_check $SCRATCH_OPTIONS $* $SCRATCH_DEV
> > + SCRATCH_OPTIONS=""
> > + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
> > + SCRATCH_OPTIONS="-l $SCRATCH_LOGDEV"
> > + [ "$LARGE_SCRATCH_DEV" = yes ] && \
> > + SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
>
> If it's a multi-line construct, just use if [...]; then.
I didn't pay attention to the actual code, just fixed the indention
issue. I'll fix them in v2.
Thanks for the review!
Eryu
>
> > + _xfs_check $SCRATCH_OPTIONS $* $SCRATCH_DEV
> > }
> >
> > _scratch_xfs_repair()
> > {
> > - SCRATCH_OPTIONS=""
> > - [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
> > - SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
> > - [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
> > - SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
> > - [ "$LARGE_SCRATCH_DEV" = yes ] && SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -t"
> > - $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV
> > + SCRATCH_OPTIONS=""
> > + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
> > + SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
> > + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_RTDEV" ] && \
> > + SCRATCH_OPTIONS=$SCRATCH_OPTIONS" -r$SCRATCH_RTDEV"
>
> And this can become:
>
> if [ "$USE_EXTERNAL" = yes ]; then
> [ -n "$SCRATCH_LOGDEV" ] && SCRATCH_OPTIONS="-l$SCRATCH_LOGDEV"
> [ -n "$SCRATCH_RTDEV" ] && SCRATCH_OPTIONS="-l$SCRATCH_RTDEV"
> fi
>
> > +
> > + $XFS_LOGPRINT_PROG -t $extra_log_options $device 2>&1 \
> > + | tee $tmp.logprint | grep -q "<CLEAN>"
> > + if [ $? -ne 0 -a "$HOSTOS" = "Linux" ]; then
> > + echo "_check_xfs_filesystem: filesystem on $device has dirty log (see $seqres.full)"
> > +
> > + echo "_check_xfs_filesystem: filesystem on $device has dirty log" >>$seqres.full
> > + echo "*** xfs_logprint -t output ***" >>$seqres.full
> > + cat $tmp.logprint >>$seqres.full
> > + echo "*** end xfs_logprint output" >>$seqres.full
>
> Better, I think, with these multi-line file dumps is something like:
>
> (
> echo ....
> echo ....
> cat ...
> echo
> ) >> $seqres.full
> > + if [ $ok -eq 0 ]; then
> > + echo "*** mount output ***" >>$seqres.full
> > + _mount >>$seqres.full
> > + echo "*** end mount output" >>$seqres.full
> > + elif [ "$type" = "xfs" ]; then
> > + _mount_or_remount_rw "$extra_mount_options" $device $mountpoint
> > + fi
> > +
> > + if [ $ok -eq 0 ]; then
> > + status=1
> > + if [ "$iam" != "check" ]; then
> > + exit 1
> > + fi
> > + return 1
> > + fi
>
> THese $ok -eq 0 cases can be combined.
>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com
next prev parent reply other threads:[~2016-12-02 3:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-01 4:22 [PATCH] common: cleanups after common/rc split Eryu Guan
2016-12-02 3:29 ` Dave Chinner
2016-12-02 3:35 ` Eryu Guan [this message]
2016-12-02 6:25 ` Eryu Guan
2016-12-02 6:51 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161202033504.GF29149@eguan.usersys.redhat.com \
--to=eguan@redhat.com \
--cc=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox