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

Commit 208b32cf authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "[DnsResolver] fix -Wreorder-init-list"

parents 852c08e5 cd6395a0
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -40,7 +40,10 @@ std::string addrToString(const sockaddr_storage* addr) {
}
}


bool parseServer(const char* server, sockaddr_storage* parsed) {
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;
    addrinfo* res;


    int err = getaddrinfo(server, "853", &hints, &res);
    int err = getaddrinfo(server, "853", &hints, &res);
+4 −1
Original line number Original line 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++) {
    for (int i = 0; i < numservers; i++) {
        // The addrinfo structures allocated here are freed in free_nameservers_locked().
        // The addrinfo structures allocated here are freed in free_nameservers_locked().
        const addrinfo hints = {
        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]);
        const int rt = getaddrinfo_numeric(nameservers[i].c_str(), "53", hints, &nsaddrinfo[i]);
        if (rt != 0) {
        if (rt != 0) {
            for (int j = 0; j < i; j++) {
            for (int j = 0; j < i; j++) {
+2 −2
Original line number Original line Diff line number Diff line
@@ -558,8 +558,8 @@ TEST_F(ResolverTest, GetAddrInfo_InvalidSocketType) {
    // TODO: Test other invalid socket types.
    // TODO: Test other invalid socket types.
    const addrinfo hints = {
    const addrinfo hints = {
            .ai_family = AF_UNSPEC,
            .ai_family = AF_UNSPEC,
            .ai_protocol = ANY,
            .ai_socktype = SOCK_PACKET,
            .ai_socktype = SOCK_PACKET,
            .ai_protocol = ANY,
    };
    };
    addrinfo* result = nullptr;
    addrinfo* result = nullptr;
    // This is a valid hint, but the query won't be sent because the socket type is
    // 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());
        SCOPED_TRACE(config.asParameters());


        addrinfo hints = {
        addrinfo hints = {
                .ai_flags = config.flag,
                .ai_family = AF_UNSPEC,  // any address family
                .ai_family = AF_UNSPEC,  // any address family
                .ai_socktype = 0,        // any type
                .ai_socktype = 0,        // any type
                .ai_protocol = 0,        // any protocol
                .ai_protocol = 0,        // any protocol
                .ai_flags = config.flag,
        };
        };


        // Assign hostname as null and service as port name.
        // Assign hostname as null and service as port name.
+2 −2
Original line number Original line 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}) {
            for (const auto& socktype : {SOCK_RDM, SOCK_SEQPACKET, SOCK_DCCP, SOCK_PACKET}) {
                const addrinfo hints = {
                const addrinfo hints = {
                        .ai_family = family,
                        .ai_family = family,
                        .ai_protocol = protocol,
                        .ai_socktype = socktype,
                        .ai_socktype = socktype,
                        .ai_protocol = protocol,
                };
                };
                for (const char* service : {static_cast<const char*>(nullptr),  // service is null
                for (const char* service : {static_cast<const char*>(nullptr),  // service is null
                                            "80",
                                            "80",
@@ -295,8 +295,8 @@ TEST_F(ResolvGetAddrInfoTest, InvalidParameters_MeaningfulSocktypeAndProtocolCom
                addrinfo* result = nullptr;
                addrinfo* result = nullptr;
                const addrinfo hints = {
                const addrinfo hints = {
                        .ai_family = family,
                        .ai_family = family,
                        .ai_protocol = protocol,
                        .ai_socktype = socktype,
                        .ai_socktype = socktype,
                        .ai_protocol = protocol,
                };
                };
                NetworkDnsEventReported event;
                NetworkDnsEventReported event;
                int rv = resolv_getaddrinfo("localhost", nullptr /*servname*/, &hints, &mNetcontext,
                int rv = resolv_getaddrinfo("localhost", nullptr /*servname*/, &hints, &mNetcontext,
+5 −1
Original line number Original line Diff line number Diff line
@@ -515,7 +515,11 @@ bool DNSResponder::startServer() {
    }
    }


    // Set up UDP socket.
    // 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;
    addrinfo* ai_res = nullptr;
    int rv = getaddrinfo(listen_address_.c_str(), listen_service_.c_str(), &ai_hints, &ai_res);
    int rv = getaddrinfo(listen_address_.c_str(), listen_service_.c_str(), &ai_hints, &ai_res);
    ScopedAddrinfo ai_res_cleanup(ai_res);
    ScopedAddrinfo ai_res_cleanup(ai_res);
Loading