From patchwork Mon Nov 7 03:59:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 16232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1818932wru; Sun, 6 Nov 2022 20:04:44 -0800 (PST) X-Google-Smtp-Source: AMsMyM5SrYGkAqHohKRdMqDiG8dvIb3Xxbdz5pzArV7GNsjNsdSEyk6hSrPShhRu1lHDs9xHNuA3 X-Received: by 2002:a17:903:2341:b0:188:5bb2:d52 with SMTP id c1-20020a170903234100b001885bb20d52mr19187735plh.32.1667793883732; Sun, 06 Nov 2022 20:04:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667793883; cv=none; d=google.com; s=arc-20160816; b=h9aWKXHSAN4+09hJ3iupEpXa1fkgM/5wOdlLFjYT8hJFOl4/V6RoSrJhrQSVmyyL3G 8bRy9v80gLQ96CjTKiYRG3xkW3JKMFXFEdbEC0MzsjtSupUwQt/WKJPc873wZqWTEiWi H9N5wKDF36hCjn1TG5AIkI94WDChBqAf/rl1BUG5r1Q8YTft1Wdfj79umpzx0o5jbX4t m7nTxw8BVIkqyJFaQ0kwCvLiapH31xkTzRQCzK/5Ld8Q1sbkaFnXGT9bUBuCPQOm7AMH vOSHiWYj3EJMf15J4nG6i97/1OBi0GIW/X+IEf9L6L4yO+dlton8+mwtH35rwotUXZT4 CbUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=GeGYkVDUyjBhPLdUPgCsLKMSMMzt4cvhY1MG27UMVhE=; b=eFMN0R/LltaXZd6WEZM9uj2nopUN3rr3AZL4Leqnh0SFnYCaVnUFnFKH8tyHCjuORH WlADs/zqKD617gkC/HvS9JFCCZB4HIcm8ZOXLpdNP9zEjc9M4evwMNKHFMvRQjCY5loY RMIqvTQZWYAgCTUlrBG55Pz6eyQNX6PvROKDW4A6UH2mRVyE0Hj0Ig1qHiXFjGQMJR8f AF6ey7zQCfd7Yfx1oigstE8DQQkETbvFqMOZ0zc4NWdhaTbo29j4v4ELoqvuIzp5GMO5 +zAlXJ0KhHk6hWe2OcptqpCexOef9CQc0w3pV8UJW5WSn5zFZ6AgGj55xwDeQw8I7Sc5 tCZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=YdXnXEFb; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x34-20020a631722000000b00434c05007d5si8983443pgl.845.2022.11.06.20.04.30; Sun, 06 Nov 2022 20:04:43 -0800 (PST) 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=fail header.i=@mailo.com header.s=mailo header.b=YdXnXEFb; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbiKGD7Y (ORCPT + 99 others); Sun, 6 Nov 2022 22:59:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230302AbiKGD7U (ORCPT ); Sun, 6 Nov 2022 22:59:20 -0500 Received: from msg-4.mailo.com (msg-4.mailo.com [213.182.54.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB5AF10066 for ; Sun, 6 Nov 2022 19:59:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1667793550; bh=PWveDsnayKgrwHoxVXJd7rB504HWxfroON00hivoOew=; h=X-EA-Auth:Date:From:To:Subject:Message-ID:MIME-Version: Content-Type; b=YdXnXEFbW9DR84+iQYgGw8mU2/2+6Bb8Wwll1qOCq4uZ4C18UFwzkjyzz8M9CGjKY 4G85+g/j+Pw/ehmO6twUGpIWGUtMEH2ymEhY8JaYmb8LRXmq+tRppsXo2A7Pzh5KdO vVYc3UXABM2TfdPXmo+/u4T/KqvpMkk6mhx9SXSQ= Received: by b-3.in.mailobj.net [192.168.90.13] with ESMTP via ip-206.mailobj.net [213.182.55.206] Mon, 7 Nov 2022 04:59:10 +0100 (CET) X-EA-Auth: kW7V4VN242VMCTbuSQIdbYqXwNnnKreCRhtWZoxe9kVNSMa8hCD5XlxbnutT/5ApyQQFpSH0lrGK4birqbcL2Px+W7eI+2Au Date: Mon, 7 Nov 2022 09:29:04 +0530 From: Deepak R Varma To: Greg Kroah-Hartman , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] staging: most: video: use min_t() for comparison and assignment Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748808639479979231?= X-GMAIL-MSGID: =?utf-8?q?1748808639479979231?= Simplify code by using min_t helper macros in place of lengthy if/else block oriented logical evaluation and value assignment. Use the _t variant of min macro since the variable types are not same. This issue is identified by coccicheck using the minmax.cocci file. Signed-off-by: Deepak R Varma --- drivers/staging/most/video/video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.34.1 diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c index ffa97ef21ea5..d5cc7eea3b52 100644 --- a/drivers/staging/most/video/video.c +++ b/drivers/staging/most/video/video.c @@ -173,7 +173,7 @@ static ssize_t comp_vdev_read(struct file *filp, char __user *buf, while (count > 0 && data_ready(mdev)) { struct mbo *const mbo = get_top_mbo(mdev); int const rem = mbo->processed_length - fh->offs; - int const cnt = rem < count ? rem : count; + int const cnt = min_t(int, rem, count); if (copy_to_user(buf, mbo->virt_address + fh->offs, cnt)) { v4l2_err(&mdev->v4l2_dev, "read: copy_to_user failed\n");