From 70048a0b2c4e4b0a8c491a44ce195bff2a331fc9 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sun, 22 Sep 2013 02:06:58 +0200 Subject: [PATCH] uart.c: check return of read() Fix warning uart.c:146:3: warning: ignoring return value of 'read', declared with attribute warn_unused_result [-Wunused-result] Also reported by Coverity: CID undefined (#1 of 1): Ignoring number of bytes read (CHECKED_RETURN) check_return: "read(int, void *, size_t)" returns the number of bytes read, but it is ignored. --- libnfc/buses/uart.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libnfc/buses/uart.c b/libnfc/buses/uart.c index 3dd099a..c2e67af 100644 --- a/libnfc/buses/uart.c +++ b/libnfc/buses/uart.c @@ -143,7 +143,11 @@ uart_flush_input(serial_port sp) return; } // There is something available, read the data - (void)read(UART_DATA(sp)->fd, rx, available_bytes_count); + if (read(UART_DATA(sp)->fd, rx, available_bytes_count) < 0) { + perror("uart read"); + free(rx); + return; + } log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%d bytes have eaten.", available_bytes_count); free(rx); }