[PATCH 2/4] lib: fwts_ipmi: remove redundant for loop

Colin King colin.king at canonical.com
Tue May 31 10:42:36 UTC 2016


From: Colin Ian King <colin.king at canonical.com>

The for loop is redundant; it never gets to the end to do more than
1 loop; so remove the loop.  Instead, return if the poll failed or
timed out. This simplifies the code and keeps the same functionality.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/lib/src/fwts_ipmi.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/lib/src/fwts_ipmi.c b/src/lib/src/fwts_ipmi.c
index f5f5a56..d4492cc 100644
--- a/src/lib/src/fwts_ipmi.c
+++ b/src/lib/src/fwts_ipmi.c
@@ -55,16 +55,12 @@ int fwts_ipmi_exec_query(
 		return FWTS_ERROR;
 	}
 
-	for (;;) {
-		fwts_pfd.events = POLLIN | POLLPRI;
-		fwts_pfd.fd = fd;
-		fwts_pollfd_rc = poll(&fwts_pfd,1,5000);
-		if (fwts_pollfd_rc > 0) {
-			break;
-		} else {
-			close(fd);
-			return FWTS_ERROR;
-		}
+	fwts_pfd.events = POLLIN | POLLPRI;
+	fwts_pfd.fd = fd;
+	fwts_pollfd_rc = poll(&fwts_pfd, 1, 5000);
+	if (fwts_pollfd_rc <= 0) {
+		close(fd);
+		return FWTS_ERROR;
 	}
 
 	memset(&recv_data, 0, sizeof(IPMI_MAX_MSG_LENGTH));
-- 
2.8.1




More information about the fwts-devel mailing list