threads / patch / 37290

patchcache.h: add missing NORETURN on git_die_config*()

Subject: [PATCH] cache.h: add missing NORETURN on git_die_config*()

## tl;dr

2 messages between Aug 5, 2014 and Aug 5, 2014. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Ramsay Jones· Aug 5, 2014, 13:57 UTC · lore

Commit 3a2a9527 ("config: add `git_die_config()` to the config-set API", 01-08-2014) added git_die_config() and git_die_config_linenr() functions, but forgot to include the NORETURN attribute in their declarations. Sparse complains like so:

        SP config.c
    config.c:1567:6: error: symbol 'git_die_config_linenr' redeclared \
        with different type (originally declared at cache.h:1419) \
        - different modifiers
    config.c:1579:6: error: symbol 'git_die_config' redeclared with \
        different type (originally declared at cache.h:1418) \
        - different modifiers

Suppress the sparse errors by adding NORETURN to the function declarations in the cache.h header file.

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
Hi Tanay,

If you need to re-roll the patches in the 'ta/config-set-1' branch, could you please squash this into the relevant patch. Thanks!

At present there are no callers outside of config.c (but that will change right!;-), but since three of the four call sights for these functions appear _before_ the definitions, only a single call could possibly benefit from the NORETURN (line 1585).

HTH

ATB, Ramsay Jones

 cache.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to cache.h +2 −2
diff --git a/cache.h b/cache.h
index 9faea51..d82a5c3 100644
--- a/cache.h
+++ b/cache.h
@@ -1415,8 +1415,8 @@ extern int git_config_get_bool(const char *key, int *dest);
 extern int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest);
 extern int git_config_get_maybe_bool(const char *key, int *dest);
 extern int git_config_get_pathname(const char *key, const char **dest);
-extern void git_die_config(const char *key);
-extern void git_die_config_linenr(const char *key, const char *filename, int linenr);
+extern NORETURN void git_die_config(const char *key);
+extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr);
 
 extern int committer_ident_sufficiently_given(void);
 extern int author_ident_sufficiently_given(void);
-- 
2.0.0
Tanay Abhra· Aug 5, 2014, 14:09 UTC · re: Ramsay Jones · lore

Re: [PATCH] cache.h: add missing NORETURN on git_die_config*()

On 8/5/2014 7:27 PM, Ramsay Jones wrote:
Show 25 quoted lines
> 
> Commit 3a2a9527 ("config: add `git_die_config()` to the config-set
> API", 01-08-2014) added git_die_config() and git_die_config_linenr()
> functions, but forgot to include the NORETURN attribute in their
> declarations. Sparse complains like so:
> 
>         SP config.c
>     config.c:1567:6: error: symbol 'git_die_config_linenr' redeclared \
>         with different type (originally declared at cache.h:1419) \
>         - different modifiers
>     config.c:1579:6: error: symbol 'git_die_config' redeclared with \
>         different type (originally declared at cache.h:1418) \
>         - different modifiers
> 
> Suppress the sparse errors by adding NORETURN to the function
> declarations in the cache.h header file.
> 
> Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
> ---
> 
> Hi Tanay,
> 
> If you need to re-roll the patches in the 'ta/config-set-1' branch,
> could you please squash this into the relevant patch. Thanks!
>
Sorry, my bad. I will squash it in the relevant patch for my next re roll.

Thanks, Tanay Abhra.

← back to recent threads