]> sourceware.org Git - glibc.git/commitdiff
resolv: Introduce is_sort_mask and call it from res_vinit
authorFlorian Weimer <fweimer@redhat.com>
Mon, 19 Jun 2017 11:19:00 +0000 (13:19 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 19 Jun 2017 12:24:24 +0000 (14:24 +0200)
ChangeLog
resolv/res_init.c

index 0e2f1417efe0b31077e1e33882fdb9a328e32aea..da00dbd5b4c6aa3f65313db55b3767e31654114f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-06-19  Florian Weimer  <fweimer@redhat.com>
+
+       * resolv/res_init.c (sort_mask_chars, ISSORTMASK): Remove.
+       (is_sort_mask): New function.
+       (__res_vinit): Use it.
+
 2017-06-19  Florian Weimer  <fweimer@redhat.com>
 
        * resolv/res_init.c (res_setoptions): Remove DEBUG preprocessor
index eb24fca3a6ecef9a63921f61b9a97d87e51ef2ad..eb8e308fdaa899efd14005e21a5a73839cb6c13b 100644 (file)
@@ -85,9 +85,6 @@
 
 static void res_setoptions (res_state, const char *, const char *)
      internal_function;
-
-static const char sort_mask_chars[] = "/&";
-#define ISSORTMASK(ch) (strchr(sort_mask_chars, ch) != NULL)
 static u_int32_t net_mask (struct in_addr) __THROW;
 
 unsigned long long int __res_initstamp attribute_hidden;
@@ -109,6 +106,14 @@ res_ninit(res_state statp) {
 }
 libc_hidden_def (__res_ninit)
 
+/* Return true if CH separates the netmask in the "sortlist"
+   directive.  */
+static inline bool
+is_sort_mask (char ch)
+{
+  return ch == '/' || ch == '&';
+}
+
 /* This function has to be reachable by res_data.c but not publically. */
 int
 __res_vinit(res_state statp, int preinit) {
@@ -305,14 +310,14 @@ __res_vinit(res_state statp, int preinit) {
                        if (*cp == '\0' || *cp == '\n' || *cp == ';')
                            break;
                        net = cp;
-                       while (*cp && !ISSORTMASK(*cp) && *cp != ';' &&
+                       while (*cp && !is_sort_mask (*cp) && *cp != ';' &&
                               isascii(*cp) && !isspace(*cp))
                                cp++;
                        n = *cp;
                        *cp = 0;
                        if (__inet_aton(net, &a)) {
                            statp->sort_list[nsort].addr = a;
-                           if (ISSORTMASK(n)) {
+                           if (is_sort_mask (n)) {
                                *cp++ = n;
                                net = cp;
                                while (*cp && *cp != ';' &&
This page took 0.140043 seconds and 5 git commands to generate.