]> granicus.if.org Git - json-c/commitdiff
Fix #771/#768 by marking usage() as "noreturn" instead of using "FALLTHRU" in the...
authorEric Haszlakiewicz <erh+git@nimenees.com>
Mon, 13 Jun 2022 01:02:53 +0000 (01:02 +0000)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Mon, 13 Jun 2022 01:02:53 +0000 (01:02 +0000)
apps/json_parse.c

index 86eb20005fc3bfe601caa6f4c0e2973bf27e3cf9..b26ce9b3dad1936151f6d29b7846e2f198123462 100644 (file)
 #include <sys/time.h>
 #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");
                }
        }