Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp435625rwe; Thu, 25 Aug 2022 03:11:56 -0700 (PDT) X-Google-Smtp-Source: AA6agR6+i5Jy74gjIY9QNWv3QkYB8OuUMNuZl+TvT4+xWbIxcsYwIwfl4UqnkeY2wzSYL2T6qmEZ X-Received: by 2002:a63:8743:0:b0:42b:4d1b:db0 with SMTP id i64-20020a638743000000b0042b4d1b0db0mr2029646pge.607.1661422315996; Thu, 25 Aug 2022 03:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661422315; cv=none; d=google.com; s=arc-20160816; b=Snnouxm5FXjTbYViHpDOOm/ozNJ8ptoEN0m/PF9ZLaGHHwCBc6oGUimuMMDTHF4SyP hY0+l6MqRZIguoGmKh4MxLzrT07MQXTiFK1Iy4JYD6snfwL+Iok0uRPEc9YBpADw/qUx vQzF6n/ECxtXInZgxF8E6dWEiktw6VE4nbtWuF49isNmsiWV/pnrL7Ss9jBcQJRdCqXq RORsHk4eUHQxidcbkkDAfY7xmG8qJIA+koiCM+RXqfRxtxa+utHGoVfQi+gUpMuuJ5gx r9TXQhqTJpy+BcWBG7JOnIeVqfVBzOSDcrF7amBqylK9M93mA7f/hiZTqE+vgHcaASDA U0gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=vsWreB60jvSvb2RpFpErH+SeZYbUPNjuEh9amyOPQak=; b=XPh0KXc58l1ZKsHUmEUZeA48+4xsCzjCWZXCBadbhcT+XBTYSNnt1sY3+LKPXBu2Le z6Cj4FNC1FiKemmtIr6PRMVJ6U/2WMuarBrCHccFhG366VeaDm9D1TDDFdGS0bm93S// m5G2WdKJneMsarG0Euz1EjO2RNLEKM6DMC0+cGN8JZpo9ypx3uPw8FUxGo3UJKkk8Rio 8x9wSuPpIGpNHICq/k0vvhud0uNDmQI8ekJnUPk/bBzmI4syH8ThCbuAXFslOCahrdRz NiPsEzqwb5rCEPrbMLiRUn5WpNnk57EySOJXv7h7HO4keQCm7Xhs0eiCKaC26fOE/U4x e9/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RficcT4m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q199-20020a632ad0000000b0041d0a3e7de3si22216211pgq.796.2022.08.25.03.11.44; Thu, 25 Aug 2022 03:11:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RficcT4m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240103AbiHYJaR (ORCPT + 99 others); Thu, 25 Aug 2022 05:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234415AbiHYJaO (ORCPT ); Thu, 25 Aug 2022 05:30:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FB7254669; Thu, 25 Aug 2022 02:30:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CE05861BE6; Thu, 25 Aug 2022 09:30:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1ACBC433D6; Thu, 25 Aug 2022 09:30:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1661419811; bh=L+0sXmx3plDatFgNg4UJoNuIQ/1S5Vx8B0Xd9YUiaZ8=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=RficcT4mEcQK7KICgYfApQfkkwbhkoNIXWvgSNZBHQwxDMUuPe8nLksV3+nsoWiXi INl4jOWJNbt8JA+d9a4LHowOOuCH4dcAKeJiVfwqPJ1IObit0z9qjmHVJQLoh8PDBy wG1k21fNEWDYQZbUuVwoeAY585DVqJMU3vkinUzfGrQjdbf7i3hwlxyyl1D+YbUxAp 05JYjVbKzSjioxsRK/zbDx0+C4jQfh23baof986uVXGqH6OdUymxqp8hMGMZDORaOI 6arWSoVJVpaM++wsBbnf7nw+bppAanXXEk7lgtazOgGOicGFDqun2b+DaaffQ0VAQ2 +f3UbxTps1tXw== Date: Thu, 25 Aug 2022 11:30:07 +0200 (CEST) From: Jiri Kosina To: Jiangshan Yi <13667453960@163.com> cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Jiangshan Yi Subject: Re: [PATCH] HID: rmi: replace ternary operator with min() In-Reply-To: <20220713032047.2238205-1-13667453960@163.com> Message-ID: References: <20220713032047.2238205-1-13667453960@163.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Jul 2022, Jiangshan Yi wrote: > From: Jiangshan Yi > > Fix the following coccicheck warning: > > drivers/hid/hid-rmi.c:240: WARNING opportunity for min(). > drivers/hid/hid-rmi.c:350: 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 > --- > drivers/hid/hid-rmi.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c > index 311eee599ce9..bb1f423f4ace 100644 > --- a/drivers/hid/hid-rmi.c > +++ b/drivers/hid/hid-rmi.c > @@ -237,8 +237,7 @@ static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr, > > read_input_count = data->readReport[1]; > memcpy(buf + bytes_read, &data->readReport[2], > - read_input_count < bytes_needed ? > - read_input_count : bytes_needed); > + min(read_input_count, bytes_needed)); > > bytes_read += read_input_count; > bytes_needed -= read_input_count; > @@ -347,8 +346,7 @@ static int rmi_read_data_event(struct hid_device *hdev, u8 *data, int size) > return 0; > } > > - memcpy(hdata->readReport, data, size < hdata->input_report_size ? > - size : hdata->input_report_size); > + memcpy(hdata->readReport, data, min((u32)size, hdata->input_report_size)); > set_bit(RMI_READ_DATA_PENDING, &hdata->flags); > wake_up(&hdata->wait); Applied, thanks. -- Jiri Kosina SUSE Labs