diff options
author | Florian Weimer <fweimer@redhat.com> | 2017-04-19 14:29:11 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2017-04-19 14:29:24 +0200 |
commit | bee05c9d58a34ec5886faf3b56ecaa56355d94bf (patch) | |
tree | a06d305b3059a1fbbf55f7e183102124ed02a02f /resolv/nss_dns/dns-host.c | |
parent | 3e2cf872a5509d5ba903c1766ca533d56c430655 (diff) | |
download | glibc-bee05c9d58a34ec5886faf3b56ecaa56355d94bf.tar.gz glibc-bee05c9d58a34ec5886faf3b56ecaa56355d94bf.tar.xz glibc-bee05c9d58a34ec5886faf3b56ecaa56355d94bf.zip |
resolv: Replace __builtin_expect with __glibc_unlikely/__glibc_likely
Diffstat (limited to 'resolv/nss_dns/dns-host.c')
-rw-r--r-- | resolv/nss_dns/dns-host.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 705b3c9c07..7099d093f3 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -619,7 +619,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, ancount = ntohs (hp->ancount); qdcount = ntohs (hp->qdcount); cp = answer->buf + HFIXEDSZ; - if (__builtin_expect (qdcount, 1) != 1) + if (__glibc_unlikely (qdcount != 1)) { *h_errnop = NO_RECOVERY; return NSS_STATUS_UNAVAIL; @@ -633,7 +633,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, packtmp, sizeof packtmp); if (n != -1 && __ns_name_ntop (packtmp, bp, linebuflen) == -1) { - if (__builtin_expect (errno, 0) == EMSGSIZE) + if (__glibc_unlikely (errno) == EMSGSIZE) goto too_small; n = -1; @@ -642,13 +642,19 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, if (n > 0 && bp[0] == '.') bp[0] = '\0'; - if (__builtin_expect (n < 0 || ((*name_ok) (bp) == 0 && (errno = EBADMSG)), - 0)) + if (__glibc_unlikely (n < 0)) { *errnop = errno; *h_errnop = NO_RECOVERY; return NSS_STATUS_UNAVAIL; } + if (__glibc_unlikely (name_ok (bp) == 0)) + { + errno = EBADMSG; + *errnop = EBADMSG; + *h_errnop = NO_RECOVERY; + return NSS_STATUS_UNAVAIL; + } cp += n + QFIXEDSZ; if (qtype == T_A || qtype == T_AAAA) @@ -690,7 +696,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, packtmp, sizeof packtmp); if (n != -1 && __ns_name_ntop (packtmp, bp, linebuflen) == -1) { - if (__builtin_expect (errno, 0) == EMSGSIZE) + if (__glibc_unlikely (errno == EMSGSIZE)) goto too_small; n = -1; @@ -750,7 +756,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, /* Store alias. */ *ap++ = bp; n = strlen (bp) + 1; /* For the \0. */ - if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN) + if (__glibc_unlikely (n >= MAXHOSTNAMELEN)) { ++had_error; continue; @@ -761,7 +767,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, n = strlen (tbuf) + 1; /* For the \0. */ if (__glibc_unlikely (n > linebuflen)) goto too_small; - if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN) + if (__glibc_unlikely (n >= MAXHOSTNAMELEN)) { ++had_error; continue; @@ -789,7 +795,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, n = strlen (tbuf) + 1; /* For the \0. */ if (__glibc_unlikely (n > linebuflen)) goto too_small; - if (__builtin_expect (n, 0) >= MAXHOSTNAMELEN) + if (__glibc_unlikely (n >= MAXHOSTNAMELEN)) { ++had_error; continue; @@ -821,7 +827,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, packtmp, sizeof packtmp); if (n != -1 && __ns_name_ntop (packtmp, bp, linebuflen) == -1) { - if (__builtin_expect (errno, 0) == EMSGSIZE) + if (__glibc_unlikely (errno == EMSGSIZE)) goto too_small; n = -1; @@ -854,7 +860,7 @@ getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, return NSS_STATUS_SUCCESS; case T_A: case T_AAAA: - if (__builtin_expect (strcasecmp (result->h_name, bp), 0) != 0) + if (__glibc_unlikely (strcasecmp (result->h_name, bp) != 0)) { cp += n; continue; /* XXX - had_error++ ? */ @@ -975,7 +981,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, it later. */ if (n != -1 && __ns_name_ntop (packtmp, buffer, buflen) == -1) { - if (__builtin_expect (errno, 0) == EMSGSIZE) + if (__glibc_unlikely (errno == EMSGSIZE)) { too_small: *errnop = ERANGE; @@ -986,13 +992,19 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, n = -1; } - if (__builtin_expect (n < 0 || (res_hnok (buffer) == 0 - && (errno = EBADMSG)), 0)) + if (__glibc_unlikely (n < 0)) { *errnop = errno; *h_errnop = NO_RECOVERY; return NSS_STATUS_UNAVAIL; } + if (__glibc_unlikely (res_hnok (buffer) == 0)) + { + errno = EBADMSG; + *errnop = EBADMSG; + *h_errnop = NO_RECOVERY; + return NSS_STATUS_UNAVAIL; + } cp += n + QFIXEDSZ; int haveanswer = 0; @@ -1014,7 +1026,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, if (n != -1 && (h_namelen = __ns_name_ntop (packtmp, buffer, buflen)) == -1) { - if (__builtin_expect (errno, 0) == EMSGSIZE) + if (__glibc_unlikely (errno == EMSGSIZE)) goto too_small; n = -1; @@ -1128,8 +1140,7 @@ gaih_getanswer_slice (const querybuf *answer, int anslen, const char *qname, buffer += pad; buflen = buflen > pad ? buflen - pad : 0; - if (__builtin_expect (buflen < sizeof (struct gaih_addrtuple), - 0)) + if (__glibc_unlikely (buflen < sizeof (struct gaih_addrtuple))) goto too_small; *pat = (struct gaih_addrtuple *) buffer; |