linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] m68k: string: Make char intermediate in strcmp() signed
@ 2022-12-15 13:30 Geert Uytterhoeven
  2022-12-15 18:43 ` Jason A. Donenfeld
  0 siblings, 1 reply; 2+ messages in thread
From: Geert Uytterhoeven @ 2022-12-15 13:30 UTC (permalink / raw)
  To: Jason A . Donenfeld
  Cc: linux-m68k, linux-arch, linux-kernel, Geert Uytterhoeven

Since char became unsigned, strcmp() always returns a positive number.

"res" is used to store a byte difference, so it should be signed.

Fixes: 3bc753c06dd02a35 ("kbuild: treat char as always unsigned")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
See "Re: [PATCH v9] kallsyms: Add self-test facility"
https://lore.kernel.org/r/CAMuHMdWM6+pC3yUqy+hHRrAf1BCz2sz1KQv2zxS+Wz-639X-aA@mail.gmail.com

I'm wondering how many surprises like this are still hidden...
---
 arch/m68k/include/asm/string.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/string.h b/arch/m68k/include/asm/string.h
index f759d944c4499404..b8f4ae19e8f6ee2c 100644
--- a/arch/m68k/include/asm/string.h
+++ b/arch/m68k/include/asm/string.h
@@ -42,7 +42,7 @@ static inline char *strncpy(char *dest, const char *src, size_t n)
 #define __HAVE_ARCH_STRCMP
 static inline int strcmp(const char *cs, const char *ct)
 {
-	char res;
+	signed char res;
 
 	asm ("\n"
 		"1:	move.b	(%0)+,%2\n"	/* get *cs */
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] m68k: string: Make char intermediate in strcmp() signed
  2022-12-15 13:30 [PATCH] m68k: string: Make char intermediate in strcmp() signed Geert Uytterhoeven
@ 2022-12-15 18:43 ` Jason A. Donenfeld
  0 siblings, 0 replies; 2+ messages in thread
From: Jason A. Donenfeld @ 2022-12-15 18:43 UTC (permalink / raw)
  To: Geert Uytterhoeven; +Cc: linux-m68k, linux-arch, linux-kernel

On Thu, Dec 15, 2022 at 02:30:04PM +0100, Geert Uytterhoeven wrote:
> Since char became unsigned, strcmp() always returns a positive number.
> 
> "res" is used to store a byte difference, so it should be signed.
> 
> Fixes: 3bc753c06dd02a35 ("kbuild: treat char as always unsigned")
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> See "Re: [PATCH v9] kallsyms: Add self-test facility"
> https://lore.kernel.org/r/CAMuHMdWM6+pC3yUqy+hHRrAf1BCz2sz1KQv2zxS+Wz-639X-aA@mail.gmail.com
> 
> I'm wondering how many surprises like this are still hidden...

OOOOOOOOOOFFFFF! Not sure how I missed this one. Perhaps the ASM alluded
the coccinelle scripts. Anyway, thanks for catching it, sorry for the
bug, and here's my:

Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>

I assume you'll send this out for the next tranche of m68k fixes.

Jason

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-15 18:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-15 13:30 [PATCH] m68k: string: Make char intermediate in strcmp() signed Geert Uytterhoeven
2022-12-15 18:43 ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).