Skip to content

Commit b6f2ecb

Browse files
Jakub Kicinskigregkh
authored andcommitted
selftests: bpf: correct perror strings
[ Upstream commit e5dc9dd ] perror(str) is basically equivalent to print("%s: %s\n", str, strerror(errno)). New line or colon at the end of str is a mistake/breaks formatting. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Simon Horman <simon.horman@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7ba0f92 commit b6f2ecb

2 files changed

Lines changed: 20 additions & 20 deletions

File tree

‎tools/testing/selftests/bpf/test_sockmap.c‎

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -240,44 +240,44 @@ static int sockmap_init_sockets(int verbose)
240240
addr.sin_port = htons(S1_PORT);
241241
err = bind(s1, (struct sockaddr *)&addr, sizeof(addr));
242242
if (err < 0) {
243-
perror("bind s1 failed()\n");
243+
perror("bind s1 failed()");
244244
return errno;
245245
}
246246

247247
addr.sin_port = htons(S2_PORT);
248248
err = bind(s2, (struct sockaddr *)&addr, sizeof(addr));
249249
if (err < 0) {
250-
perror("bind s2 failed()\n");
250+
perror("bind s2 failed()");
251251
return errno;
252252
}
253253

254254
/* Listen server sockets */
255255
addr.sin_port = htons(S1_PORT);
256256
err = listen(s1, 32);
257257
if (err < 0) {
258-
perror("listen s1 failed()\n");
258+
perror("listen s1 failed()");
259259
return errno;
260260
}
261261

262262
addr.sin_port = htons(S2_PORT);
263263
err = listen(s2, 32);
264264
if (err < 0) {
265-
perror("listen s1 failed()\n");
265+
perror("listen s1 failed()");
266266
return errno;
267267
}
268268

269269
/* Initiate Connect */
270270
addr.sin_port = htons(S1_PORT);
271271
err = connect(c1, (struct sockaddr *)&addr, sizeof(addr));
272272
if (err < 0 && errno != EINPROGRESS) {
273-
perror("connect c1 failed()\n");
273+
perror("connect c1 failed()");
274274
return errno;
275275
}
276276

277277
addr.sin_port = htons(S2_PORT);
278278
err = connect(c2, (struct sockaddr *)&addr, sizeof(addr));
279279
if (err < 0 && errno != EINPROGRESS) {
280-
perror("connect c2 failed()\n");
280+
perror("connect c2 failed()");
281281
return errno;
282282
} else if (err < 0) {
283283
err = 0;
@@ -286,13 +286,13 @@ static int sockmap_init_sockets(int verbose)
286286
/* Accept Connecrtions */
287287
p1 = accept(s1, NULL, NULL);
288288
if (p1 < 0) {
289-
perror("accept s1 failed()\n");
289+
perror("accept s1 failed()");
290290
return errno;
291291
}
292292

293293
p2 = accept(s2, NULL, NULL);
294294
if (p2 < 0) {
295-
perror("accept s1 failed()\n");
295+
perror("accept s1 failed()");
296296
return errno;
297297
}
298298

@@ -353,7 +353,7 @@ static int msg_loop_sendpage(int fd, int iov_length, int cnt,
353353
int sent = sendfile(fd, fp, NULL, iov_length);
354354

355355
if (!drop && sent < 0) {
356-
perror("send loop error:");
356+
perror("send loop error");
357357
close(fp);
358358
return sent;
359359
} else if (drop && sent >= 0) {
@@ -472,7 +472,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
472472
int sent = sendmsg(fd, &msg, flags);
473473

474474
if (!drop && sent < 0) {
475-
perror("send loop error:");
475+
perror("send loop error");
476476
goto out_errno;
477477
} else if (drop && sent >= 0) {
478478
printf("send loop error expected: %i\n", sent);
@@ -508,7 +508,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
508508
total_bytes -= txmsg_pop_total;
509509
err = clock_gettime(CLOCK_MONOTONIC, &s->start);
510510
if (err < 0)
511-
perror("recv start time: ");
511+
perror("recv start time");
512512
while (s->bytes_recvd < total_bytes) {
513513
if (txmsg_cork) {
514514
timeout.tv_sec = 0;
@@ -552,7 +552,7 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
552552
if (recv < 0) {
553553
if (errno != EWOULDBLOCK) {
554554
clock_gettime(CLOCK_MONOTONIC, &s->end);
555-
perror("recv failed()\n");
555+
perror("recv failed()");
556556
goto out_errno;
557557
}
558558
}
@@ -566,15 +566,15 @@ static int msg_loop(int fd, int iov_count, int iov_length, int cnt,
566566

567567
errno = msg_verify_data(&msg, recv, chunk_sz);
568568
if (errno) {
569-
perror("data verify msg failed\n");
569+
perror("data verify msg failed");
570570
goto out_errno;
571571
}
572572
if (recvp) {
573573
errno = msg_verify_data(&msg_peek,
574574
recvp,
575575
chunk_sz);
576576
if (errno) {
577-
perror("data verify msg_peek failed\n");
577+
perror("data verify msg_peek failed");
578578
goto out_errno;
579579
}
580580
}
@@ -663,7 +663,7 @@ static int sendmsg_test(struct sockmap_options *opt)
663663
err = 0;
664664
exit(err ? 1 : 0);
665665
} else if (rxpid == -1) {
666-
perror("msg_loop_rx: ");
666+
perror("msg_loop_rx");
667667
return errno;
668668
}
669669

@@ -690,7 +690,7 @@ static int sendmsg_test(struct sockmap_options *opt)
690690
s.bytes_recvd, recvd_Bps, recvd_Bps/giga);
691691
exit(err ? 1 : 0);
692692
} else if (txpid == -1) {
693-
perror("msg_loop_tx: ");
693+
perror("msg_loop_tx");
694694
return errno;
695695
}
696696

@@ -724,7 +724,7 @@ static int forever_ping_pong(int rate, struct sockmap_options *opt)
724724
/* Ping/Pong data from client to server */
725725
sc = send(c1, buf, sizeof(buf), 0);
726726
if (sc < 0) {
727-
perror("send failed()\n");
727+
perror("send failed()");
728728
return sc;
729729
}
730730

@@ -757,7 +757,7 @@ static int forever_ping_pong(int rate, struct sockmap_options *opt)
757757
rc = recv(i, buf, sizeof(buf), 0);
758758
if (rc < 0) {
759759
if (errno != EWOULDBLOCK) {
760-
perror("recv failed()\n");
760+
perror("recv failed()");
761761
return rc;
762762
}
763763
}
@@ -769,7 +769,7 @@ static int forever_ping_pong(int rate, struct sockmap_options *opt)
769769

770770
sc = send(i, buf, rc, 0);
771771
if (sc < 0) {
772-
perror("send failed()\n");
772+
perror("send failed()");
773773
return sc;
774774
}
775775
}

‎tools/testing/selftests/bpf/xdping.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static int get_stats(int fd, __u16 count, __u32 raddr)
4545
printf("\nXDP RTT data:\n");
4646

4747
if (bpf_map_lookup_elem(fd, &raddr, &pinginfo)) {
48-
perror("bpf_map_lookup elem: ");
48+
perror("bpf_map_lookup elem");
4949
return 1;
5050
}
5151

0 commit comments

Comments
 (0)