mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Arnd Bergmann <arnd@kernel.org>,
	Richard Weinberger <richard@nod.at>,
	Nathan Chancellor <nathan@kernel.org>,
	Adrian Hunter <ext-adrian.hunter@nokia.com>,
	Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	<linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
	<llvm@lists.linux.dev>
Subject: Re: [PATCH 1/2] ubifs: fix sort function prototype
Date: Sun, 18 Feb 2024 09:25:43 +0800	[thread overview]
Message-ID: <e9687d56-1ee4-37ee-4a0e-d0b7933f3353@huawei.com> (raw)
In-Reply-To: <20240213095412.453787-1-arnd@kernel.org>

在 2024/2/13 17:54, Arnd Bergmann 写道:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The global sort() function expects a callback pointer to a function with two
> void* arguments, but ubifs has a function with specific object types, which
> causes a warning in clang-16 and higher:
> 
> fs/ubifs/lprops.c:1272:9: error: cast from 'int (*)(struct ubifs_info *, const struct ubifs_lprops *, int, struct ubifs_lp_stats *)' 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]
>   1272 |                                     (ubifs_lpt_scan_callback)scan_check_cb,
>        |                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Change the prototype to the regular one and cast the object pointers
> locally instead.
> 
> Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   fs/ubifs/find.c | 9 ++++-----
>   1 file changed, 4 insertions(+), 5 deletions(-)

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> 
> diff --git a/fs/ubifs/find.c b/fs/ubifs/find.c
> index 873e6e1c92b5..1cb79b167a4f 100644
> --- a/fs/ubifs/find.c
> +++ b/fs/ubifs/find.c
> @@ -726,11 +726,10 @@ int ubifs_find_free_leb_for_idx(struct ubifs_info *c)
>   	return err;
>   }
>   
> -static int cmp_dirty_idx(const struct ubifs_lprops **a,
> -			 const struct ubifs_lprops **b)
> +static int cmp_dirty_idx(const void *a, const void *b)
>   {
> -	const struct ubifs_lprops *lpa = *a;
> -	const struct ubifs_lprops *lpb = *b;
> +	const struct ubifs_lprops *lpa = *(const struct ubifs_lprops **)a;
> +	const struct ubifs_lprops *lpb = *(const struct ubifs_lprops **)b;
>   
>   	return lpa->dirty + lpa->free - lpb->dirty - lpb->free;
>   }
> @@ -754,7 +753,7 @@ int ubifs_save_dirty_idx_lnums(struct ubifs_info *c)
>   	       sizeof(void *) * c->dirty_idx.cnt);
>   	/* Sort it so that the dirtiest is now at the end */
>   	sort(c->dirty_idx.arr, c->dirty_idx.cnt, sizeof(void *),
> -	     (int (*)(const void *, const void *))cmp_dirty_idx, NULL);
> +	     cmp_dirty_idx, NULL);
>   	dbg_find("found %d dirty index LEBs", c->dirty_idx.cnt);
>   	if (c->dirty_idx.cnt)
>   		dbg_find("dirtiest index LEB is %d with dirty %d and free %d",
> 


      parent reply	other threads:[~2024-02-18  1:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13  9:54 Arnd Bergmann
2024-02-13  9:54 ` [PATCH 2/2] ubifs: fix function pointer cast warnings Arnd Bergmann
2024-02-18  1:40   ` Zhihao Cheng
2024-02-18  1:25 ` Zhihao Cheng [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=e9687d56-1ee4-37ee-4a0e-d0b7933f3353@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=Artem.Bityutskiy@nokia.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=ext-adrian.hunter@nokia.com \
    --cc=justinstitt@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=llvm@lists.linux.dev \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=richard@nod.at \
    /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

all inboxes | Powered by JetHome®