[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJZ5v0i3Ew=LPPzVw5Vtttpq+H=YuCrU_LN1b7W9Kj0v5JQ5gA@mail.gmail.com>
Date: Tue, 28 Mar 2023 17:21:55 +0200
From: "Rafael J. Wysocki" <rafael@...nel.org>
To: Jiangshan Yi <yijiangshan@...inos.cn>
Cc: robert.moore@...el.com, rafael.j.wysocki@...el.com,
lenb@...nel.org, linux-acpi@...r.kernel.org,
acpica-devel@...ts.linuxfoundation.org,
linux-kernel@...r.kernel.org, 13667453960@....com
Subject: Re: [PATCH] drivers/acpi/acpica/exserial.c: replace ternary operator
with min()
On Tue, Mar 28, 2023 at 3:52 AM Jiangshan Yi <yijiangshan@...inos.cn> wrote:
>
> Fix the following coccicheck warning:
>
> drivers/acpi/acpica/exserial.c:346: WARNING opportunity for min().
>
> min() macro is defined in include/linux/minmax.h. It avoids
> multiple evaluations of the arguments when non-constant and performs
> strict type-checking.
>
> Signed-off-by: Jiangshan Yi <yijiangshan@...inos.cn>
ACPICA changes need to be submitted as pull requests to the upstream
project on GitHub. When that happens, a Linux patch based on an
upstream ACPICA PR can be submitted with a Link: tag pointing to that
PR.
Thanks!
> ---
> drivers/acpi/acpica/exserial.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/acpi/acpica/exserial.c b/drivers/acpi/acpica/exserial.c
> index fd63f2042514..dfe507e0a09a 100644
> --- a/drivers/acpi/acpica/exserial.c
> +++ b/drivers/acpi/acpica/exserial.c
> @@ -343,8 +343,7 @@ acpi_ex_write_serial_bus(union acpi_operand_object *source_desc,
> /* Copy the input buffer data to the transfer buffer */
>
> buffer = buffer_desc->buffer.pointer;
> - data_length = (buffer_length < source_desc->buffer.length ?
> - buffer_length : source_desc->buffer.length);
> + data_length = min(buffer_length, source_desc->buffer.length);
> memcpy(buffer, source_desc->buffer.pointer, data_length);
>
> /* Lock entire transaction if requested */
> --
> 2.27.0
>
Powered by blists - more mailing lists