Message ID | 20230721170022.3461-5-andriy.shevchenko@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9010:0:b0:3e4:2afc:c1 with SMTP id l16csp359470vqg; Fri, 21 Jul 2023 10:29:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlH+dtOYE0saCRgi8BAnLAwnBSS0q3LeEmCOUxXv72UKyU6Dsk5hIElEsL9pORKCZ1vFN1jF X-Received: by 2002:a05:6402:1854:b0:51e:d4b:3c9d with SMTP id v20-20020a056402185400b0051e0d4b3c9dmr2019551edy.23.1689960597969; Fri, 21 Jul 2023 10:29:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689960597; cv=none; d=google.com; s=arc-20160816; b=ZA81DElsnhM1sYzH+brsmyVWxSghKyGSrxiJiIgS9d0ppN0ojQp29JPa/I3otJM4tB vd4ATH3zUrqmYBevNq75F31hxCDAZjTZUrkenCY/Krml5lO2xlddY898dFv+svJcsgnC CKwtpratEKaT8PvVnCfX5Y/Cbw1jgFMxtWqg96y3IjqnrFB4G0VFI8qA+taREFjFNGKZ kNjjBi2EhhNW9TX7wRtPJ4RUFTZSTOsqWXYCQuMHQ/g1oedmLYsgzK6pG+lHR2ZmMAc0 UlgaArBn0YiUode13l4GDsmenFOlXhdqtbwrnDLRQIJO9X6hV+8XAqkWAwIXqnAZH0Tw a02A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ns28UV9+6BxfPhEaJOZvh4/qN0snNowpbOsznuSEPgs=; fh=zI/sCjjpFZFpRWFbJrpu9GJ6xSZKd2JacIs4UkYeF5Q=; b=vVdrzzP9gdZoY0cWpvmJHG5TEWW4sSu6a292937KhGCpE+MVsIF85nZpNcEjMKHWPs uMn3IUhncIwevaLCYYTpyNciz7BzcMiU2S7GXw0C+1+I8UsQbVpDwW/quXQo2lpNW5U0 RTRxmRvq7fvvCnxBCckr22dkcRmdXGsF33XA0tidmEnTSDBWidZRuBAAdDwCELyTZSsC 6pWwkoYoQ7WXQfJYQECVqLkyp62q8+qfuVvQ5dAHAwi4o+H0ofJxXlK5E076OevNSYeR gTBYO6kg9aR4lY+/mwp/vOqM8egXsov0q9sz9wpCPb9Pb7LaJwe15bDDac+ub4vTMIRs fSYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=R3GGX5vn; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r16-20020a056402035000b0052160968facsi2597369edw.414.2023.07.21.10.29.34; Fri, 21 Jul 2023 10:29:57 -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=@intel.com header.s=Intel header.b=R3GGX5vn; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231190AbjGURA0 (ORCPT <rfc822;assdfgzxcv4@gmail.com> + 99 others); Fri, 21 Jul 2023 13:00:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230327AbjGURAU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 21 Jul 2023 13:00:20 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2CBE26A0; Fri, 21 Jul 2023 10:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689958818; x=1721494818; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UZLQH0kViux9VJJxBn8faoSNy7gR7pEqp4KmqCGfoYU=; b=R3GGX5vnHWgT7f+TO9myhR7lxYMIEzh33BtzFngVA9TMR/wB9Wud2Aka XixqJ6qfkfWUxsk46BSau0sNO+uvwnqrHkJ92g9PAJmXQX9F+3a6pIFgc oDc/QOiW+XZIN1lR5tviy+VJwabvwsvDFyzxqMrPJUnJi9uMg8UE/k2fd W0tagzMUzIE9zZrAohKsDlyUQPE5sEcm39cCGK/u+1P7vDnQIML1yvoU6 HreOArqOUCV6CfalsLbIOUvd5n+rXAFLgJkrpNt1PpZ89toKi+mL61bAt 35k/ybFoX8b64EDv7kYcsBXp/SjawXVlucacDRHWbWHhEuD06VH+qPC3b w==; X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="369739466" X-IronPort-AV: E=Sophos;i="6.01,222,1684825200"; d="scan'208";a="369739466" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2023 10:00:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10778"; a="754540196" X-IronPort-AV: E=Sophos;i="6.01,222,1684825200"; d="scan'208";a="754540196" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 21 Jul 2023 10:00:15 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 609895FC; Fri, 21 Jul 2023 20:00:23 +0300 (EEST) From: Andy Shevchenko <andriy.shevchenko@linux.intel.com> To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron <jic23@kernel.org>, Lars-Peter Clausen <lars@metafoo.de>, Nuno Sa <nuno.sa@analog.com> Subject: [PATCH v2 4/8] iio: core: Use min() instead of min_t() to make code more robust Date: Fri, 21 Jul 2023 20:00:18 +0300 Message-Id: <20230721170022.3461-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230721170022.3461-1-andriy.shevchenko@linux.intel.com> References: <20230721170022.3461-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772052123968450147 X-GMAIL-MSGID: 1772052123968450147 |
Series |
iio: core: A few code cleanups and documentation fixes
|
|
Commit Message
Andy Shevchenko
July 21, 2023, 5 p.m. UTC
min() has strict type checking and preferred over min_t() for unsigned types to avoid overflow. Here it's unclear why min_t() was chosen since both variables are of the same type. In any case update to use min(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Nuno Sa <nuno.sa@analog.com> --- drivers/iio/industrialio-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Fri, 21 Jul 2023 20:00:18 +0300 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > min() has strict type checking and preferred over min_t() for > unsigned types to avoid overflow. Here it's unclear why min_t() > was chosen since both variables are of the same type. In any > case update to use min(). > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Reviewed-by: Nuno Sa <nuno.sa@analog.com> Applied to the togreg branch of iio.git and pushed out as testing for 0-day to give it a quick sanity check. Thanks, Jonathan > --- > drivers/iio/industrialio-core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c > index 6e28c2a3d223..78cc67efa490 100644 > --- a/drivers/iio/industrialio-core.c > +++ b/drivers/iio/industrialio-core.c > @@ -389,7 +389,7 @@ static ssize_t iio_debugfs_write_reg(struct file *file, > char buf[80]; > int ret; > > - count = min_t(size_t, count, (sizeof(buf)-1)); > + count = min(count, sizeof(buf) - 1); > if (copy_from_user(buf, userbuf, count)) > return -EFAULT; >
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 6e28c2a3d223..78cc67efa490 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -389,7 +389,7 @@ static ssize_t iio_debugfs_write_reg(struct file *file, char buf[80]; int ret; - count = min_t(size_t, count, (sizeof(buf)-1)); + count = min(count, sizeof(buf) - 1); if (copy_from_user(buf, userbuf, count)) return -EFAULT;