Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp456355rdb; Sat, 17 Feb 2024 17:40:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU+WFgALEFeqyllV35OzWby+wqKt88Q71jRhXYiIo0ojNGNGz0HQKkYemLW4EZYUqrTDMhigBP5SjMLijTbqrW+WgVZBnEc8z3lQlsV0w== X-Google-Smtp-Source: AGHT+IEgHrQJ68iOVF2fVrcSoPDooAUsmS6YNFwzMFfKVu36d6aJUsPSFVLdsDFbCI+k/E+ntegW X-Received: by 2002:a05:6808:487:b0:3c1:1398:9eca with SMTP id z7-20020a056808048700b003c113989ecamr7916890oid.28.1708220425913; Sat, 17 Feb 2024 17:40:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708220425; cv=pass; d=google.com; s=arc-20160816; b=kKnW6U3tKpouRJWTtZlIJK2AXClbR3ojWanL89Y2WRr/kM9lOW+M+xlKom2adrWrdi znPs34GpP2SRWybvi9g/jWyR+p51faG2VFKt3WbK+2nxmiXHatbFcu6gjKqsFK53DvzD /6dTfHR82vLJyoLE8jlrG2vikYJK10VJcNp0jFdJGq8DHh0q2dyX3C80HZ1XnJ4qbmPi D6gtq8fdJZ+ynF6h6R/2rLWpiNIb3Q6V54r7+5U1IlWbTVQ/GAMBsWgf/Or/90XAHpeg Bp9yj10LZu+OqevPz7vMv3uDp9ZUqCuaEzcZKjOgOiPSXQPw52yY3oZj2t+lt8sGADWh SWPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=H0WS0yQuleoeiH8PJsGDBVZNIcsouUngQTFxZ/dem1Y=; fh=xMUYGR5C8+McctmCx2X9pCOTqnkpi4NOZ0+LAOnp8Hk=; b=TzOVuR8/45hKICh4DiWkmXklBtKQSsGOlff8havaAd4CxrNTf1HYbM+XVxIPM7wUya AY7ebxYnp23i3Z3X7E2hw04R4mjW7wgTk+/hXR1SJ+42KcMQXlOE407Wy8DEaxPuA43e Nsz2p3v0V2DQx8JtkkaepbKh6ni5X+jYPmbgxGrkKncDME9eVgIFWfK0gbtpCU0rInln daux5DpHRuucJ4c99z1FDP6OeiqAf3DVq2LbY7gPAUoqSfLGYGQBFkQbZSyTvTx+CKEf +1m7/XIQUu5aN/UEwzvZHDDDWDhBCM6oMs9Lg/fW31E28Oe7S0xtdFcmbYFM+1ragUFn KoNg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-70140-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70140-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h14-20020a05622a170e00b0042dd5c5f24asi3596852qtk.82.2024.02.17.17.40.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 17:40:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70140-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-70140-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70140-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9A7E51C20BA0 for ; Sun, 18 Feb 2024 01:40:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 628ACA5F; Sun, 18 Feb 2024 01:40:16 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4185EBB for ; Sun, 18 Feb 2024 01:40:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708220415; cv=none; b=uCtGH7vdZGtSIcAofwuwknWsvoFMdy5RrbpmPSTyRTL6xFxmrzHnfEn1xX2oro0SSIhHXselDgCVT5/Ae+Ck9jsO9XF3VgXV/Msndorx3NB+Euysb34iRDIK67+CYXH1Wn4GbTFwJI/HR5cHf6gnq3/Gg6XirJu/0sFLLmiapi8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708220415; c=relaxed/simple; bh=WNQbxKVFpHm9Lmd2Xka8K18EGXlXYe/WvQMzH4jHjUM=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=PpDJrbGa3jnOSOk5vciR9ROVhwKXNR8jVDT8WxmKVneo6TCyHVh6itxXZgRIWyD4aPHISIl7VrwlVHp2+M2pt2DZ/vwQBtsGh7uBGC15mHwxjt6RUFyjI8UcSMXaoj/8uwJ5cDgW/KKY2Z3xh+YbssWeDkh+ZlazkKsO8CX9LFw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4TcpG41X3cz1gydy; Sun, 18 Feb 2024 09:38:04 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id DBFE11400CC; Sun, 18 Feb 2024 09:40:09 +0800 (CST) Received: from [10.174.178.46] (10.174.178.46) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Sun, 18 Feb 2024 09:40:08 +0800 Subject: Re: [PATCH 2/2] ubifs: fix function pointer cast warnings To: Arnd Bergmann , Richard Weinberger , Nathan Chancellor CC: Arnd Bergmann , Nick Desaulniers , Bill Wendling , Justin Stitt , , , References: <20240213095412.453787-1-arnd@kernel.org> <20240213095412.453787-2-arnd@kernel.org> From: Zhihao Cheng Message-ID: <0921a996-c579-5760-a6ff-dbd9b9eca057@huawei.com> Date: Sun, 18 Feb 2024 09:40:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240213095412.453787-2-arnd@kernel.org> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600013.china.huawei.com (7.193.23.68) ?? 2024/2/13 17:54, Arnd Bergmann ะด??: > From: Arnd Bergmann > > ubifs has a number of callback functions for ubifs_lpt_scan_nolock() using > two different prototypes, either passing a struct scan_data or > a struct ubifs_lp_stats, but the caller expects a void pointer instead. > > clang-16 now warns about this: > > fs/ubifs/find.c:170:9: error: cast from 'int (*)(struct ubifs_info *, const struct ubifs_lprops *, int, struct scan_data *)' to 'ubifs_lpt_scan_callback' (aka 'int (*)(struct ubifs_info *, const struct ubifs_lprops *, int, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] > 170 | (ubifs_lpt_scan_callback)scan_for_dirty_cb, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > fs/ubifs/find.c:449:9: error: cast from 'int (*)(struct ubifs_info *, const struct ubifs_lprops *, int, struct scan_data *)' to 'ubifs_lpt_scan_callback' (aka 'int (*)(struct ubifs_info *, const struct ubifs_lprops *, int, void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict] > 449 | (ubifs_lpt_scan_callback)scan_for_free_cb, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Change all of these callback functions to actually take the void * argument > that is passed by their caller. > > Signed-off-by: Arnd Bergmann > --- > fs/ubifs/find.c | 23 ++++++++++++----------- > fs/ubifs/lprops.c | 6 +++--- > 2 files changed, 15 insertions(+), 14 deletions(-) > Reviewed-by: Zhihao Cheng > diff --git a/fs/ubifs/find.c b/fs/ubifs/find.c > index 1cb79b167a4f..6ebf3c04ac5f 100644 > --- a/fs/ubifs/find.c > +++ b/fs/ubifs/find.c > @@ -82,8 +82,9 @@ static int valuable(struct ubifs_info *c, const struct ubifs_lprops *lprops) > */ > static int scan_for_dirty_cb(struct ubifs_info *c, > const struct ubifs_lprops *lprops, int in_tree, > - struct scan_data *data) > + void *arg) > { > + struct scan_data *data = arg; > int ret = LPT_SCAN_CONTINUE; > > /* Exclude LEBs that are currently in use */ > @@ -166,8 +167,7 @@ static const struct ubifs_lprops *scan_for_dirty(struct ubifs_info *c, > data.pick_free = pick_free; > data.lnum = -1; > data.exclude_index = exclude_index; > - err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, > - (ubifs_lpt_scan_callback)scan_for_dirty_cb, > + err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, scan_for_dirty_cb, > &data); > if (err) > return ERR_PTR(err); > @@ -349,8 +349,9 @@ int ubifs_find_dirty_leb(struct ubifs_info *c, struct ubifs_lprops *ret_lp, > */ > static int scan_for_free_cb(struct ubifs_info *c, > const struct ubifs_lprops *lprops, int in_tree, > - struct scan_data *data) > + void *arg) > { > + struct scan_data *data = arg; > int ret = LPT_SCAN_CONTINUE; > > /* Exclude LEBs that are currently in use */ > @@ -446,7 +447,7 @@ const struct ubifs_lprops *do_find_free_space(struct ubifs_info *c, > data.pick_free = pick_free; > data.lnum = -1; > err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, > - (ubifs_lpt_scan_callback)scan_for_free_cb, > + scan_for_free_cb, > &data); > if (err) > return ERR_PTR(err); > @@ -589,8 +590,9 @@ int ubifs_find_free_space(struct ubifs_info *c, int min_space, int *offs, > */ > static int scan_for_idx_cb(struct ubifs_info *c, > const struct ubifs_lprops *lprops, int in_tree, > - struct scan_data *data) > + void *arg) > { > + struct scan_data *data = arg; > int ret = LPT_SCAN_CONTINUE; > > /* Exclude LEBs that are currently in use */ > @@ -625,8 +627,7 @@ static const struct ubifs_lprops *scan_for_leb_for_idx(struct ubifs_info *c) > int err; > > data.lnum = -1; > - err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, > - (ubifs_lpt_scan_callback)scan_for_idx_cb, > + err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, scan_for_idx_cb, > &data); > if (err) > return ERR_PTR(err); > @@ -781,8 +782,9 @@ int ubifs_save_dirty_idx_lnums(struct ubifs_info *c) > */ > static int scan_dirty_idx_cb(struct ubifs_info *c, > const struct ubifs_lprops *lprops, int in_tree, > - struct scan_data *data) > + void *arg) > { > + struct scan_data *data = arg; > int ret = LPT_SCAN_CONTINUE; > > /* Exclude LEBs that are currently in use */ > @@ -841,8 +843,7 @@ static int find_dirty_idx_leb(struct ubifs_info *c) > if (c->pnodes_have >= c->pnode_cnt) > /* All pnodes are in memory, so skip scan */ > return -ENOSPC; > - err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, > - (ubifs_lpt_scan_callback)scan_dirty_idx_cb, > + err = ubifs_lpt_scan_nolock(c, -1, c->lscan_lnum, scan_dirty_idx_cb, > &data); > if (err) > return err; > diff --git a/fs/ubifs/lprops.c b/fs/ubifs/lprops.c > index 6d6cd85c2b4c..a11c3dab7e16 100644 > --- a/fs/ubifs/lprops.c > +++ b/fs/ubifs/lprops.c > @@ -1014,8 +1014,9 @@ void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat, > */ > static int scan_check_cb(struct ubifs_info *c, > const struct ubifs_lprops *lp, int in_tree, > - struct ubifs_lp_stats *lst) > + void *arg) > { > + struct ubifs_lp_stats *lst = arg; > struct ubifs_scan_leb *sleb; > struct ubifs_scan_node *snod; > int cat, lnum = lp->lnum, is_idx = 0, used = 0, free, dirty, ret; > @@ -1269,8 +1270,7 @@ int dbg_check_lprops(struct ubifs_info *c) > > memset(&lst, 0, sizeof(struct ubifs_lp_stats)); > err = ubifs_lpt_scan_nolock(c, c->main_first, c->leb_cnt - 1, > - (ubifs_lpt_scan_callback)scan_check_cb, > - &lst); > + scan_check_cb, &lst); > if (err && err != -ENOSPC) > goto out; > >