[DnsResolver] fix -Wreorder-init-list

C++20 will require members in a designated initializer to be in order
unlike C99.

Bug: 139945549
Test: mm
Change-Id: Ifef988f29c23707e27d659d8ee5fe278c4e2a803
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
diff --git a/PrivateDnsConfiguration.cpp b/PrivateDnsConfiguration.cpp
index 14bac16..b4a9ab0 100644
--- a/PrivateDnsConfiguration.cpp
+++ b/PrivateDnsConfiguration.cpp
@@ -40,7 +40,10 @@
 }
 
 bool parseServer(const char* server, sockaddr_storage* parsed) {
-    addrinfo hints = {.ai_family = AF_UNSPEC, .ai_flags = AI_NUMERICHOST | AI_NUMERICSERV};
+    addrinfo hints = {
+            .ai_flags = AI_NUMERICHOST | AI_NUMERICSERV,
+            .ai_family = AF_UNSPEC,
+    };
     addrinfo* res;
 
     int err = getaddrinfo(server, "853", &hints, &res);
diff --git a/res_cache.cpp b/res_cache.cpp
index 68dc48b..4b5ba28 100644
--- a/res_cache.cpp
+++ b/res_cache.cpp
@@ -1487,7 +1487,10 @@
     for (int i = 0; i < numservers; i++) {
         // The addrinfo structures allocated here are freed in free_nameservers_locked().
         const addrinfo hints = {
-                .ai_family = AF_UNSPEC, .ai_socktype = SOCK_DGRAM, .ai_flags = AI_NUMERICHOST};
+                .ai_flags = AI_NUMERICHOST,
+                .ai_family = AF_UNSPEC,
+                .ai_socktype = SOCK_DGRAM,
+        };
         const int rt = getaddrinfo_numeric(nameservers[i].c_str(), "53", hints, &nsaddrinfo[i]);
         if (rt != 0) {
             for (int j = 0; j < i; j++) {
diff --git a/resolv_integration_test.cpp b/resolv_integration_test.cpp
index 5014983..fb526bf 100644
--- a/resolv_integration_test.cpp
+++ b/resolv_integration_test.cpp
@@ -558,8 +558,8 @@
     // TODO: Test other invalid socket types.
     const addrinfo hints = {
             .ai_family = AF_UNSPEC,
-            .ai_protocol = ANY,
             .ai_socktype = SOCK_PACKET,
+            .ai_protocol = ANY,
     };
     addrinfo* result = nullptr;
     // This is a valid hint, but the query won't be sent because the socket type is
@@ -2640,10 +2640,10 @@
         SCOPED_TRACE(config.asParameters());
 
         addrinfo hints = {
+                .ai_flags = config.flag,
                 .ai_family = AF_UNSPEC,  // any address family
                 .ai_socktype = 0,        // any type
                 .ai_protocol = 0,        // any protocol
-                .ai_flags = config.flag,
         };
 
         // Assign hostname as null and service as port name.
diff --git a/resolv_unit_test.cpp b/resolv_unit_test.cpp
index f9accd0..fa59571 100644
--- a/resolv_unit_test.cpp
+++ b/resolv_unit_test.cpp
@@ -236,8 +236,8 @@
             for (const auto& socktype : {SOCK_RDM, SOCK_SEQPACKET, SOCK_DCCP, SOCK_PACKET}) {
                 const addrinfo hints = {
                         .ai_family = family,
-                        .ai_protocol = protocol,
                         .ai_socktype = socktype,
+                        .ai_protocol = protocol,
                 };
                 for (const char* service : {static_cast<const char*>(nullptr),  // service is null
                                             "80",
@@ -295,8 +295,8 @@
                 addrinfo* result = nullptr;
                 const addrinfo hints = {
                         .ai_family = family,
-                        .ai_protocol = protocol,
                         .ai_socktype = socktype,
+                        .ai_protocol = protocol,
                 };
                 NetworkDnsEventReported event;
                 int rv = resolv_getaddrinfo("localhost", nullptr /*servname*/, &hints, &mNetcontext,
diff --git a/tests/dns_responder/dns_responder.cpp b/tests/dns_responder/dns_responder.cpp
index 4bac4b0..072c2dd 100644
--- a/tests/dns_responder/dns_responder.cpp
+++ b/tests/dns_responder/dns_responder.cpp
@@ -515,7 +515,11 @@
     }
 
     // Set up UDP socket.
-    addrinfo ai_hints{.ai_family = AF_UNSPEC, .ai_socktype = SOCK_DGRAM, .ai_flags = AI_PASSIVE};
+    addrinfo ai_hints{
+            .ai_flags = AI_PASSIVE,
+            .ai_family = AF_UNSPEC,
+            .ai_socktype = SOCK_DGRAM,
+    };
     addrinfo* ai_res = nullptr;
     int rv = getaddrinfo(listen_address_.c_str(), listen_service_.c_str(), &ai_hints, &ai_res);
     ScopedAddrinfo ai_res_cleanup(ai_res);
diff --git a/tests/dns_responder/dns_tls_frontend.cpp b/tests/dns_responder/dns_tls_frontend.cpp
index 3b25324..a8f6546 100644
--- a/tests/dns_responder/dns_tls_frontend.cpp
+++ b/tests/dns_responder/dns_tls_frontend.cpp
@@ -164,7 +164,10 @@
 
     // Set up TCP server socket for clients.
     addrinfo frontend_ai_hints{
-            .ai_family = AF_UNSPEC, .ai_socktype = SOCK_STREAM, .ai_flags = AI_PASSIVE};
+            .ai_flags = AI_PASSIVE,
+            .ai_family = AF_UNSPEC,
+            .ai_socktype = SOCK_STREAM,
+    };
     addrinfo* frontend_ai_res = nullptr;
     int rv = getaddrinfo(listen_address_.c_str(), listen_service_.c_str(), &frontend_ai_hints,
                          &frontend_ai_res);