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

[PATCH] make sure enum object_type is signed

From
Nicolas Pitre <nico@cam.org>
Date
Feb 28, 2007, 01:38 UTC
Message-ID
<alpine.LRH.0.82.0702272028100.29426@xanadu.home>

This allows for keeping the common idiom which consists of using negative values to signal error conditions by ensuring that the enum will be a signed type.

Signed-off-by: Nicolas Pitre <nico@cam.org>
---
Per early discussion.
diff --git a/cache.h b/cache.h
index 0117b7e..ec72c0c 100644
--- a/cache.h
+++ b/cache.h
@@ -263,6 +263,7 @@ int safe_create_leading_directories(char *path);
 char *enter_repo(char *path, int strict);
 
 enum object_type {
+	OBJ_BAD = -1,
 	OBJ_NONE = 0,
 	OBJ_COMMIT = 1,
 	OBJ_TREE = 2,
@@ -271,7 +272,7 @@ enum object_type {
 	/* 5 for future expansion */
 	OBJ_OFS_DELTA = 6,
 	OBJ_REF_DELTA = 7,
-	OBJ_BAD,
+	OBJ_MAX,
 };
 
 /* Read and unpack a sha1 file into memory, write memory to a sha1 file */
Message 1 of 1 in “make sure enum object_type is signed”
  1. make sure enum object_type is signedNicolas Pitre, Feb 28, 2007

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.