summary refs log tree commit diff
path: root/resolv/res_init.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2017-06-19 13:19:00 +0200
committerFlorian Weimer <fweimer@redhat.com>2017-06-19 14:24:24 +0200
commit94f094f22b50a20de9042cb1e78c7299992a91c9 (patch)
tree091d16271ff672a72d8cf9927c2a89108c37b738 /resolv/res_init.c
parente68111fbd63e84b66bd9e03b42721c79230b9b6d (diff)
downloadglibc-94f094f22b50a20de9042cb1e78c7299992a91c9.tar.gz
glibc-94f094f22b50a20de9042cb1e78c7299992a91c9.tar.xz
glibc-94f094f22b50a20de9042cb1e78c7299992a91c9.zip
resolv: Introduce is_sort_mask and call it from res_vinit
Diffstat (limited to 'resolv/res_init.c')
-rw-r--r--resolv/res_init.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/resolv/res_init.c b/resolv/res_init.c
index eb24fca3a6..eb8e308fda 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -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 != ';' &&