summaryrefslogtreecommitdiffstats
path: root/src/printf.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-20 06:02:29 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-20 06:08:07 +0200
commitd9dc87d8409ddf8361b7fcb311ae97088ed1d984 (patch)
treec63be2cf2a7d978dd5b30b3a404d9442acefdff7 /src/printf.c
parent3fd947a2d13a3f110f7c558b1d294dddfd2d25e0 (diff)
downloadfastd-d9dc87d8409ddf8361b7fcb311ae97088ed1d984.tar
fastd-d9dc87d8409ddf8361b7fcb311ae97088ed1d984.zip
Fix lots of -Wextra warnings
Everything clang and GCC warn about, except GCC's missing-field-initializers which are just stupid as they don't allow {} syntax to zero a field.
Diffstat (limited to 'src/printf.c')
-rw-r--r--src/printf.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/printf.c b/src/printf.c
index 99c577b..db111a0 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -31,16 +31,19 @@
#include <net/if.h>
-static inline int snprintf_safe(char *buffer, size_t size, const char *format, ...) {
+static inline size_t snprintf_safe(char *buffer, size_t size, const char *format, ...) {
va_list ap;
va_start(ap, format);
int ret = vsnprintf(buffer, size, format, ap);
va_end(ap);
- return ret < 0 ? 0 : ret > size ? size : ret;
+ if (ret < 0)
+ return 0;
+
+ return min_size_t(ret, size);
}
-static int snprint_peer_address(const fastd_context_t *ctx, char *buffer, size_t size, const fastd_peer_address_t *address, bool bind_address) {
+static size_t snprint_peer_address(const fastd_context_t *ctx, char *buffer, size_t size, const fastd_peer_address_t *address, bool bind_address) {
char addr_buf[INET6_ADDRSTRLEN] = "";
switch (address->sa.sa_family) {
@@ -78,7 +81,7 @@ static int snprint_peer_address(const fastd_context_t *ctx, char *buffer, size_t
}
}
-static int snprint_peer_str(const fastd_context_t *ctx, char *buffer, size_t size, const fastd_peer_t *peer) {
+static size_t snprint_peer_str(const fastd_context_t *ctx, char *buffer, size_t size, const fastd_peer_t *peer) {
if (peer->config && peer->config->name) {
return snprintf_safe(buffer, size, "<%s>", peer->config->name);
}