From: Eric Haszlakiewicz Date: Mon, 13 Jun 2022 01:02:53 +0000 (+0000) Subject: Fix #771/#768 by marking usage() as "noreturn" instead of using "FALLTHRU" in the... X-Git-Tag: json-c-0.17-20230812~46 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=6ee0a35a20ce986e60cad88dce1f3f19a2a23d5e;p=thirdparty%2Fjson-c.git Fix #771/#768 by marking usage() as "noreturn" instead of using "FALLTHRU" in the case statement where it'd called. --- diff --git a/apps/json_parse.c b/apps/json_parse.c index 86eb2000..b26ce9b3 100644 --- a/apps/json_parse.c +++ b/apps/json_parse.c @@ -22,6 +22,19 @@ #include #endif +#ifndef JSON_NORETURN +#if defined(_MSC_VER) +#define JSON_NORETURN __declspec(noreturn) +#elif defined(__OS400__) +#define JSON_NORETURN +#else +/* 'cold' attribute is for optimization, telling the computer this code + * path is unlikely. + */ +#define JSON_NORETURN __attribute__((noreturn, cold)) +#endif +#endif + static int formatted_output = 0; static int show_output = 1; static int strict_mode = 0; @@ -31,7 +44,7 @@ static const char *fname = NULL; #define json_tokener_get_parse_end(tok) ((tok)->char_offset) #endif -static void usage(const char *argv0, int exitval, const char *errmsg); +JSON_NORETURN static void usage(const char *argv0, int exitval, const char *errmsg); static void showmem(void); static int parseit(int fd, int (*callback)(struct json_object *)); static int showobj(struct json_object *new_obj); @@ -167,7 +180,7 @@ int main(int argc, char **argv) case 'f': formatted_output = 1; break; case 'n': show_output = 0; break; case 's': strict_mode = 1; break; - case 'h': usage(argv[0], 0, NULL); /* FALLTHRU */ + case 'h': usage(argv[0], 0, NULL); default: /* '?' */ usage(argv[0], EXIT_FAILURE, "Unknown arguments"); } }