From: "J. Neuschäfer via B4 Relay" <devnull+j.ne.posteo.net@kernel.org>
To: Caleb Connolly <caleb.connolly@linaro.org>,
Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de, "J. Neuschäfer" <j.ne@posteo.net>
Subject: [PATCH 1/3] cmd: ufetch: Fix type mismatch on 32-bit
Date: Thu, 05 Dec 2024 19:35:33 +0100 [thread overview]
Message-ID: <20241205-ufetch-v1-1-df861318bd49@posteo.net> (raw)
In-Reply-To: <20241205-ufetch-v1-0-df861318bd49@posteo.net>
From: "J. Neuschäfer" <j.ne@posteo.net>
On 32-bit architectures, LAST_LINE (_LAST_LINE - 1UL) is 64 bits long,
but size_t (from ARRAY_SIZE(...)) is 32 bits. This results in a warning
because the max() macro expects the same type on both sides:
cmd/ufetch.c: In function ‘do_ufetch’:
include/linux/kernel.h:179:24: warning: comparison of distinct pointer types lacks a cast [-Wcompare-distinct-pointer-types]
179 | (void) (&_max1 == &_max2); \
| ^~
cmd/ufetch.c:92:25: note: in expansion of macro ‘max’
92 | int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines));
| ^~~
Fix this by casting LAST_LINE to size_t.
Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
---
cmd/ufetch.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/ufetch.c b/cmd/ufetch.c
index 0b825d7e8c75f3b18933d3e3f77e5f40f2c7b658..5f3ef847b268dc384271fc6774720e5fd2337157 100644
--- a/cmd/ufetch.c
+++ b/cmd/ufetch.c
@@ -89,7 +89,7 @@ enum output_lines {
static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- int num_lines = max(LAST_LINE + 1, ARRAY_SIZE(logo_lines));
+ int num_lines = max((size_t)LAST_LINE + 1, ARRAY_SIZE(logo_lines));
const char *model, *compatible;
char *ipaddr;
int n_cmds, n_cpus = 0, ret, compatlen;
--
2.45.2
next prev parent reply other threads:[~2024-12-05 23:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-05 18:35 [PATCH 0/3] cmd: ufetch improvements J. Neuschäfer via B4 Relay
2024-12-05 18:35 ` J. Neuschäfer via B4 Relay [this message]
2024-12-09 14:58 ` [PATCH 1/3] cmd: ufetch: Fix type mismatch on 32-bit Caleb Connolly
2024-12-05 18:35 ` [PATCH 2/3] cmd: Allow building ufetch without CONFIG_BLK J. Neuschäfer via B4 Relay
2024-12-09 15:04 ` Caleb Connolly
2024-12-09 16:51 ` J. Neuschäfer
2024-12-09 16:55 ` Caleb Connolly
2024-12-05 18:35 ` [PATCH 3/3] cmd: ufetch: Show CPU architecture under "CPU" J. Neuschäfer via B4 Relay
2024-12-09 15:09 ` Caleb Connolly
2024-12-09 16:58 ` J. Neuschäfer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241205-ufetch-v1-1-df861318bd49@posteo.net \
--to=devnull+j.ne.posteo.net@kernel.org \
--cc=caleb.connolly@linaro.org \
--cc=j.ne@posteo.net \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox