From patchwork Mon Apr 29 15:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 13647154 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 8CC13C4345F for ; Mon, 29 Apr 2024 15:05:55 +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=f9PfJLA/RjPqF/RaRea16xpMTEWBs0fSYxEHCTYu0JI=; b=Cx0KG6oaBasQ/v XSkBjN/7/BrujA14Q+eTt+eSIyfXzHY+gcV3sD+zO+TSRhAhEBz3nWYYkBtw+9DGbv4KF+9GLeMC9 h2MXvty3KONefJOUYv2kWwLHwIe6CzQLsYuutzRDlRyGqaYN1E2aNgTIH+zwd1Ix/mKpfFpcH/2aR dSVSLfnzjkXllSX0usreeVnPzyytsIE9951PeXw2Q3kSX5LLrDzaFtbwgrmV3jooa2CFnBUbyz4Dm DTIpgWKjWrvTqSCFDPHilzsAOnwp6qCSLHBPs0jxfam/mOSLwS9Ae2iLVlJncpUMccnWnGgj+mtvo VY3NtE7w99+1ofydPSJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SZY-00000003Fsx-1NDw; Mon, 29 Apr 2024 15:05:40 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1SYi-00000003FI1-2sba for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 15:04:50 +0000 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-78f049ddd7dso369241685a.1 for ; Mon, 29 Apr 2024 08:04:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714403087; x=1715007887; 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=2ANA0Ymw4Lt0Uz9R7FMbv4c7Ba86EanvWiJ79X90fJk=; b=e5lVo1YPRMe5wRSofk+aF1JjaKu1RV9Lqovo/n5bTx0ChOYT4uyhgRpPRvAiJrM5wR NBIJlJyFFXae/QZbqVxXi/L/hc26KCHlud/hpbsgB9uHfs6yKnehcx+v3+6aW4A1Lta3 5FLo5KvXybijZgEW5cJjpzRLiBlXnNB99JqhU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714403087; x=1715007887; 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=2ANA0Ymw4Lt0Uz9R7FMbv4c7Ba86EanvWiJ79X90fJk=; b=kZQpXED8BrYdRYY+H07HqXJra8OqTobWJ23Y0xQvdJ/+WWG+IOgg77trn09NV23h18 s0+AguNVmDeIDmadrsvvUfz6iVkQFNkr2G6Xi7H6UPK1pH/SYvCgYvn229PRlgp3nkHM uKGiBefe8E8gf8qOGmlGwk2h+q3wVNB4QHGHDewk+J1d5fO8CXL2qg8qUQrSKMNQZemm w39fNsLUH7ntBV5kJqCJFxhVxj4m3zgCcpm/1jE6juPr1UlFnSFm4Q5YTLFJ9AegmG7g sTLZfemfJ/9OEGtnp5YOM7Ze21DaoocLuEJvSqEZd2G7Po3+JMY6J8RkzJdDVzEkzget y8dg== X-Forwarded-Encrypted: i=1; AJvYcCWsQlBXHnKYXZdAEWzIhsLPzRPI0S3epWWUqpjo5VSQEOTDp4JODIjoooBpOA2xvqUJk9/eL1jr/GLwn5aX4k/d/2/tYhsw0K1g29/PZ155ndiug40= X-Gm-Message-State: AOJu0YxpULpjGhOsGpKlxw5hSKOxgTgkcXltd1qz+H8Oa0kLfe+NmjlL 0Ns/VCucmXnKL4HPpE8xSnU09KkCw3ZkeHT80M/jliEPk9StQ3JBsp0pZxDJCA== X-Google-Smtp-Source: AGHT+IEnQjn3WLm+y+PPKHAe/yfoK7DsUlbFKzqXGLCHhSBuNgNTvG4+ilDw6HzfNC7wT8W0tTtiYw== X-Received: by 2002:a37:c449:0:b0:790:98ba:67c5 with SMTP id h9-20020a37c449000000b0079098ba67c5mr11283245qkm.33.1714403087305; Mon, 29 Apr 2024 08:04:47 -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 p7-20020a05620a056700b0078d3b9139edsm10568591qkp.97.2024.04.29.08.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 08:04:47 -0700 (PDT) From: Ricardo Ribalda Date: Mon, 29 Apr 2024 15:04:43 +0000 Subject: [PATCH v3 04/26] media: uvcvideo: Use max() macro MIME-Version: 1.0 Message-Id: <20240429-fix-cocci-v3-4-3c4865f5a4b0@chromium.org> References: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> In-Reply-To: <20240429-fix-cocci-v3-0-3c4865f5a4b0@chromium.org> To: Martin Tuma , Mauro Carvalho Chehab , Laurent Pinchart , 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 , Benjamin Mugnier , Sylvain Petinot , Stanimir Varbanov , Vikash Garodia , Bryan O'Donoghue , Bjorn Andersson , Konrad Dybcio 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 , Sergey Senozhatsky , Kieran Bingham X-Mailer: b4 0.12.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240429_080449_213124_1D0ADA53 X-CRM114-Status: GOOD ( 12.48 ) 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 It makes the code slightly more clear and makes cocci incredibly happy: drivers/media/usb/uvc/uvc_ctrl.c:839:22-23: WARNING opportunity for max() Reviewed-by: Sergey Senozhatsky Reviewed-by: Kieran Bingham Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index a4a987913430..4b685f883e4d 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -836,7 +836,7 @@ static s32 uvc_get_le_value(struct uvc_control_mapping *mapping, while (1) { u8 byte = *data & mask; value |= offset > 0 ? (byte >> offset) : (byte << (-offset)); - bits -= 8 - (offset > 0 ? offset : 0); + bits -= 8 - max(offset, 0); if (bits <= 0) break;