summaryrefslogtreecommitdiff
path: root/ltunify.c
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-04-24 10:55:25 +0200
committerPeter Wu <lekensteyn@gmail.com>2013-04-24 10:55:25 +0200
commit6f4b439a5f4a003c9bca334bab3beaa01328064d (patch)
treeead5818f9c167789439aa3c2d0c2667db8f4799e /ltunify.c
parentabcf8c5ff87f1afb2bbed2c68ce84635b7fe8d13 (diff)
downloadltunify-6f4b439a5f4a003c9bca334bab3beaa01328064d.tar.gz
Fix compiler warnings
The memcpy bug is actually a real one-by-off. Since the msg_long struct is contained in a union of hidpp_message, this does not lead to write-past-boundaries (but it may read more than intended). Some fields of version could be uninitialised (when the register query failed). Explicitly clear the values to make clang happy.
Diffstat (limited to 'ltunify.c')
-rw-r--r--ltunify.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/ltunify.c b/ltunify.c
index 127dd12..a14deaf 100644
--- a/ltunify.c
+++ b/ltunify.c
@@ -402,12 +402,12 @@ static bool set_register(int fd, u8 device_index, u8 address,
msg.report_id = LONG_MESSAGE;
exp_sub_id = SUB_SET_LONG_REGISTER;
msg.msg_long.address = address;
- memcpy(&msg.msg_long.str, params, LONG_MESSAGE_LEN - HEADER_SIZE);
+ memcpy(&msg.msg_long.str, params, sizeof msg.msg_long.str);
} else {
msg.report_id = SHORT_MESSAGE;
exp_sub_id = SUB_SET_REGISTER;
msg.msg_short.address = address;
- memcpy(&msg.msg_short.value, params, SHORT_MESSAGE_LEN - HEADER_SIZE);
+ memcpy(&msg.msg_short.value, params, sizeof msg.msg_short.value);
}
msg.sub_id = exp_sub_id;
@@ -717,6 +717,8 @@ bool get_device_version(int fd, u8 device_index, u8 version_type, struct val_reg
bool get_device_versions(int fd, u8 device_index, struct version *version) {
struct val_reg_version ver;
+ memset(version, 0, sizeof *version);
+
if (get_device_version(fd, device_index, VERSION_FIRMWARE, &ver)) {
version->fw_major = ver.v1;
version->fw_minor = ver.v2;