Skip to content

Commit 6caf08c

Browse files
committed
mctp-bench: check getrandom return value
Some compiles will warn with: ../src/mctp-bench.c: In function ‘command’: ../src/mctp-bench.c:686:9: warning: ignoring return value of ‘getrandom’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 686 | getrandom(&req->iid, sizeof(req->iid), 0); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ getrandom() cannot fail with the length we're requesting, so suppress the warning. Signed-off-by: Jeremy Kerr <[email protected]>
1 parent 832706c commit 6caf08c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mctp-bench.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,10 @@ static int command(mctp_eid_t eid, int net, enum command command,
683683
req->magic = COMMAND_MAGIC;
684684
req->version = COMMAND_VERSION;
685685
req->command = command;
686-
getrandom(&req->iid, sizeof(req->iid), 0);
686+
/* on a recent kernel (ie., any with MCTP support), getrandom is
687+
* infallible with <=256-byte lengths
688+
*/
689+
(void)getrandom(&req->iid, sizeof(req->iid), 0);
687690
memcpy(req->body, body, body_len);
688691

689692
rc = sendto(sd, req, req_len, 0, (struct sockaddr *)&addr,

0 commit comments

Comments
 (0)