From patchwork Wed Jan 12 07:48:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jukka Laitinen X-Patchwork-Id: 1578892 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=AxFjTdzY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=ZKoBgfX9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JYfpN15WMz9sSs for ; Wed, 12 Jan 2022 18:49:13 +1100 (AEDT) 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:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0xslXz0avDKrmbJnaZN/e8gjA8EYQ5xaqmmrQkpdNog=; b=AxFjTdzYkLdl+I lguMuw6z06K9oKQvRiPmTqifr1/LYMPJhU8UC6zryNA8rej3kpVli6XVNW7O2t8vbbzNkw0DbEUq6 vhUyG0w/rMKX/8AUniFP6ZQyjjkHI4oF1KPDOEWyBFzFUYn9AhQ911B8dIPzFY5f9PIH96bQzvJRt dZcNtw4FLLVtD3G8BQYD9ozP/cZqvS52CPolAFjP1nimht0bxneNK3GvpDpCohfqZ1ycC0bzhNcOg DBF8N2dmwUdi9k2AXaudfVjwwDe16u0iZY2nwxoxyCUkyuQcJ99pfuq65rZ+RTyDCAJCr0Pz3No4z w4A9xzKUzVWa3+VohBaA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7YNT-001QPV-Dv; Wed, 12 Jan 2022 07:49:03 +0000 Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n7YNQ-001QNZ-Ed for opensbi@lists.infradead.org; Wed, 12 Jan 2022 07:49:02 +0000 Received: by mail-lf1-x130.google.com with SMTP id m1so5158596lfq.4 for ; Tue, 11 Jan 2022 23:48:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K9VvquIoPWanQ1iUniNdBRAYu1M/viRC3/ssXqcdafQ=; b=ZKoBgfX91MPidIlSU3oNexJGVC/wZadEJe7hV7+tUXBKLRtXaM0281oIsrhh8YZ+9E Jr/zl/taiJbV34NPFjectBrRNhCA4fFNe/z50CVZITIzfAr4xKsf5DhsEayjJxP3+MTO Pfk+/OgBc3z3v4mAHDEG67ouvgnxMeQvJ12bI/vNX0R+7OKILgm0gaUppSrgPM3/lUbK ZEmE5jEvhAVgFIXxdXK3IpOiJVi+JyJLXSRx99NC6/jA03QdNMaweVAvLHguCPfUQkCI Q2fYkgPbZSM6u1B20akhzbpEuVg0lojoWor4qezrZpQCdnKbaV+mnPFGXFXuI7OX6zSM aVMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=K9VvquIoPWanQ1iUniNdBRAYu1M/viRC3/ssXqcdafQ=; b=JLVgmAI/DEluSO8sczD9A4UyJj0+pgI9ioyecpRpcYYjBVcrIbb+1bm+pEbgFNvJ3i He0kQjtjxN8LMl67glbQXW5yDPO9Xpv6++tAPvWfFS01OU8SBSVCN+f5UKNa8NT6n0FR Et1ufcrZrfPej+azLIpuju6JqSuwFbkTBWmBI6fc0euJ4h9on2WMEMkKYgCZ3p3qjUKd wjO2d5Js50ghVC0Ma9wyyKicbMDUNd2EsOpInsTkIAeXxF2xw2cAaqmfnyuG2tx0KalF Wat1X7skMw+aMGcI6zdTUjStfyKI9H0gqtBKC2zT96clqoRPZa55QlDCyIUOSyD0vObi +/JA== X-Gm-Message-State: AOAM533WZJd/z2xvQIf43MxGvrjzb5+4NOeN2438MtS0PcjkBuQWomBM DOA1+L18DCdYRmcAJLeKUSNbTVzegcg= X-Google-Smtp-Source: ABdhPJxwtKxM1+o5it5TQiXUvGBnE/EuXuAICrtJoJ3JkM69QBZ+Q12zpElf7r+w6oVa5rxdoDPJCw== X-Received: by 2002:a2e:3006:: with SMTP id w6mr4462542ljw.205.1641973736553; Tue, 11 Jan 2022 23:48:56 -0800 (PST) Received: from localhost.localdomain (dy5m7x-bzrgdmdsf1yybt-4.rev.dnainternet.fi. [2001:14bb:655:b9fc:3471:46a1:bc95:3]) by smtp.gmail.com with ESMTPSA id g11sm1559165lfu.169.2022.01.11.23.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jan 2022 23:48:56 -0800 (PST) From: Jukka Laitinen X-Google-Original-From: Jukka Laitinen To: opensbi@lists.infradead.org Cc: Jukka Laitinen Subject: [PATCH] Fix pointer of type 'void *' used in arithmetic Date: Wed, 12 Jan 2022 09:48:46 +0200 Message-Id: <20220112074846.136171-1-jukkax@ssrc.tii.ae> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220111_234900_521249_44E8ADB2 X-CRM114-Status: GOOD ( 14.27 ) X-Spam-Score: 0.6 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Using "void *" in arithmetic causes errors with strict compiler settings: "error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]" Just remove these by calculating on "char *" where 1-byte data size is assumed --- include/sbi/sbi_scratch.h | 4 ++-- lib/sbi/sbi_fifo.c | 6 +++--- lib/sbi/sbi_string.c | 4 ++-- lib/utils/irqchip/plic [...] Content analysis details: (0.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:130 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [jlaitin0[at]gmail.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [jlaitin0[at]gmail.com] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.2 FREEMAIL_FORGED_FROMDOMAIN 2nd level domains in From and EnvelopeFrom freemail headers are different X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Using "void *" in arithmetic causes errors with strict compiler settings: "error: pointer of type 'void *' used in arithmetic [-Werror=pointer-arith]" Just remove these by calculating on "char *" where 1-byte data size is assumed --- include/sbi/sbi_scratch.h | 4 ++-- lib/sbi/sbi_fifo.c | 6 +++--- lib/sbi/sbi_string.c | 4 ++-- lib/utils/irqchip/plic.c | 8 ++++---- lib/utils/timer/aclint_mtimer.c | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/sbi/sbi_scratch.h b/include/sbi/sbi_scratch.h index 186a40c..0c27307 100644 --- a/include/sbi/sbi_scratch.h +++ b/include/sbi/sbi_scratch.h @@ -104,11 +104,11 @@ unsigned long sbi_scratch_alloc_offset(unsigned long size); void sbi_scratch_free_offset(unsigned long offset); /** Get pointer from offset in sbi_scratch */ -#define sbi_scratch_offset_ptr(scratch, offset) ((void *)scratch + (offset)) +#define sbi_scratch_offset_ptr(scratch, offset) (void *)((char *)(scratch) + (offset)) /** Get pointer from offset in sbi_scratch for current HART */ #define sbi_scratch_thishart_offset_ptr(offset) \ - ((void *)sbi_scratch_thishart_ptr() + (offset)) + (void *)((char *)sbi_scratch_thishart_ptr() + (offset)) /** HART id to scratch table */ extern struct sbi_scratch *hartid_to_scratch_table[]; diff --git a/lib/sbi/sbi_fifo.c b/lib/sbi/sbi_fifo.c index 589cc18..68d6039 100644 --- a/lib/sbi/sbi_fifo.c +++ b/lib/sbi/sbi_fifo.c @@ -66,7 +66,7 @@ static inline void __sbi_fifo_enqueue(struct sbi_fifo *fifo, void *data) if (head >= fifo->num_entries) head = head - fifo->num_entries; - sbi_memcpy(fifo->queue + head * fifo->entry_size, data, fifo->entry_size); + sbi_memcpy((char *)fifo->queue + head * fifo->entry_size, data, fifo->entry_size); fifo->avail++; } @@ -142,7 +142,7 @@ int sbi_fifo_inplace_update(struct sbi_fifo *fifo, void *in, index = fifo->tail + i; if (index >= fifo->num_entries) index -= fifo->num_entries; - entry = (void *)fifo->queue + (u32)index * fifo->entry_size; + entry = (char *)fifo->queue + (u32)index * fifo->entry_size; ret = fptr(in, entry); if (ret == SBI_FIFO_SKIP || ret == SBI_FIFO_UPDATED) { @@ -184,7 +184,7 @@ int sbi_fifo_dequeue(struct sbi_fifo *fifo, void *data) return SBI_ENOENT; } - sbi_memcpy(data, fifo->queue + (u32)fifo->tail * fifo->entry_size, + sbi_memcpy(data, (char *)fifo->queue + (u32)fifo->tail * fifo->entry_size, fifo->entry_size); fifo->avail--; diff --git a/lib/sbi/sbi_string.c b/lib/sbi/sbi_string.c index c87bce9..c163f31 100644 --- a/lib/sbi/sbi_string.c +++ b/lib/sbi/sbi_string.c @@ -149,8 +149,8 @@ void *sbi_memmove(void *dest, const void *src, size_t count) count--; } } else { - temp1 = dest + count - 1; - temp2 = src + count - 1; + temp1 = (char *)dest + count - 1; + temp2 = (char *)src + count - 1; while (count > 0) { *temp1-- = *temp2--; diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c index 7665c62..0f58f3e 100644 --- a/lib/utils/irqchip/plic.c +++ b/lib/utils/irqchip/plic.c @@ -23,7 +23,7 @@ static void plic_set_priority(struct plic_data *plic, u32 source, u32 val) { - volatile void *plic_priority = (void *)plic->addr + + volatile void *plic_priority = (char *)plic->addr + PLIC_PRIORITY_BASE + 4 * source; writel(val, plic_priority); } @@ -35,19 +35,19 @@ void plic_set_thresh(struct plic_data *plic, u32 cntxid, u32 val) if (!plic) return; - plic_thresh = (void *)plic->addr + + plic_thresh = (char *)plic->addr + PLIC_CONTEXT_BASE + PLIC_CONTEXT_STRIDE * cntxid; writel(val, plic_thresh); } void plic_set_ie(struct plic_data *plic, u32 cntxid, u32 word_index, u32 val) { - volatile void *plic_ie; + volatile char *plic_ie; if (!plic) return; - plic_ie = (void *)plic->addr + + plic_ie = (char *)plic->addr + PLIC_ENABLE_BASE + PLIC_ENABLE_STRIDE * cntxid; writel(val, plic_ie + word_index * 4); } diff --git a/lib/utils/timer/aclint_mtimer.c b/lib/utils/timer/aclint_mtimer.c index 62e87f7..2532b63 100644 --- a/lib/utils/timer/aclint_mtimer.c +++ b/lib/utils/timer/aclint_mtimer.c @@ -47,7 +47,7 @@ static u64 mtimer_time_rd32(volatile u64 *addr) static void mtimer_time_wr32(bool timecmp, u64 value, volatile u64 *addr) { writel_relaxed((timecmp) ? -1U : 0U, (void *)(addr)); - writel_relaxed((u32)(value >> 32), (void *)(addr) + 0x04); + writel_relaxed((u32)(value >> 32), (char *)(addr) + 0x04); writel_relaxed((u32)value, (void *)(addr)); }