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

[PATCH] read_cache: cast types from stat to ce_cache

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jun 10, 2010, 09:15 UTC
Message-ID
<a06cc84698f174d914350d6fd6e6b4739d22aa45.1276161176.git.git@drmicha.warpmail.net>

Cast the system dependent entries of struct stat to unsigned integers for struct ce_cache just like in other places where we do this already, to protect against any type conversion issues.

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
This does not fix the "filesystem boundary issue" I reported, but I spotted
this when digging through read-cache.c. My device ids would have issues
when int = short.
 read-cache.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/read-cache.c b/read-cache.c
index e381ea5..aa9b847 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -72,11 +72,11 @@ void fill_stat_cache_info(struct cache_entry *ce, struct stat *st)
 	ce->ce_mtime.sec = (unsigned int)st->st_mtime;
 	ce->ce_ctime.nsec = ST_CTIME_NSEC(*st);
 	ce->ce_mtime.nsec = ST_MTIME_NSEC(*st);
-	ce->ce_dev = st->st_dev;
-	ce->ce_ino = st->st_ino;
-	ce->ce_uid = st->st_uid;
-	ce->ce_gid = st->st_gid;
-	ce->ce_size = st->st_size;
+	ce->ce_dev = (unsigned int)st->st_dev;
+	ce->ce_ino = (unsigned int)st->st_ino;
+	ce->ce_uid = (unsigned int)st->st_uid;
+	ce->ce_gid = (unsigned int)st->st_gid;
+	ce->ce_size = (unsigned int)st->st_size;
 
 	if (assume_unchanged)
 		ce->ce_flags |= CE_VALID;
-- 
1.7.1.501.g23b46
Next: Junio C Hamano
Message 1 of 5 in “read_cache: cast types from stat to ce_cache”
  1. read_cache: cast types from stat to ce_cacheMichael J Gruber, Jun 10, 2010
  2. Junio C HamanoJun 10, 2010
  3. Michael J GruberJun 11, 2010
  4. Erik Faye-LundJun 11, 2010
  5. Michael J GruberJun 11, 2010

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.