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

[PATCH] compat-util: pretend that stub setitimer() always succeeds

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 15, 2020, 21:26 UTC
Message-ID
<xmqqpn3a7ocm.fsf_-_@gitster.c.googlers.com>
In-Reply-To
<xmqqzh2e7p6l.fsf@gitster.c.googlers.com>

When 15b52a44 (compat-util: type-check parameters of no-op replacement functions, 2020-08-06) turned a handful of no-op C-preprocessor macros into static inline functions to give the callers a better type checking for their parameters, it forgot to return anything from the stubbed out setitimer() function, even though the function was defined to return an int just like the real thing.

Since the original C-preprocessor macro implementation was to just turn the call to the function an empty statement, we know that the existing callers do not check the return value from it, and it does not matter what value we return. But it is safer to pretend that the call succeeded by returning 0 than making it fail by returning -1 and clobbering errno with some value.

Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-compat-util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git-compat-util.h b/git-compat-util.h
index 7a0fb7a045..421c90b5d8 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -273,7 +273,7 @@ struct itimerval {
 
 #ifdef NO_SETITIMER
 static inline int setitimer(int which, const struct itimerval *value, struct itimerval *newvalue) {
-	; /* nothing */
+	return 0; /* pretend success */
 }
 #endif
 
-- 
2.30.0-rc0-186-g20447144ec
Previous: Randall S. BeckerNext: Jeff King
Message 10 of 12 in “Re: [ANNOUNCE] git-2.30.0-rc0 - Compile Fails on HPE NonStop”
  1. Randall S. BeckerDec 14, 2020
  2. Junio C HamanoDec 15, 2020
  3. Jeff KingDec 15, 2020
  4. Randall S. BeckerDec 15, 2020
  5. Elijah NewrenDec 15, 2020
  6. Junio C HamanoDec 15, 2020
  7. Junio C HamanoDec 15, 2020
  8. strmap: make callers of strmap_remove() to call it in void contextJunio C Hamano, Dec 15, 2020
  9. Randall S. BeckerDec 15, 2020
  10. compat-util: pretend that stub setitimer() always succeedsJunio C Hamano, Dec 15, 2020
  11. Jeff KingDec 15, 2020
  12. Junio C HamanoDec 16, 2020

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.