systemd-netlogd icon indicating copy to clipboard operation
systemd-netlogd copied to clipboard

Question about code snippet

Open cgzones opened this issue 1 year ago • 1 comments

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;

?

cgzones avatar Jul 29 '24 15:07 cgzones

yes

ssahani avatar Jul 30 '24 14:07 ssahani