From cf2c7d48380969200034afeab93169e68c34c397 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Wed, 23 Dec 2020 17:39:01 -0800 Subject: [clang-tidy] Do not use else after return Signed-off-by: Rosen Penev --- src/afc.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/afc.c') diff --git a/src/afc.c b/src/afc.c index 17273e2..d8c3db0 100644 --- a/src/afc.c +++ b/src/afc.c @@ -229,7 +229,9 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t if (recv_len == 0) { debug_info("Just didn't get enough."); return AFC_E_MUX_ERROR; - } else if (recv_len < sizeof(AFCPacket)) { + } + + if (recv_len < sizeof(AFCPacket)) { debug_info("Did not even get the AFCPacket header"); return AFC_E_MUX_ERROR; } @@ -250,14 +252,14 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t if (header.this_length < sizeof(AFCPacket)) { debug_info("Invalid AFCPacket header received!"); return AFC_E_OP_HEADER_INVALID; - } else if ((header.this_length == header.entire_length) - && header.entire_length == sizeof(AFCPacket)) { + } + if ((header.this_length == header.entire_length) + && header.entire_length == sizeof(AFCPacket)) { debug_info("Empty AFCPacket received!"); if (header.operation == AFC_OP_DATA) { return AFC_E_SUCCESS; - } else { - return AFC_E_IO_ERROR; } + return AFC_E_IO_ERROR; } debug_info("received AFC packet, full len=%lld, this len=%lld, operation=0x%llx", header.entire_length, header.this_length, header.operation); @@ -273,7 +275,8 @@ static afc_error_t afc_receive_data(afc_client_t client, char **bytes, uint32_t free(buf); debug_info("Did not get packet contents!"); return AFC_E_NOT_ENOUGH_DATA; - } else if (recv_len < this_len) { + } + if (recv_len < this_len) { free(buf); debug_info("Could not receive this_len=%d bytes", this_len); return AFC_E_NOT_ENOUGH_DATA; @@ -749,22 +752,23 @@ LIBIMOBILEDEVICE_API afc_error_t afc_file_read(afc_client_t client, uint64_t han if (ret != AFC_E_SUCCESS) { afc_unlock(client); return ret; - } else if (bytes_loc == 0) { + } + if (bytes_loc == 0) { if (input) free(input); afc_unlock(client); *bytes_read = current_count; /* FIXME: check that's actually a success */ return ret; - } else { - if (input) { - debug_info("%d", bytes_loc); - memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc); - free(input); - input = NULL; - current_count += (bytes_loc > length) ? length : bytes_loc; - } } + if (input) { + debug_info("%d", bytes_loc); + memcpy(data + current_count, input, (bytes_loc > length) ? length : bytes_loc); + free(input); + input = NULL; + current_count += (bytes_loc > length) ? length : bytes_loc; + } + afc_unlock(client); *bytes_read = current_count; return ret; -- cgit v1.1-32-gdbae