Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1529499pxb; Wed, 4 Nov 2020 11:23:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJwS/66JPDEmn9kNbmcGsDXlZrbBJub17dJFtjjjkX4isXzyj2E2B3WP6RjMGVSx1t20IGOC X-Received: by 2002:aa7:c608:: with SMTP id h8mr27849781edq.16.1604517804950; Wed, 04 Nov 2020 11:23:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604517804; cv=none; d=google.com; s=arc-20160816; b=h9OL4wv5xvkEVjPSv8J9fXvlULeBQ2qC4RC4qss9397zWN6VOg8mIYljzGdW66R/lx LQZyRQWNFTpWuZ43MsBB5vZDjD92rdGIIt/Qb/b7083ByF6dSISiJBtY3e+3rVW2eCyi tsFWu/Xr3jfCpYUrc+2/L9FOoo/aRfcvK+LMdoOAjsbwaT+1KiPcVnnbYoYwyKnmrGka mIn6rtLFcPZBDYcuG/T3Ax/5PJD65R8xVKZPEIoTMspMet0G+Bofx1BJ7nvLXh9kS7My we5ZH3KuKzFCWU+6ob/sBnUglzZy8tCTrMIQpmlitOuwVDWVjoZFV0OoKqTirwlYUjh8 YfSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=U4x1MXz5tbIvT1cORoWiOryU1faGGNbGUjdU+7mF3HQ=; b=RWo9MBVI/xNi4bqVaRiJY6/oihZNle0lD4AHdCK1PfPs0l3HMzYaWORzMvAT4Nmxq0 QKjv42r85foV0TAykwOWg3WzY7hs9OT74Ckzx44rSSVhH4SvgfSzViMkXITbPKbqFDXp THytqYkDTOxKKRYuqabc8MOP4A5J3zJDdNpx6H0v/Gu9NtbCRC7/A2+37IyKhsS3AAWL K/jKg0MlAcdDp5tXYFnaO2ErqgS/HPEyXNKASDijBiP3r7uNikRXwyNyLD1vGH6IHJ1m 4zToDOvWfqS+AYEj0PCgtL8/P2iH/O9/4ruUODCfQ59TeY3Mrd6yQkSmauviUV/t5Cxs 7Lyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q24jLDwe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si2054888edl.557.2020.11.04.11.23.02; Wed, 04 Nov 2020 11:23:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q24jLDwe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731477AbgKDSxQ (ORCPT + 99 others); Wed, 4 Nov 2020 13:53:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:60972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbgKDSxP (ORCPT ); Wed, 4 Nov 2020 13:53:15 -0500 Received: from google.com (unknown [104.132.1.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6FA6320782; Wed, 4 Nov 2020 18:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604515994; bh=gmgwXt+wYX0tzEd4eikIaskpTiv2GPG3uhFSrn8iPa0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q24jLDweh2NM6hfE1ZDGJZmSgFQtFBUHeCWTOyKy2wCxzd2okKBB826gYkGDpJ5i7 nyW2NRXYEONX+uznTSpTpBJxfBoEUyHhzyxVXDc1/Yf9wR9RWYJFj3J0PRhkh8X6Wl A9+OR6DyHKfLwhgovtxd9o+wZUYYkEZ0GxUXztNY= Date: Wed, 4 Nov 2020 10:53:12 -0800 From: Jaegeuk Kim To: Robin Hsu Cc: Eric Biggers , linux-f2fs-devel@lists.sourceforge.net, chao@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [f2fs-dev] [PATCH 1/1] f2fs-toos:fsck.f2fs Fix bad return value Message-ID: <20201104185312.GA134770@google.com> References: <20201026094000.1500425-1-robinhsu@google.com> <20201103025247.GA2875@sol.localdomain> <20201103032327.GA3655802@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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 > > 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 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 > > > > --- > > > > 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 > > 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 > > Reviewed-by: Chao Yu > > Signed-off-by: Jaegeuk Kim > > --- > > 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 > > > >