Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit a4f3131

Browse files
kusmapeff
authored andcommitted
increase portability of NORETURN declarations
Some compilers (including at least MSVC) support NORETURN on function declarations, but only before the function-name. This patch makes it possible to define NORETURN to something meaningful for those compilers. Signed-off-by: Erik Faye-Lund <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 1be224b commit a4f3131

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

git-compat-util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ extern char *gitbasename(char *);
186186
#include "compat/bswap.h"
187187

188188
/* General helper functions */
189-
extern void usage(const char *err) NORETURN;
190-
extern void die(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
191-
extern void die_errno(const char *err, ...) NORETURN __attribute__((format (printf, 1, 2)));
189+
extern NORETURN void usage(const char *err);
190+
extern NORETURN void die(const char *err, ...) __attribute__((format (printf, 1, 2)));
191+
extern NORETURN void die_errno(const char *err, ...) __attribute__((format (printf, 1, 2)));
192192
extern int error(const char *err, ...) __attribute__((format (printf, 1, 2)));
193193
extern void warning(const char *err, ...) __attribute__((format (printf, 1, 2)));
194194

195-
extern void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN);
195+
extern void set_die_routine(NORETURN void (*routine)(const char *err, va_list params));
196196

197197
extern int prefixcmp(const char *str, const char *prefix);
198198
extern time_t tm_to_time_t(const struct tm *tm);

index-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ static void parse_pack_header(void)
206206
use(sizeof(struct pack_header));
207207
}
208208

209-
static void bad_object(unsigned long offset, const char *format,
210-
...) NORETURN __attribute__((format (printf, 2, 3)));
209+
static NORETURN void bad_object(unsigned long offset, const char *format,
210+
...) __attribute__((format (printf, 2, 3)));
211211

212212
static void bad_object(unsigned long offset, const char *format, ...)
213213
{

usage.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ static void warn_builtin(const char *warn, va_list params)
3636

3737
/* If we are in a dlopen()ed .so write to a global variable would segfault
3838
* (ugh), so keep things static. */
39-
static void (*usage_routine)(const char *err) NORETURN = usage_builtin;
40-
static void (*die_routine)(const char *err, va_list params) NORETURN = die_builtin;
39+
static NORETURN void (*usage_routine)(const char *err) = usage_builtin;
40+
static NORETURN void (*die_routine)(const char *err, va_list params) = die_builtin;
4141
static void (*error_routine)(const char *err, va_list params) = error_builtin;
4242
static void (*warn_routine)(const char *err, va_list params) = warn_builtin;
4343

44-
void set_die_routine(void (*routine)(const char *err, va_list params) NORETURN)
44+
void set_die_routine(NORETURN void (*routine)(const char *err, va_list params))
4545
{
4646
die_routine = routine;
4747
}

0 commit comments

Comments
 (0)