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

[PATCH v2 1/1] add: use unsigned type for collection of bits

From
Eugenio Gigante <giganteeugenio2@gmail.com>
Date
Feb 29, 2024, 19:44 UTC
Message-ID
<20240229194444.8499-2-giganteeugenio2@gmail.com>
In-Reply-To
<20240229194444.8499-1-giganteeugenio2@gmail.com>

The 'refresh' function in 'builtin/add.c' declares 'flags' as signed, and passes it as an argument to the 'refresh_index' function, which though expects an unsigned value.

Since in this case 'flags' represents a bag of bits, whose MSB is not used in special ways, change the type of 'flags' to unsigned.

Signed-off-by: Eugenio Gigante <giganteeugenio2@gmail.com>
---
 builtin/add.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/add.c b/builtin/add.c
index ada7719561..393c10cbcf 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -115,7 +115,7 @@ static int refresh(int verbose, const struct pathspec *pathspec)
 	int i, ret = 0;
 	char *skip_worktree_seen = NULL;
 	struct string_list only_match_skip_worktree = STRING_LIST_INIT_NODUP;
-	int flags = REFRESH_IGNORE_SKIP_WORKTREE |
+	unsigned int flags = REFRESH_IGNORE_SKIP_WORKTREE |
 		    (verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET);
 
 	seen = xcalloc(pathspec->nr, 1);
-- 
2.43.0
Previous: Eugenio GiganteNext: Junio C Hamano
Message 6 of 7 in “Use unsigned integral type for collection of bits.”
  1. Eugenio GiganteFeb 24, 2024
  2. [GSoC][PATCH 1/1] add: use unsigned type for collection of bitsEugenio Gigante, Feb 24, 2024
  3. Christian CouderFeb 26, 2024
  4. Junio C HamanoFeb 26, 2024
  5. [GSoC][PATCH v2 0/1] Use unsigned integral type for collection of bits.Eugenio Gigante, Feb 29, 2024
  6. 1/1 add: use unsigned type for collection of bitsEugenio Gigante, Feb 29, 2024
  7. Junio C HamanoFeb 29, 2024

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.