From 27e48d2eea8a6231697719dbaca341603072c89d Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Thu, 19 Aug 1999 11:18:37 +0000 Subject: [PATCH] don't test errno if there has been no error --- lib/isc/unix/ifiter_ioctl.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/isc/unix/ifiter_ioctl.c b/lib/isc/unix/ifiter_ioctl.c index af195e3100..b2a8e97891 100644 --- a/lib/isc/unix/ifiter_ioctl.c +++ b/lib/isc/unix/ifiter_ioctl.c @@ -85,9 +85,18 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) iter->ifc.ifc_len = iter->bufsize; iter->ifc.ifc_buf = iter->buf; - if (ioctl(iter->socket, SIOCGIFCONF, (char *) &iter->ifc) >= 0) - { + if (ioctl(iter->socket, SIOCGIFCONF, (char *) &iter->ifc) < 0) { + if (errno != EINVAL) { + UNEXPECTED_ERROR(__FILE__, __LINE__, + "get interface configuration: %s", + strerror(errno)); + result = ISC_R_UNEXPECTED; + goto ioctl_failure; + } + /* EINVAL. Retry with a bigger buffer. */ + } else { /* + * The ioctl succeeded. * Some OS's just return what will fit rather * than set EINVAL if the buffer is too small * to fit all the interfaces in. If @@ -99,14 +108,6 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) < iter->bufsize) break; } - if (errno != EINVAL) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "get interface configuration: %s", - strerror(errno)); - result = ISC_R_UNEXPECTED; - goto ioctl_failure; - } - if (iter->bufsize >= IFCONF_BUFSIZE_MAX) { UNEXPECTED_ERROR(__FILE__, __LINE__, "get interface configuration: "