linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Robin Hsu <robinhsu@google.com>
Cc: Eric Biggers <ebiggers@kernel.org>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 1/1] f2fs-toos:fsck.f2fs Fix bad return value
Date: Wed, 4 Nov 2020 10:53:12 -0800	[thread overview]
Message-ID: <20201104185312.GA134770@google.com> (raw)
In-Reply-To: <CAH7-xNRd1QBJUaxajijjrMbWdKKO1AKS2-1Q5HAAkHSUF628ug@mail.gmail.com>

On 11/04, Robin Hsu wrote:
> The root cause is the ASSERT() marco,  In fact, I already fixed it in one
> of my recent work.
> I separate it as an independent commit here:
> 
> >From 5359588b1804c5e555e9fad92203d76041ef09eb Mon Sep 17 00:00:00 2001
> 
> From: Robin Hsu <robinhsu@google.com>
> 
> Date: Wed, 4 Nov 2020 10:50:28 +0800
> 
> Subject: [PATCH] Fix ASSERT() macro with '%' in the expression
> 
> 
> 
> Fix a compiling error triggered by ASSERT(exp), when exp contains '%'
> 
> (e.g. integer modular operator)
> 
> 
> 
> Signed-off-by: Robin Hsu <robinhsu@google.com>
> 
> Change-Id: I84708dbaf10c675b9950926c9b6ded5b5a3fbd59

Thanks, applied as well. :)

> 
> ---
> 
>  include/f2fs_fs.h | 4 ++--
> 
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 
> 
> diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
> 
> index b5bda13..1348e39 100644
> 
> --- a/include/f2fs_fs.h
> 
> +++ b/include/f2fs_fs.h
> 
> @@ -194,8 +194,8 @@ static inline uint64_t bswap_64(uint64_t val)
> 
>  #define ASSERT(exp)                                                    \
> 
>         do {                                                            \
> 
>                 if (!(exp)) {                                           \
> 
> -                       printf("[ASSERT] (%s:%4d) " #exp"\n",           \
> 
> -                                       __func__, __LINE__);            \
> 
> +                       printf("[ASSERT] (%s:%4d) %s\n",                \
> 
> +                                       __func__, __LINE__, #exp);      \
> 
>                         exit(-1);                                       \
> 
>                 }                                                       \
> 
>         } while (0)
> 
> --
> 
> 2.29.1.341.ge80a0c044ae-goog
> 
> 
> On Tue, Nov 3, 2020 at 11:23 AM Jaegeuk Kim <jaegeuk@kernel.org> wrote:
> 
> > On 11/02, Eric Biggers wrote:
> > > On Mon, Oct 26, 2020 at 05:40:00PM +0800, Robin Hsu via Linux-f2fs-devel
> > wrote:
> > > > 'ret' should not have been used here: otherwise, it would be wrongly
> > used
> > > > as the error code and then be returned from main().
> > > >
> > > > Signed-off-by: Robin Hsu <robinhsu@google.com>
> > > > ---
> > > >  fsck/fsck.c | 3 +--
> > > >  1 file changed, 1 insertion(+), 2 deletions(-)
> > > >
> > > > diff --git a/fsck/fsck.c b/fsck/fsck.c
> > > > index f97e9fb..66e4e3f 100644
> > > > --- a/fsck/fsck.c
> > > > +++ b/fsck/fsck.c
> > > > @@ -3137,8 +3137,7 @@ int fsck_verify(struct f2fs_sb_info *sbi)
> > > >             char ans[255] = {0};
> > > >
> > > >             printf("\nDo you want to restore lost files into
> > ./lost_found/? [Y/N] ");
> > > > -           ret = scanf("%s", ans);
> > > > -           ASSERT(ret >= 0);
> > > > +           ASSERT(scanf("%s", ans) >= 0);
> > > >             if (!strcasecmp(ans, "y")) {
> > > >                     for (i = 0; i < fsck->nr_nat_entries; i++) {
> > > >                             if (f2fs_test_bit(i,
> > fsck->nat_area_bitmap))
> > >
> > > This patch causes a compiler warning:
> > >
> > >       In file included from f2fs.h:33,
> > >                        from fsck.h:14,
> > >                        from fsck.c:11:
> > >       fsck.c: In function 'fsck_verify':
> > >       ../include/f2fs_fs.h:197:11: warning: format '%s' expects a
> > matching 'char *' argument [-Wformat=]
> > >           printf("[ASSERT] (%s:%4d) " #exp"\n",  \
> > >                  ^~~~~~~~~~~~~~~~~~~~
> > >       fsck.c:3151:3: note: in expansion of macro 'ASSERT'
> > >          ASSERT(scanf("%s", ans) >= 0);
> > >          ^~~~~~
> >
> > Urg. Fixed by this.
> >
> > From c986140e3c5abb9eb7a08928a88acb8273f1bd52 Mon Sep 17 00:00:00 2001
> > From: Robin Hsu <robinhsu@google.com>
> > Date: Mon, 26 Oct 2020 17:40:00 +0800
> > Subject: [PATCH] f2fs-toos: fsck.f2fs Fix bad return value
> >
> > 'ret' should not have been used here: otherwise, it would be wrongly used
> > as the error code and then be returned from main().
> >
> > Signed-off-by: Robin Hsu <robinhsu@google.com>
> > Reviewed-by: Chao Yu <yuchao0@huawei.com>
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> >  fsck/fsck.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/fsck/fsck.c b/fsck/fsck.c
> > index 647523397f3e..e52672032d2c 100644
> > --- a/fsck/fsck.c
> > +++ b/fsck/fsck.c
> > @@ -3146,10 +3146,11 @@ int fsck_verify(struct f2fs_sb_info *sbi)
> >  #ifndef WITH_ANDROID
> >         if (nr_unref_nid && !c.ro) {
> >                 char ans[255] = {0};
> > +               int res;
> >
> >                 printf("\nDo you want to restore lost files into
> > ./lost_found/? [Y/N] ");
> > -               ret = scanf("%s", ans);
> > -               ASSERT(ret >= 0);
> > +               res = scanf("%s", ans);
> > +               ASSERT(res >= 0);
> >                 if (!strcasecmp(ans, "y")) {
> >                         for (i = 0; i < fsck->nr_nat_entries; i++) {
> >                                 if (f2fs_test_bit(i,
> > fsck->nat_area_bitmap))
> > --
> > 2.29.1.341.ge80a0c044ae-goog
> >
> >


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

      parent reply	other threads:[~2020-11-04 18:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26  9:40 [f2fs-dev] [PATCH 1/1] f2fs-toos:fsck.f2fs Fix bad return value Robin Hsu via Linux-f2fs-devel
2020-10-28  6:57 ` Chao Yu
2020-11-02 16:09   ` Jaegeuk Kim
2020-11-03  2:52 ` Eric Biggers
2020-11-03  3:23   ` Jaegeuk Kim
     [not found]     ` <CAH7-xNRd1QBJUaxajijjrMbWdKKO1AKS2-1Q5HAAkHSUF628ug@mail.gmail.com>
2020-11-04 18:53       ` Jaegeuk Kim [this message]

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=20201104185312.GA134770@google.com \
    --to=jaegeuk@kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robinhsu@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).