From patchwork Thu Jul 20 20:53:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13321054 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 D6CB8EB64DD for ; Thu, 20 Jul 2023 20:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229992AbjGTUxZ (ORCPT ); Thu, 20 Jul 2023 16:53:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbjGTUxY (ORCPT ); Thu, 20 Jul 2023 16:53:24 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9192919A6; Thu, 20 Jul 2023 13:53:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689886403; x=1721422403; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cZRvDtegPkJ6Dc6pagLE3ye5wvpxC8MUK6vl7B8hndU=; b=PguHkZZDI9IaFJ/+X1uYuGy9uMVv57tEIOLp1jFO87taNlwzDPUFA/cU ozE4ipYkGBVoSzAgQCSJSRdTcssXfMshO+GZjfs6hhdZ0r8HN5a4Xiikc qIdyJVbi9DpoF5cfBLXWO219PEvJn6PRYlPZRhPOGbJHUgpLoY+/sQ4Zb TF1a8eRSxj8MRm+PQyOsRbFGb8xvGH2yy1MjqBooGI8YpFGP6drsSttVK iOBWkFZiWpIMjwgP1Tnq7k/FVOsVdsO9FA8Xdn3dzLF59OhjbPG0VCCDJ JyKnLh9HyijMKDlciwmHi9OnERbJdmG00wG6cGLDUeL8+5/UCbXoy/HuO g==; X-IronPort-AV: E=McAfee;i="6600,9927,10777"; a="356846038" X-IronPort-AV: E=Sophos;i="6.01,219,1684825200"; d="scan'208";a="356846038" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jul 2023 13:53:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10777"; a="838273934" X-IronPort-AV: E=Sophos;i="6.01,219,1684825200"; d="scan'208";a="838273934" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 20 Jul 2023 13:53:20 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 536B15FC; Thu, 20 Jul 2023 23:53:28 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jonathan Cameron , Lars-Peter Clausen Subject: [PATCH v1 4/8] iio: core: Use min() instead of min_t() to make code more robust Date: Thu, 20 Jul 2023 23:53:20 +0300 Message-Id: <20230720205324.58702-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230720205324.58702-1-andriy.shevchenko@linux.intel.com> References: <20230720205324.58702-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 --- 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 be154879983e..9753f6552db4 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;