git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1 1/2] path.c: char is not (always) signed

From
tboegi@web.de <tboegi@web.de>
Date
Oct 25, 2018, 16:13 UTC
Message-ID
<20181025161308.29207-1-tboegi@web.de>
From: Torsten Bögershausen <tboegi@web.de>

If a "char" in C is signed or unsigned is not specified, because it is out of tradition "implementation dependent". Therefore constructs like "if (name[i] < 0)" are not portable, use "if (name[i] & 0x80)" instead.

Detected by "gcc (Raspbian 6.3.0-18+rpi1+deb9u1) 6.3.0 20170516" when setting DEVELOPER = 1 DEVOPTS = extra-all

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
---
 path.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/path.c b/path.c
index 34f0f98349..ba06ec5b2d 100644
--- a/path.c
+++ b/path.c
@@ -1369,7 +1369,7 @@ static int is_ntfs_dot_generic(const char *name,
 			saw_tilde = 1;
 		} else if (i >= 6)
 			return 0;
-		else if (name[i] < 0) {
+		else if (name[i] & 0x80) {
 			/*
 			 * We know our needles contain only ASCII, so we clamp
 			 * here to make the results of tolower() sane.
-- 
2.11.0
Message 1 of 1 in “path.c: char is not (always) signed”
  1. 1/2 path.c: char is not (always) signedtboegi@web.de, Oct 25, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.