summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-24 03:04:25 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-24 03:04:25 +0200
commit40de1bb4fec2d17ad0aa10d8b0f7fa05c4d4a196 (patch)
tree32af533853b15fb50e9d753685fd1a53ad789e15
parent1865f867fbe24ad11351ae2a196f117d8d55d0ca (diff)
Some more minor annotations
-rw-r--r--minecproxy/main.c15
-rw-r--r--shared/external.h6
-rw-r--r--shared/utils.h7
3 files changed, 15 insertions, 13 deletions
diff --git a/minecproxy/main.c b/minecproxy/main.c
index 7cd3336..790bbfe 100644
--- a/minecproxy/main.c
+++ b/minecproxy/main.c
@@ -419,7 +419,7 @@ const struct {
};
_noreturn_ static void
-usage(char **argv, bool invalid)
+usage(bool invalid)
{
if (invalid)
info("Invalid option(s)");
@@ -427,7 +427,8 @@ usage(char **argv, bool invalid)
info("Usage: %s [OPTIONS]\n"
"\n"
"Valid options:\n"
- " -c, --cfgdir=DIR\tlook for configuration files in DIR\n"
+ " -c, --cfgdir=DIR\tlook for server configuration files in DIR\n"
+ " -C, --cfgfile=PATH\tuse PATH as the main configuration file\n"
" -u, --user=USER\trun as USER\n"
" -D, --daemonize\trun in daemon mode (disables stderr output)\n"
" -l, --logfile=FILE\tlog to FILE instead of stderr\n"
@@ -436,7 +437,7 @@ usage(char **argv, bool invalid)
" -d, --debug=CATEGORY\tenable debugging for CATEGORY\n"
"\t\t\t(use \"list\" to see available categories,\n"
"\t\t\t or \"all\" to enable all categories)\n",
- argv ? argv[0] : "mcproxy");
+ program_invocation_short_name);
exit(invalid ? EXIT_FAILURE : EXIT_SUCCESS);
}
@@ -548,23 +549,23 @@ cfg_init(int argc, char **argv)
}
if (!debug_category_str[i].name)
- usage(argv, true);
+ usage(true);
debug_mask |= DBG_VERBOSE;
debug_mask |= debug_category_str[i].val;
break;
case 'h':
- usage(argv, false);
+ usage(false);
default:
- usage(argv, true);
+ usage(true);
}
}
if (optind < argc)
- usage(argv, true);
+ usage(true);
}
static void
diff --git a/shared/external.h b/shared/external.h
index 1d7f3b7..beba93a 100644
--- a/shared/external.h
+++ b/shared/external.h
@@ -3,13 +3,13 @@
/* These need to be defined in the linking binary */
#define zmalloc(s) __zmalloc(__func__, __LINE__, s)
-void *__zmalloc(const char *fn, int line, size_t s);
+void *__zmalloc(const char *fn, int line, size_t s) _malloc_ _alloc_(3);
#define xstrdup(s) __xstrdup(__func__, __LINE__, s)
-char *__xstrdup(const char *fn, int line, const char *s);
+char *__xstrdup(const char *fn, int line, const char *s) _malloc_;
#define xstrndup(s, n) __xstrndup(__func__, __LINE__, s, n)
-char *__xstrndup(const char *fn, int line, const char *s, size_t n);
+char *__xstrndup(const char *fn, int line, const char *s, size_t n) _malloc_ _alloc_(4);
#define xfree(s) __xfree(__func__, __LINE__, s)
void __xfree(const char *fn, int line, void *ptr);
diff --git a/shared/utils.h b/shared/utils.h
index d0142b1..769d3e3 100644
--- a/shared/utils.h
+++ b/shared/utils.h
@@ -13,11 +13,12 @@
extern unsigned debug_mask;
#define _unused_ __attribute__((__unused__))
-
+#define _pure_ __attribute__((__pure__))
+#define _const_ __attribute__((__const__))
+#define _alloc_(...) __attribute__((__alloc_size__(__VA_ARGS__)))
+#define _malloc_ __attribute__((__malloc__))
#define _printf_(a, b) __attribute__((__format__(printf, a, b)))
-
#define _alignas_(x) __attribute__((__aligned__(__alignof(x))))
-
#define _big_endian_ __attribute__((packed, scalar_storage_order("big-endian")))
#if __GNUC__ >= 7