2022-02-09 13:54:02

by CGEL

[permalink] [raw]
Subject: [PATCH] fbcon: use min() to make code cleaner

From: Changcheng Deng <[email protected]>

Use min() in order to make code cleaner.

Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Changcheng Deng <[email protected]>
---
drivers/video/fbdev/core/fbcon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
index f36829eeb5a9..61171159fee2 100644
--- a/drivers/video/fbdev/core/fbcon.c
+++ b/drivers/video/fbdev/core/fbcon.c
@@ -602,7 +602,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
save = kmalloc(array3_size(logo_lines, new_cols, 2),
GFP_KERNEL);
if (save) {
- int i = cols < new_cols ? cols : new_cols;
+ int i = min(cols, new_cols);
scr_memsetw(save, erase, array3_size(logo_lines, new_cols, 2));
r = q - step;
for (cnt = 0; cnt < logo_lines; cnt++, r += i)
--
2.25.1



2022-02-09 19:49:31

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] fbcon: use min() to make code cleaner

On Wed, Feb 09, 2022 at 08:48:10AM +0000, [email protected] wrote:
> From: Changcheng Deng <[email protected]>
>
> Use min() in order to make code cleaner.
>
> Reported-by: Zeal Robot <[email protected]>
> Signed-off-by: Changcheng Deng <[email protected]>
Reviewed-by: Sam Ravnborg <[email protected]>

I had preferred in minmax.h was included, but it has an indirect include
so shrug.

I assume Daniel or Helge will pick it up.

Sam

> ---
> drivers/video/fbdev/core/fbcon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index f36829eeb5a9..61171159fee2 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -602,7 +602,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
> save = kmalloc(array3_size(logo_lines, new_cols, 2),
> GFP_KERNEL);
> if (save) {
> - int i = cols < new_cols ? cols : new_cols;
> + int i = min(cols, new_cols);
> scr_memsetw(save, erase, array3_size(logo_lines, new_cols, 2));
> r = q - step;
> for (cnt = 0; cnt < logo_lines; cnt++, r += i)
> --
> 2.25.1

2022-02-09 23:27:36

by Helge Deller

[permalink] [raw]
Subject: Re: [PATCH] fbcon: use min() to make code cleaner

On 2/9/22 19:54, Sam Ravnborg wrote:
> On Wed, Feb 09, 2022 at 08:48:10AM +0000, [email protected] wrote:
>> From: Changcheng Deng <[email protected]>
>>
>> Use min() in order to make code cleaner.
>>
>> Reported-by: Zeal Robot <[email protected]>
>> Signed-off-by: Changcheng Deng <[email protected]>
> Reviewed-by: Sam Ravnborg <[email protected]>
>
> I had preferred in minmax.h was included, but it has an indirect include
> so shrug.
>
> I assume Daniel or Helge will pick it up.

Daniel has quite some upcoming changes to core/fbcon, so I prefer
that he takes it when he thinks it's the right time...

Helge

>
>> ---
>> drivers/video/fbdev/core/fbcon.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
>> index f36829eeb5a9..61171159fee2 100644
>> --- a/drivers/video/fbdev/core/fbcon.c
>> +++ b/drivers/video/fbdev/core/fbcon.c
>> @@ -602,7 +602,7 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
>> save = kmalloc(array3_size(logo_lines, new_cols, 2),
>> GFP_KERNEL);
>> if (save) {
>> - int i = cols < new_cols ? cols : new_cols;
>> + int i = min(cols, new_cols);
>> scr_memsetw(save, erase, array3_size(logo_lines, new_cols, 2));
>> r = q - step;
>> for (cnt = 0; cnt < logo_lines; cnt++, r += i)
>> --
>> 2.25.1