From patchwork Fri Jul 21 17:00:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13322379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2393C001DC for ; Fri, 21 Jul 2023 17:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230484AbjGURAW (ORCPT ); Fri, 21 Jul 2023 13:00:22 -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 ); 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 To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen , Nuno Sa 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 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 Reviewed-by: Nuno Sa --- 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;