Skip to content

Commit 2bb7c98

Browse files
Geliang Tangintel-lab-lkp
authored andcommitted
selftests: mptcp: diag: drop nlh parameter of recv_nlmsg
It's strange that 'nlh' variable is set to NULL in get_mptcpinfo() and then this NULL pointer is passed to recv_nlmsg(). In fact, this variable should be defined in recv_nlmsg(), not get_mptcpinfo(). So this patch drops this useless 'nlh' parameter of recv_nlmsg() and define 'nlh' variable in recv_nlmsg(). Signed-off-by: Geliang Tang <[email protected]>
1 parent 5907038 commit 2bb7c98

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tools/testing/selftests/net/mptcp/mptcp_diag.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,10 @@ static void parse_nlmsg(struct nlmsghdr *nlh)
185185
}
186186
}
187187

188-
static void recv_nlmsg(int fd, struct nlmsghdr *nlh)
188+
static void recv_nlmsg(int fd)
189189
{
190190
char rcv_buff[8192];
191+
struct nlmsghdr *nlh = (struct nlmsghdr *)rcv_buff;
191192
struct sockaddr_nl rcv_nladdr = {
192193
.nl_family = AF_NETLINK
193194
};
@@ -204,7 +205,6 @@ static void recv_nlmsg(int fd, struct nlmsghdr *nlh)
204205
int len;
205206

206207
len = recvmsg(fd, &rcv_msg, 0);
207-
nlh = (struct nlmsghdr *)rcv_buff;
208208

209209
while (NLMSG_OK(nlh, len)) {
210210
if (nlh->nlmsg_type == NLMSG_DONE) {
@@ -225,15 +225,14 @@ static void recv_nlmsg(int fd, struct nlmsghdr *nlh)
225225

226226
static void get_mptcpinfo(__u32 token)
227227
{
228-
struct nlmsghdr *nlh = NULL;
229228
int fd;
230229

231230
fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG);
232231
if (fd < 0)
233232
die_perror("Netlink socket");
234233

235234
send_query(fd, token);
236-
recv_nlmsg(fd, nlh);
235+
recv_nlmsg(fd);
237236

238237
close(fd);
239238
}

0 commit comments

Comments
 (0)