From patchwork Mon Apr 15 19:34:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13630600 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E3043C00A94 for ; Mon, 15 Apr 2024 19:37:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q/1HIHLdwKeWIK7v8vAPM81y5EDG3tZMZwuW8iq/CFA=; b=cV+G2r7aHst6gk b0kMVxPTWaLODUJeeTThCcbfobwYxziB/pF9RvsAcRtuOXgzoQdpO9ES8mUH1KW3/dUbf3yN7ajUl 3Nw9R+P0FS/RbAEiOX3KFy6TyK/3GcIf4L0LjWmzJfWk44eWB83Tyq06nuRTkSw+97bFAVAgKRkdg 6xdIDoBAZ9wV6PAxDLVhRbKIx3e6dahT1okir/z0rpZeQwamYaE+/4c8Y6znIeMaQwVIfv71RHD0J nr+2AGAPCB/iwkfCqTnQTV+D30NdDrzqL9I+v/VC+0D1L70RLyvABjEHajo++oXqi7Z6+/SnWDSxi P0SMzBs8/RnhOcy3t6bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwS8U-00000009dQH-2RtG; Mon, 15 Apr 2024 19:37:02 +0000 Received: from mail-qk1-x731.google.com ([2607:f8b0:4864:20::731]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwS6O-00000009c6A-1dUz for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 19:34:55 +0000 Received: by mail-qk1-x731.google.com with SMTP id af79cd13be357-78d543db3a4so272579785a.0 for ; Mon, 15 Apr 2024 12:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713209690; x=1713814490; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=cKMvbnJBvce6w6rhgAtTaziLR0gQM5TDA935faRghdc=; b=hZlszzlgbAW6CeHqDfWA0DxNT76rUM3rFB2LKmsjx5NrhrsjD/tfr52Wbh+v++wMrB zjJ23wZfhfO3ltdjxOt83A91N6QQxiSfsFQXIPn096c6qwjUw1rbYY7na9cNvs6Mb15o +DeKjJJ0ioo5SVGslephigA05Ff14AlMOXoWA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713209690; x=1713814490; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cKMvbnJBvce6w6rhgAtTaziLR0gQM5TDA935faRghdc=; b=IoLl0XlSYjXLGaB7DgqrhXquJEGh2vWuHrXcynxrfGHrVgM0MnV4S+pb3giH4GIGZv cPPIwza+qmhDIOuL2hlQi4BFr7pMrBJHdVnzicUbnFqsTG/dhrfRvuqnigHsZE30TCbq qqbAc0l+djtfaYnwnGOd8d4ZbylLi3s2pnKsMWBNdA+JptN/OpH6pV48rwblRP+XQif0 JG8FZnNJs2+MLfKsQlQYAvRIpuy6AEQUIbchC0N1VqsrW1x+YytjIxuBec1Y8mQFts+6 eUzlrBroMGs2avJfEH8q1g8OtUa//Y9yu9p628tf4FRguq1m8ldnxVuVCTSz3yLPvzsN TeiA== X-Forwarded-Encrypted: i=1; AJvYcCUvJtrgF8Lg1ofAEfPGS8ELsMcRM74Fv8krjSdYJBj7+P7eGdDeZQWNH4mZgUUr76nELUFAJqC7t6yttD75h11HljJRreDKX6A97SVAf6w+U1kxqUE= X-Gm-Message-State: AOJu0Yzuw4WaQniPigCYCunEnw/LLYe7AINaAjYGHGOFJY59a1JskfN2 lHy3Zd7nU7s7xcj3MLWtRM9Iwp2kljA94lqrxGpClRSp3DzqWX9AV9nlSAjffw== X-Google-Smtp-Source: AGHT+IEuVGO99fF8WY6cFUn2TeptksBJEwdpaYOr7CSPDLRmva6Ltt+et0Zcs6jy4zj82KXO8YnR2A== X-Received: by 2002:a05:620a:4486:b0:78d:65e0:3100 with SMTP id x6-20020a05620a448600b0078d65e03100mr15166755qkp.60.1713209690125; Mon, 15 Apr 2024 12:34:50 -0700 (PDT) Received: from denia.c.googlers.com (114.152.245.35.bc.googleusercontent.com. [35.245.152.114]) by smtp.gmail.com with ESMTPSA id s26-20020ae9f71a000000b0078d3b54eb76sm6718055qkg.78.2024.04.15.12.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 12:34:49 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 15 Apr 2024 19:34:36 +0000 Subject: [PATCH 19/35] media: stk1160: Use min macro MIME-Version: 1.0 Message-Id: <20240415-fix-cocci-v1-19-477afb23728b@chromium.org> References: <20240415-fix-cocci-v1-0-477afb23728b@chromium.org> In-Reply-To: <20240415-fix-cocci-v1-0-477afb23728b@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , Hans Verkuil , Hugues Fruchet , Alain Volmat , Maxime Coquelin , Alexandre Torgue , Paul Kocialkowski , Greg Kroah-Hartman , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sakari Ailus , Thierry Reding , Jonathan Hunter , Sowjanya Komatineni , Luca Ceresoli , Matthias Brugger , AngeloGioacchino Del Regno , Hans Verkuil , Sergey Kozlov , Abylay Ospan , Ezequiel Garcia , Dmitry Osipenko , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio , Benjamin Mugnier , Sylvain Petinot , Jacopo Mondi , Kieran Bingham , Laurent Pinchart , =?utf-8?q?Ni?= =?utf-8?q?klas_S=C3=B6derlund?= , Pavel Machek Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-msm@vger.kernel.org, Ricardo Ribalda X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240415_123452_669415_938AA36D X-CRM114-Status: GOOD ( 14.59 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Simplifies the code. Found by cocci: drivers/media/usb/stk1160/stk1160-video.c:133:12-13: WARNING opportunity for min() drivers/media/usb/stk1160/stk1160-video.c:176:13-14: WARNING opportunity for min() Signed-off-by: Ricardo Ribalda Reviewed-by: Bryan O'Donoghue --- drivers/media/usb/stk1160/stk1160-video.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c index 366f0e4a5dc0..0ba0f41fe3f4 100644 --- a/drivers/media/usb/stk1160/stk1160-video.c +++ b/drivers/media/usb/stk1160/stk1160-video.c @@ -130,10 +130,7 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len) dst += linesdone * bytesperline * 2 + lineoff; /* Copy the remaining of current line */ - if (remain < (bytesperline - lineoff)) - lencopy = remain; - else - lencopy = bytesperline - lineoff; + lencopy = min(remain, bytesperline - lineoff); /* * Check if we have enough space left in the buffer. @@ -173,10 +170,7 @@ void stk1160_copy_video(struct stk1160 *dev, u8 *src, int len) src += lencopy; /* Copy one line at a time */ - if (remain < bytesperline) - lencopy = remain; - else - lencopy = bytesperline; + lencopy = min(remain, bytesperline); /* * Check if we have enough space left in the buffer.