Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd6395a0 authored by Nick Desaulniers's avatar Nick Desaulniers
Browse files

[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: default avatarNick Desaulniers <ndesaulniers@google.com>
parent e6352200
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -40,7 +40,10 @@ std::string addrToString(const sockaddr_storage* addr) {
}

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);
+4 −1
Original line number Diff line number Diff line
@@ -1487,7 +1487,10 @@ int resolv_set_nameservers(unsigned netid, const std::vector<std::string>& serve
    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++) {
+2 −2
Original line number Diff line number Diff line
@@ -558,8 +558,8 @@ TEST_F(ResolverTest, GetAddrInfo_InvalidSocketType) {
    // 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 @@ TEST_F(ResolverTest, GetAddrInfo_Dns64QueryNullArgumentNode) {
        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.
+2 −2
Original line number Diff line number Diff line
@@ -236,8 +236,8 @@ TEST_F(ResolvGetAddrInfoTest, InvalidParameters_SocketType) {
            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 @@ TEST_F(ResolvGetAddrInfoTest, InvalidParameters_MeaningfulSocktypeAndProtocolCom
                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,
+5 −1
Original line number Diff line number Diff line
@@ -515,7 +515,11 @@ bool DNSResponder::startServer() {
    }

    // 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);
Loading