From bb9aa51ebe8376adc7ffdef5ee6bb3ca959be6e8 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Thu, 11 Jan 2018 21:30:07 +0100 Subject: fmt,macros: update from upstream --- lib/fmt.c | 10 +++++++--- lib/macros.h | 14 +++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/fmt.c b/lib/fmt.c index 58186f8..90e31f4 100644 --- a/lib/fmt.c +++ b/lib/fmt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2017 Richard Braun. + * Copyright (c) 2010-2018 Richard Braun. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -338,6 +338,7 @@ fmt_sprintf_state_consume_modifier(struct fmt_sprintf_state *state) break; case 'z': state->modifier = FMT_MODIFIER_SIZE; + __fallthrough; case 't': state->modifier = FMT_MODIFIER_PTRDIFF; break; @@ -359,6 +360,7 @@ fmt_sprintf_state_consume_specifier(struct fmt_sprintf_state *state) case 'd': case 'i': state->flags |= FMT_FORMAT_CONV_SIGNED; + __fallthrough; case 'u': state->base = 10; state->specifier = FMT_SPECIFIER_INT; @@ -370,8 +372,10 @@ fmt_sprintf_state_consume_specifier(struct fmt_sprintf_state *state) case 'p': state->flags |= FMT_FORMAT_ALT_FORM; state->modifier = FMT_MODIFIER_PTR; + __fallthrough; case 'x': state->flags |= FMT_FORMAT_LOWER; + __fallthrough; case 'X': state->base = 16; state->specifier = FMT_SPECIFIER_INT; @@ -674,8 +678,6 @@ fmt_sprintf_state_produce_str(struct fmt_sprintf_state *state) s = "(null)"; } - len = 0; - for (len = 0; s[len] != '\0'; len++) { if (len == state->precision) { break; @@ -1023,6 +1025,7 @@ fmt_sscanf_state_consume_specifier(struct fmt_sscanf_state *state) break; case 'd': state->flags |= FMT_FORMAT_CONV_SIGNED; + __fallthrough; case 'u': state->base = 10; state->specifier = FMT_SPECIFIER_INT; @@ -1033,6 +1036,7 @@ fmt_sscanf_state_consume_specifier(struct fmt_sscanf_state *state) break; case 'p': state->modifier = FMT_MODIFIER_PTR; + __fallthrough; case 'x': case 'X': state->base = 16; diff --git a/lib/macros.h b/lib/macros.h index a61f80e..6369599 100644 --- a/lib/macros.h +++ b/lib/macros.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2015 Richard Braun. + * Copyright (c) 2009-2018 Richard Braun. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -91,4 +91,16 @@ #define __unused __attribute__((unused)) #endif +#ifndef __used +#define __used __attribute__((used)) +#endif + +#ifndef __fallthrough +#if __GNUC__ >= 7 +#define __fallthrough __attribute__((fallthrough)) +#else /* __GNUC__ >= 7 */ +#define __fallthrough +#endif /* __GNUC__ >= 7 */ +#endif + #endif /* _MACROS_H */ -- cgit v1.2.3