summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2020-08-02 01:49:51 +0200
committerGravatar Nikias Bassen2020-08-02 01:49:51 +0200
commit0cd01163e5e30c2005edf4daafecbddea236a0d0 (patch)
tree19b6c3105864354d60094d7698b1e916d42fa3f6 /src
parent540e0c1fb988b926b625618c8bf31c8311f37e19 (diff)
downloadusbmuxd-0cd01163e5e30c2005edf4daafecbddea236a0d0.tar.gz
usbmuxd-0cd01163e5e30c2005edf4daafecbddea236a0d0.tar.bz2
device: Remove unnecessary copy in device_control_input() logging
Diffstat (limited to 'src')
-rw-r--r--src/device.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/device.c b/src/device.c
index 0402092..95d3569 100644
--- a/src/device.c
+++ b/src/device.c
@@ -595,28 +595,20 @@ static void device_control_input(struct mux_device *dev, unsigned char *payload,
switch (payload[0]) {
case 3:
if (payload_length > 1) {
- char* buf = malloc(payload_length);
- strncpy(buf, (char*)payload+1, payload_length-1);
- buf[payload_length-1] = '\0';
- usbmuxd_log(LL_ERROR, "%s: ERROR (on device): %s", __func__, buf);
- free(buf);
+ usbmuxd_log(LL_ERROR, "%s: ERROR (on device): %.*s", __func__, payload_length-1, payload+1);
} else {
usbmuxd_log(LL_ERROR, "%s: Got device error payload with empty message", __func__);
}
break;
case 7:
if (payload_length > 1) {
- char* buf = malloc(payload_length);
- strncpy(buf, (char*)payload+1, payload_length-1);
- buf[payload_length-1] = '\0';
- usbmuxd_log(LL_INFO, "%s: %s", __func__, buf);
- free(buf);
+ usbmuxd_log(LL_INFO, "%s: %.*s", __func__, payload_length-1, payload+1);
} else {
- usbmuxd_log(LL_WARNING, "%s: Got payload type 7 with empty message", __func__);
+ usbmuxd_log(LL_WARNING, "%s: Got payload type %d with empty message", __func__, payload[0]);
}
break;
default:
- usbmuxd_log(LL_WARNING, "%s: Got unhandled payload type %d", __func__, payload[0]);
+ usbmuxd_log(LL_WARNING, "%s: Got unhandled payload type %d: %.*s", __func__, payload[0], payload_length-1, payload+1);
break;
}
} else {