Subject: Re: [ANNOUNCE] git-2.30.0-rc0 - Compile Fails on HPE NonStop

From: Junio C Hamano <[email-masked]>
Date: Mon, 14 Dec 2020 18:43:36 -0800

"Randall S. Becker" <[email-masked]> writes:

> 2.30.0-rc0 fails to compile strmap.o, and probably others, since this is in
> a header file:
>
> "git-compat-util.h", line 277: warning(1252):
>           missing return statement at end of non-void function "setitimer"

Thanks for reporting.  I guess nobody without setitimer bothered to
test, since 15b52a44 (compat-util: type-check parameters of no-op
replacement functions, 2020-08-06) which was a tad before 2.29 was
tagged.

diff --git c/git-compat-util.h w/git-compat-util.h
index 7d509c5022..58cd0761be 100644
--- c/git-compat-util.h
+++ w/git-compat-util.h
@@ -273,7 +273,8 @@ struct itimerval {
 
 #ifdef NO_SETITIMER
 static inline int setitimer(int which, const struct itimerval *value, struct itimerval *newvalue) {
-	; /* nothing */
+	errno = ENOSYS;
+	return -1; /* not implemented */
 }
 #endif
 
Alternatively we could pretend that the call always succeeds by
without touching errno and returning 0.  That might be safer, but I
dunno which one we want, and I do not have a system affected by the
choice.

>   	return strmap_remove(&map->map, str, 0);
>   	       ^
> "strmap.h", line 168: error(210):
>           a void function may not return a value
>
>   	return strmap_remove(&set->map, str, 0);
>   	       ^
> "strmap.h", line 252: error(210):
>           a void function may not return a value

This is a GNU extension biting us, perhaps?

Apparently these came from 4fa1d501 (strmap: add functions
facilitating use as a string->int map, 2020-11-05).

> Aside from inlining bodies, this should not have compiled on any platform:
>
> static inline void strset_remove(struct strset *set, const char *str)
> {
>         return strmap_remove(&set->map, str, 0);
> }
>
> What is really intended here?

I think we should just drop "return"; a void function should be
called in void context without requiring a value, even if that
return expects no value.

diff --git i/strmap.h w/strmap.h
index c4c104411b..1e152d832d 100644
--- i/strmap.h
+++ w/strmap.h
@@ -165,7 +165,7 @@ static inline int strintmap_contains(struct strintmap *map, const char *str)
 
 static inline void strintmap_remove(struct strintmap *map, const char *str)
 {
-	return strmap_remove(&map->map, str, 0);
+	strmap_remove(&map->map, str, 0);
 }
 
 static inline int strintmap_empty(struct strintmap *map)
@@ -249,7 +249,7 @@ static inline int strset_contains(struct strset *set, const char *str)
 
 static inline void strset_remove(struct strset *set, const char *str)
 {
-	return strmap_remove(&set->map, str, 0);
+	strmap_remove(&set->map, str, 0);
 }
 
 static inline int strset_empty(struct strset *set)

> Sorry,
> Randall

Thanks.