diff --git a/src/main/aciodrv/device.c b/src/main/aciodrv/device.c index d66790f..23134f6 100644 --- a/src/main/aciodrv/device.c +++ b/src/main/aciodrv/device.c @@ -60,7 +60,7 @@ aciodrv_device_log_buffer(struct aciodrv_device_ctx *device, const char *msg, co char str[4096]; hex_encode_uc((const void *) buffer, length, str, sizeof(str)); - log_misc("[%" PRIXPTR "] %s, length %d: %s", (uintptr_t)device->fd, msg, length, str); + log_misc("[%p] %s, length %d: %s", device->fd, msg, length, str); } #endif @@ -71,7 +71,7 @@ static bool aciodrv_device_send(struct aciodrv_device_ctx *device, const uint8_t uint8_t checksum = 0; if (length > sizeof(send_buf)) { - log_warning("[%" PRIXPTR "] Send buffer overflow", (uintptr_t)device->fd); + log_warning("[%p] Send buffer overflow", device->fd); return false; } @@ -106,7 +106,7 @@ static bool aciodrv_device_send(struct aciodrv_device_ctx *device, const uint8_t #endif if (aciodrv_port_write(device->fd, send_buf, send_buf_pos) != send_buf_pos) { - log_warning("[%" PRIXPTR "] Sending data with length %d failed", (uintptr_t)device->fd, send_buf_pos); + log_warning("[%p] Sending data with length %d failed", device->fd, send_buf_pos); return false; } @@ -182,7 +182,7 @@ static int aciodrv_device_receive(struct aciodrv_device_ctx *device, uint8_t *bu /* recv_size - 1: omit checksum for checksum calc */ if ((recv_size - 1) > max_resp_size) { - log_warning("[%" PRIXPTR "] Expected %d got %d", (uintptr_t)device->fd, max_resp_size - 6, recv_buf[4]); + log_warning("[%p] Expected %d got %d", device->fd, max_resp_size - 6, recv_buf[4]); return -1; } for (int i = 0; i < recv_size - 1; i++) { @@ -198,8 +198,8 @@ static int aciodrv_device_receive(struct aciodrv_device_ctx *device, uint8_t *bu if (checksum != recv_buf[recv_size - 1]) { log_warning( - "[%" PRIXPTR "] Invalid message checksum: %02X != %02X", - (uintptr_t)device->fd, + "[%p] Invalid message checksum: %02X != %02X", + device->fd, checksum, recv_buf[recv_size - 1]); return -1; @@ -341,7 +341,7 @@ struct aciodrv_device_ctx *aciodrv_device_open_path(const char *port_path, int b } } - log_info("Opening ACIO device on [%" PRIXPTR "]", (uintptr_t)device->fd); + log_info("Opening ACIO device on [%p]", device->fd); return device; } @@ -376,8 +376,8 @@ bool aciodrv_send_and_recv(struct aciodrv_device_ctx *device, struct ac_io_messa #ifdef AC_IO_MSG_LOG log_info( - "[%" PRIXPTR "] Beginning send on %d: %04x (%d b)", - (uintptr_t)device->fd, + "[%p] Beginning send on %d: %04x (%d b)", + device->fd, msg->addr, msg->cmd.code, send_size); @@ -389,7 +389,7 @@ bool aciodrv_send_and_recv(struct aciodrv_device_ctx *device, struct ac_io_messa uint16_t req_code = msg->cmd.code; #ifdef AC_IO_MSG_LOG - log_info("[%" PRIXPTR "] Beginning recv: (%d b)", (uintptr_t)device->fd, max_resp_size); + log_info("[%p] Beginning recv: (%d b)", device->fd, max_resp_size); #endif if (aciodrv_device_receive(device, (uint8_t *) msg, max_resp_size) <= 0) { return false; @@ -397,8 +397,8 @@ bool aciodrv_send_and_recv(struct aciodrv_device_ctx *device, struct ac_io_messa if (req_code != msg->cmd.code) { log_warning( - "[%" PRIXPTR "] Received invalid response %04X for request %04X", - (uintptr_t)device->fd, + "[%p] Received invalid response %04X for request %04X", + device->fd, msg->cmd.code, req_code); return false; @@ -411,7 +411,7 @@ void aciodrv_device_close(struct aciodrv_device_ctx *device) { log_assert(device); - log_info("Closing ACIO on [%" PRIXPTR "]", (uintptr_t)device->fd); + log_info("Closing ACIO on [%p]", device->fd); aciodrv_port_close(device->fd); diff --git a/src/main/aciodrv/port.c b/src/main/aciodrv/port.c index 9854cfc..4ab43a8 100644 --- a/src/main/aciodrv/port.c +++ b/src/main/aciodrv/port.c @@ -101,7 +101,7 @@ HANDLE aciodrv_port_open(const char *port_path, int baud) goto fail; } - log_info("[%" PRIXPTR "] Opened ACIO device on %s", (uintptr_t)port_fd, port_path); + log_info("[%p] Opened ACIO device on %s", port_fd, port_path); return port_fd; @@ -123,13 +123,13 @@ int aciodrv_port_read(HANDLE port_fd, void *bytes, int nbytes) } if (!ClearCommError(port_fd, NULL, NULL)) { - log_warning("[%" PRIXPTR "] ClearCommError failed", (uintptr_t)port_fd); + log_warning("[%p] ClearCommError failed", port_fd); return -1; } if (!ReadFile(port_fd, bytes, nbytes, &nread, NULL)) { - log_warning("[%" PRIXPTR "] ReadFile failed: err = %lu", (uintptr_t)port_fd, GetLastError()); + log_warning("[%p] ReadFile failed: err = %lu", port_fd, GetLastError()); return -1; } @@ -148,7 +148,7 @@ int aciodrv_port_write(HANDLE port_fd, const void *bytes, int nbytes) } if (!WriteFile(port_fd, bytes, nbytes, &nwrit, NULL)) { - log_warning("[%" PRIXPTR "] WriteFile failed: err = %lu", (uintptr_t)port_fd, GetLastError()); + log_warning("[%p] WriteFile failed: err = %lu", port_fd, GetLastError()); return -1; }