From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7DF7E430312 for ; Wed, 5 Aug 2026 11:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785928446; cv=none; b=FrPGj76Yl/bdYC9SlL5GTjS9wkcDuBRImkCPn/gDq7zrdS71v6fLFWa9lJoud3Cis1TZWz7crjpCtkhFLm+BeIsetTZVgbJfPAF1v3/VJtSCHUCMT5R9Syvgzko0eL0zMVNO8Afbym5OECtsmhloaXbRkI5Fgv0ixDHrCqKIiuo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785928446; c=relaxed/simple; bh=BFg9rizFQXFR+JyWqckZoLt/k0BQskUdlcyCXw36Q5w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=FxZgowkBMQUPHTu6/AjHdwrs74/sPe9rzzwhaKON4yl5otYbIPI7W/eoJVedCVE7zF8g6ZQI/VtrB4mnpPVhprAOfdLzo0OWdGhZzxEOmQG8sc4t+RyTPfJhAUZo6kI+DZumzZBRRPlbm/CcXkj/EN/1NW7hIJGqjv9YUpddgXA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=X7tZimbm; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X7tZimbm" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-c1677c91969so103725666b.1 for ; Wed, 05 Aug 2026 04:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785928442; x=1786533242; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to:content-type; bh=4qOAvqE6ReTe5rLjM7mwLGU4msCzPkiij9LNmtXv4oY=; b=X7tZimbmBmAKrR5KesuF0UfoqnvdVF14sz/xe9j2jJFSvAWPp/wJHaYHqKnLaTj14i 6J+/5mtxbtyJoXgFQipa21Gxx52M4KkKrYBimpdc5qLg9fN53TjJoG/lhcNSiD7w20NB dllM4CXeDS+rUY7/rbR0iKorQOwAmKbo9ZpsOpuAZrkayJOV+D4pKy+C1mu4ZbFyDkcr +NW7ilkyazpQMlKVOtT2xdNEeVNlNG/bp8NWnd4/LuBQVXK3GSXLVUjeR1T+7cz5LyI/ K/5YnXdw6J4emji+ztwu3T/rMBExnZqNtm3PbNLX4jD0OKGPjBKTNdRycaoAeRASj4Lz kiZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785928443; x=1786533243; h=references:in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4qOAvqE6ReTe5rLjM7mwLGU4msCzPkiij9LNmtXv4oY=; b=EbSe+kpXcVwfTCAuK3r/YUb7Wp31GvzLJZdKvTRMsV25vUse2IRfu3qR6fOP9v/Y2r dSFg3qVitbuKPnCkYSdpyMJh6ljHYgY8ZDe2TVPz5sA5YB9TN3mH7Dpsj6+VkjJy1nVA ZBDu+l7P9QbJk52x6fj+hu85WgfPcP7lSMB/CWFqSGnG+rYitDvjtFrk9boncnRuQSHD tBdTlU5koDwVEZI014szZCuo6MC2KCfiAmqRvPsFBwS94Qe9PsI5xzJ03l7SxMxlFPIZ 7r+il9yxlu3l2vZdScvQIX+6H+mlIBTollS5iri6I7MfG9GAXiMdNiXGGXy7Eoc+Obf1 sstg== X-Forwarded-Encrypted: i=1; AHgh+RqF7ZGWqxYpMy5LZtt/pceNcbW8GWkTOoNLpJQ2oJKnxpvTmjrbpe3s/VVG1Gf35eZZwY5+oAf3oX492zc=@vger.kernel.org X-Gm-Message-State: AOJu0Yytd8uSv4qAONQEdDt4nz4bGsZrx6pdC6Hin+RfNzNYXLUXaJov SXvey9U6QHovJXD6jrQtulkd1PRCVYLmZsXxjXvKMWhgJzhwE1jIzXdG X-Gm-Gg: AR+sD10/aExCt7yfKyvYDUktkGoOX718RtE//F4NbLu8YbIlNOV96AozmvInJJ734Fn WyTpBZYa4f8Qcw8rC8GLUW3xbPgsTmqstxu+t+nHykrmpJ9fTANHtWD/68f430M5X3W5qegkxwe V8E7fQkIezefzlXNDVpE1X5u5AfDasxbCB19BiCpY0te1XyHryLrNV4ZU1yi+Xhe4MLllMKQpdj BucyjL3gloqZ2Bvjr7NQFwYHXi8qOBL7VgT0epZimyrQ+7i55OdTxpFw0h4+Hghx3Tl/ZSXSN1w SPBOja8ixCNvU3QjWlbLK4lz11p2FTLO081IFOIXQdLm1Xkal6IuMGcS/ZiDh+g6CJVDmzewk6E PyiBiJ0MwwU4LF/S5XlWU8Jd15KwvAKq4wvsPIGvbRRW04hcxC5tZsSrHBIkFjG9RSzPzDa4veH A4ncFl4UPLAYgEWWGJ571bDwXnm7d2jfMxExpQEy9cQuK0tNA4kcopz41CjiWfvNVIphMaSCLKh BMKnVyMHnYB5hlF X-Received: by 2002:a17:907:809:b0:c12:4647:a629 with SMTP id a640c23a62f3a-c2039cb38acmr253565466b.25.1785928442552; Wed, 05 Aug 2026 04:14:02 -0700 (PDT) Received: from localhost (c-85-228-45-68.bbcust.telenor.se. [85.228.45.68]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c2053debd30sm4599466b.7.2026.08.05.04.14.01 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Aug 2026 04:14:01 -0700 (PDT) From: Eli Billauer To: gregkh@linuxfoundation.org Cc: arnd@arndb.de, linux-kernel@vger.kernel.org, corbet@lwn.net, Eli Billauer Subject: [PATCH v5 5/7] char: xillybus: Integer arithmetic improvements Date: Wed, 5 Aug 2026 13:13:35 +0200 Message-Id: <20260805111337.69178-6-eli.billauer@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20260805111337.69178-1-eli.billauer@gmail.com> References: <20260805111337.69178-1-eli.billauer@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Choose unsigned integers instead of signed where natural and required to ensure defined overflow behavoir. Simplify an arithmetic expression too. No functional change is expected, as the relevant variables normally never reach values where this transition matters. Assisted-by: Deepseek:v4-pro Kimi:K2.6 ChatGPT:GPT-5.5 Claude:Sonnet-4.6 Assisted-by: Sashiko-0.2.5:gemini-3.1-pro-preview Signed-off-by: Eli Billauer --- Notes: Changelog: ========= Changes v4->v5: -- Use unsigned literal ("1U") instead of signed to ensure defined behavior when left-shifted (in response to Sashiko's remark) No change on v3->v4. Changes v2->v3: -- Add Assisted-by tag to description No change on v1->v2. drivers/char/xillybus/xillybus_core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/char/xillybus/xillybus_core.c b/drivers/char/xillybus/xillybus_core.c index 7acebc1e6050..3ae95e6b17e9 100644 --- a/drivers/char/xillybus/xillybus_core.c +++ b/drivers/char/xillybus/xillybus_core.c @@ -343,7 +343,8 @@ static int xilly_map_single(struct xilly_endpoint *ep, static int xilly_get_dma_buffers(struct xilly_endpoint *ep, struct xilly_alloc_state *s, struct xilly_buffer **buffers, - int bufnum, int bytebufsize) + unsigned int bufnum, + unsigned int bytebufsize) { int i, rc; dma_addr_t dma_addr; @@ -431,8 +432,8 @@ static int xilly_setupchannels(struct xilly_endpoint *ep, struct device *dev = ep->dev; int i, entry, rc; struct xilly_channel *channel; - int channelnum, bufnum, bufsize, format, is_writebuf; - int bytebufsize; + unsigned int channelnum, bufnum, bufsize, format, is_writebuf; + unsigned int bytebufsize; int synchronous, allowpartial, exclusive_open, seekable; int supports_nonempty; int msg_buf_done = 0; @@ -512,7 +513,7 @@ static int xilly_setupchannels(struct xilly_endpoint *ep, format = (chandesc[1] >> 4) & 0x03; allowpartial = (chandesc[1] >> 6) & 0x01; synchronous = (chandesc[1] >> 7) & 0x01; - bufsize = 1 << (chandesc[2] & 0x1f); + bufsize = 1U << (chandesc[2] & 0x1f); bufnum = 1 << (chandesc[3] & 0x0f); exclusive_open = (chandesc[2] >> 7) & 0x01; seekable = (chandesc[2] >> 6) & 0x01; @@ -531,8 +532,7 @@ static int xilly_setupchannels(struct xilly_endpoint *ep, channel->log2_element_size = ((format > 2) ? 2 : format); - bytebufsize = bufsize * - (1 << channel->log2_element_size); + bytebufsize = bufsize << channel->log2_element_size; buffers = devm_kcalloc(dev, bufnum, sizeof(struct xilly_buffer *), @@ -589,7 +589,7 @@ static int xilly_setupchannels(struct xilly_endpoint *ep, static int xilly_scan_idt(struct xilly_endpoint *endpoint, struct xilly_idt_handle *idt_handle) { - int count = 0; + unsigned int count = 0; unsigned char *idt = endpoint->channels[1]->wr_buffers[0]->addr; unsigned char *end_of_idt = idt + endpoint->idtlen - 4; unsigned char *scan; -- 2.34.1