From c31addfa9c0e9ed51219d39d9080cfdfd46513a1 Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Fri, 8 Dec 2023 17:12:16 +0100 Subject: [PATCH] cansniffer: unify setsockopt error handling Signed-off-by: Oliver Hartkopp --- isotpsniffer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/isotpsniffer.c b/isotpsniffer.c index 5764c66..04d9c88 100644 --- a/isotpsniffer.c +++ b/isotpsniffer.c @@ -302,7 +302,11 @@ int main(int argc, char **argv) goto out; } - setsockopt(s, SOL_CAN_ISOTP, CAN_ISOTP_OPTS, &opts, sizeof(opts)); + if (setsockopt(s, SOL_CAN_ISOTP, CAN_ISOTP_OPTS, &opts, sizeof(opts)) < 0) { + perror("setsockopt"); + r = 1; + goto out; + } if ((llopts.mtu) && (setsockopt(s, SOL_CAN_ISOTP, CAN_ISOTP_LL_OPTS, &llopts, sizeof(llopts))) < 0) { perror("setsockopt");