diff options
author | Jason Gerecke <jason.gerecke@wacom.com> | 2022-02-19 15:44:40 -0800 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2022-02-22 10:41:51 +1000 |
commit | 18ac7bc40be89ccc49ec9f17583503989944069d (patch) | |
tree | 5e2e89abb5ce87992a137c81c309d96e1a1cc92a | |
parent | 571fbced64a51259ea7825c737f1703a0eb6bdf5 (diff) | |
download | xf86-input-wacom-18ac7bc40be89ccc49ec9f17583503989944069d.tar.gz |
Avoid truncated output warning in wcmAxisDump
GCC seems to be confused by our code pattern and insists that our
buffer isn't large enough (no matter how large we might make it)
and may result in truncated snprintf output. Modify the structure
to achieve the same effect in a different way that GCC doesn't
mind.
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
-rw-r--r-- | src/WacomInterface.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/WacomInterface.h b/src/WacomInterface.h index 680fdd2..153cf31 100644 --- a/src/WacomInterface.h +++ b/src/WacomInterface.h @@ -233,21 +233,23 @@ static inline void wcmAxisDump(const WacomAxisData *data, char *buf, size_t len) { uint32_t mask = data->mask; const char *prefix = ""; - size_t count = 0; assert(len > 0); buf[0] = '\0'; for (uint32_t flag = 0x1; flag <= _WACOM_AXIS_LAST; flag <<= 1) { const char *name = wcmAxisName(flag); char value[32]; + int rc; if ((mask & flag) == 0) continue; wcmAxisValue(data, flag, value, sizeof(value)); - count += snprintf(buf + count, len - count, "%s%s: %s", prefix, name, value); - assert(count < len); + rc = snprintf(buf, len, "%s%s: %s", prefix, name, value); + assert(rc > 0 && (size_t)rc < len); + buf += rc; + len -= rc; prefix = ", "; } } |