diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-03-26 21:51:58 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-03-26 21:55:24 -0400 |
commit | d67f962a386af60d495cf17789436fa352c9dfe9 (patch) | |
tree | 74f954605b5f91cc47cdbd1e610b64bf86e49841 /src/command.c | |
parent | 6de85d02ae796c02d63016b3e45da0df396f2adc (diff) | |
download | kutter-d67f962a386af60d495cf17789436fa352c9dfe9.tar.gz kutter-d67f962a386af60d495cf17789436fa352c9dfe9.tar.xz kutter-d67f962a386af60d495cf17789436fa352c9dfe9.zip |
command: Simplify sendf() switch
Commit f28eb902 reworked the switch to fix int16 encoding. However,
at least one version of avr gcc doesn't like that switch layout (it
uses a jump table). Reorg the switch to avoid that issue.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/command.c')
-rw-r--r-- | src/command.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/command.c b/src/command.c index a1ea4a7c..a5306f3b 100644 --- a/src/command.c +++ b/src/command.c @@ -139,17 +139,18 @@ _sendf(uint8_t parserid, ...) param_types++; uint32_t v; switch (t) { - case PT_byte: - case PT_uint16: - v = va_arg(args, unsigned int); - goto encode_int; - case PT_int16: - v = (int32_t)va_arg(args, int); - goto encode_int; case PT_uint32: case PT_int32: - v = va_arg(args, uint32_t); - encode_int: + case PT_uint16: + case PT_int16: + case PT_byte: + if (t >= PT_uint16) + if (t == PT_int16) + v = (int32_t)va_arg(args, int); + else + v = va_arg(args, unsigned int); + else + v = va_arg(args, uint32_t); p = encode_int(p, v); break; case PT_string: { |