systemd / systemd-netlogd

Forwards messages from the journal to other hosts over the network using syslog format RFC 5424 and RFC 3164
GNU General Public License v2.0
69 stars 25 forks source link

Question about code snippet #118

Open cgzones opened 1 month ago

cgzones commented 1 month ago

The following code snippet seems odd to me:

https://github.com/systemd/systemd-netlogd/blob/a7c6b83e8db156edee75e547b1c1aa8b0498c7ff/src/netlog/netlog-network.c#L137-L168

The variable sa is assigned but its value (only its size) is never used.

Should the code either look like this:

case AF_INET:
    salen = sizeof(m->address.sockaddr.in);
    break;
case AF_INET6:
    salen = sizeof(m->address.sockaddr.in6);
    break;

or should the variable be used this way:

r = sockaddr_pretty(sa, salen, true, true, &pretty);
        if (r < 0)
                return r;

?

ssahani commented 1 month ago

yes