Message ID | 1464691358-18134-3-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 2016-05-31 06:42 PM, Colin King wrote: > From: Colin Ian King <colin.king@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@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)); > Acked-by: Alex Hung <alex.hung@canonical.com>
On 05/31/2016 06:42 PM, Colin King wrote: > From: Colin Ian King <colin.king@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@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)); Acked-by: Ivan Hu <ivan.hu@canonical.com>
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));