From: Helge Deller <deller@gmx.de>
To: Markus Elfring <Markus.Elfring@web.de>,
kernel-janitors@vger.kernel.org, linux-fbdev@vger.kernel.org,
dri-devel@lists.freedesktop.org, Daniel Vetter <daniel@ffwll.ch>
Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr
Subject: Re: [PATCH 1/2] fbdev: Move two variable assignments in fb_alloc_cmap_gfp()
Date: Wed, 24 May 2023 20:10:55 +0200 [thread overview]
Message-ID: <35bb7db7-bf14-20ba-3bff-80d05c42e28b@gmx.de> (raw)
In-Reply-To: <341b4af7-5c6c-cbd2-6fe3-c0e4e58f3c7d@web.de>
On 5/23/23 22:15, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 23 May 2023 21:30:29 +0200
>
> Move the assignment for the local variables “size” and “flags”
> because the computed values were only used in a single if branch.
Please do not move such variables without real need.
It makes backporting (of this and maybe follow-up patches) much more
complicated and the compiler will optimize it anyway.
Thanks!
Helge
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/video/fbdev/core/fbcmap.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/video/fbdev/core/fbcmap.c b/drivers/video/fbdev/core/fbcmap.c
> index ff09e57f3c38..5c1075ed28ab 100644
> --- a/drivers/video/fbdev/core/fbcmap.c
> +++ b/drivers/video/fbdev/core/fbcmap.c
> @@ -91,16 +91,17 @@ static const struct fb_cmap default_16_colors = {
>
> int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
> {
> - int size = len * sizeof(u16);
> int ret = -ENOMEM;
>
> - flags |= __GFP_NOWARN;
> -
> if (cmap->len != len) {
> + int size;
> +
> fb_dealloc_cmap(cmap);
> if (!len)
> return 0;
>
> + size = len * sizeof(u16);
> + flags |= __GFP_NOWARN;
> cmap->red = kzalloc(size, flags);
> if (!cmap->red)
> goto fail;
> --
> 2.40.1
>
parent reply other threads:[~2023-05-24 18:11 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <341b4af7-5c6c-cbd2-6fe3-c0e4e58f3c7d@web.de>]
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=35bb7db7-bf14-20ba-3bff-80d05c42e28b@gmx.de \
--to=deller@gmx.de \
--cc=Markus.Elfring@web.de \
--cc=cocci@inria.fr \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).