inetd: only declare and use the mapped-address netconfig under INET6

In a WITHOUT_INET6 build the only assignment to netid2 is compiled out and
the non-INET6 arm returns early, so netid2 is unconditionally NULL and the
rpcb_set() call guarded by it is dead code. clang does not prove it dead
and reports nbuf2 as uninitialized where it is passed as a const pointer,

No functional change.

MFC after:	1 week
Reported by:	clang (-Wuninitialized-const-pointer)
Suggested by:   dim
Approved by: ngie (co-mentor)

Reviewed by:	ngie
Differential Revision:	https://reviews.freebsd.org/D59277
This commit is contained in:
Abdelkader Boudih committed 2026-08-31 19:15:45 +01:00
1 parent ef03c60246
commit 4dcb33ebc8
1 file changed
+6 -2
+6 -2
View File
@@ -1315,11 +1315,13 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
if (sep->se_rpc) {
u_int i;
socklen_t len = sep->se_ctrladdr_size;
struct netconfig *netid, *netid2 = NULL;
struct netconfig *netid;
struct netbuf nbuf;
#ifdef INET6
struct netconfig *netid2 = NULL;
struct sockaddr_in sock;
struct netbuf nbuf2;
#endif
struct netbuf nbuf, nbuf2;
if (getsockname(sep->se_fd,
(struct sockaddr*)&sep->se_ctrladdr, &len) < 0){
@@ -1360,10 +1362,12 @@ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on))
for (i = sep->se_rpc_lowvers; i <= sep->se_rpc_highvers; i++) {
rpcb_unset(sep->se_rpc_prog, i, netid);
rpcb_set(sep->se_rpc_prog, i, netid, &nbuf);
#ifdef INET6
if (netid2) {
rpcb_unset(sep->se_rpc_prog, i, netid2);
rpcb_set(sep->se_rpc_prog, i, netid2, &nbuf2);
}
#endif
}
}
if (sep->se_socktype == SOCK_STREAM)