Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2264730pxp; Mon, 21 Mar 2022 15:19:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxB+tq45GNtG9Ct8vzCALjdGb1svcmeQzdqWP+Fzl8yqH0U9PlsxUcpxKNePUMNXfluGsj0 X-Received: by 2002:a17:902:a3ca:b0:14f:d48e:aff3 with SMTP id q10-20020a170902a3ca00b0014fd48eaff3mr14883623plb.167.1647901172885; Mon, 21 Mar 2022 15:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647901172; cv=none; d=google.com; s=arc-20160816; b=r0C3snixfjDongFQiYgzG7Z0SYOX6RWKItiicEZ7AF6THDno6KjZDNYKKCVwUp7e0q 3Malin2xNxLEdO2uqrVqprbzKsYzbRnZj9nvzTk4o18/DmbcJCBK2TlP+VNj7x0GFudZ v5elA9eByv+FQZoPx4KXBPgT9Nkc6lMM4977I0huuOBvj1teNx9htW8qtTiJg3LN5c+3 uyJdSwo5PrldehzIpOUeA60Tvsw6kGUPlKJo2lLNOyCaJq/WboLJRQdzofQUNoiXc2U8 auRsIVoYZRvT6KdaPAILIy1ssU7aawtiWs3cpnrKAY2j1sZE7rUWsM1rTe1nnoxmURu7 p+Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=o1Kduo8anLvuf+gwEOcHfJaG3fb6qr826dpjCaVIDzM=; b=yvXqPR4EPrZAwV7tNKX7GghxCoVF5rEFDujjPESrn3e3ZUWL9eW95QnqxP9RtLNvV0 JorsuO7PIGZuQkI+ZPmdattnaQU8gvkwnBOXktIPZbbpzaClKX7/inLvIKa/lldgjcFX gIKeYIToSVBhtbNWqidijcH/CAcGvUw3aVmIX0sflWHpGvIuIr6HVhPOfmWwatY9ej+2 fAFdgjw2RLuLjp7mLSn5br87oPGE+79auSRgbn6MRwTlWXRHZCplUsAZGlSyq5y76Pi0 5w5L1PxpdypaDjCE+uIODIdXslCG1AwkThiEa3q1aLxkOxe9AEZ1vnc/LcVn67dVKrPZ 9nfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v4-20020a1709028d8400b00153b2d164f9si11345958plo.257.2022.03.21.15.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:19:32 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B0A11383546; Mon, 21 Mar 2022 14:36:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241372AbiCUQDt convert rfc822-to-8bit (ORCPT + 99 others); Mon, 21 Mar 2022 12:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348726AbiCUQDs (ORCPT ); Mon, 21 Mar 2022 12:03:48 -0400 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2CACD53A70 for ; Mon, 21 Mar 2022 09:02:23 -0700 (PDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-31-F6hM2S3-NnqEGYc8T09CnQ-1; Mon, 21 Mar 2022 16:02:20 +0000 X-MC-Unique: F6hM2S3-NnqEGYc8T09CnQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Mon, 21 Mar 2022 16:02:20 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.033; Mon, 21 Mar 2022 16:02:20 +0000 From: David Laight To: 'Wan Jiabing' , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Jakub Kicinski , Paolo Abeni , "intel-wired-lan@lists.osuosl.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "alexandr.lobakin@intel.com" Subject: RE: [PATCH v2] ice: use min_t() to make code cleaner in ice_gnss Thread-Topic: [PATCH v2] ice: use min_t() to make code cleaner in ice_gnss Thread-Index: AQHYPSxszwX/VYzTWUmJ1ZXJKTtOx6zJ/3tw Date: Mon, 21 Mar 2022 16:02:20 +0000 Message-ID: References: <20220321135947.378250-1-wanjiabing@vivo.com> In-Reply-To: <20220321135947.378250-1-wanjiabing@vivo.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Wan Jiabing > Sent: 21 March 2022 14:00 > > Fix the following coccicheck warning: > ./drivers/net/ethernet/intel/ice/ice_gnss.c:79:26-27: WARNING opportunity for min() > > Signed-off-by: Wan Jiabing > --- > Changelog: > v2: > - Use typeof(bytes_left) instead of u8. > --- > drivers/net/ethernet/intel/ice/ice_gnss.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_gnss.c b/drivers/net/ethernet/intel/ice/ice_gnss.c > index 35579cf4283f..57586a2e6dec 100644 > --- a/drivers/net/ethernet/intel/ice/ice_gnss.c > +++ b/drivers/net/ethernet/intel/ice/ice_gnss.c > @@ -76,8 +76,7 @@ static void ice_gnss_read(struct kthread_work *work) > for (i = 0; i < data_len; i += bytes_read) { > u16 bytes_left = data_len - i; Oh FFS why is that u16? Don't do arithmetic on anything smaller than 'int' David > > - bytes_read = bytes_left < ICE_MAX_I2C_DATA_SIZE ? bytes_left : > - ICE_MAX_I2C_DATA_SIZE; > + bytes_read = min_t(typeof(bytes_left), bytes_left, ICE_MAX_I2C_DATA_SIZE); > > err = ice_aq_read_i2c(hw, link_topo, ICE_GNSS_UBX_I2C_BUS_ADDR, > cpu_to_le16(ICE_GNSS_UBX_EMPTY_DATA), > -- > 2.35.1 - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)