From 15dd23394344b005f9bb08ac3152fa9f19969641 Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Fri, 25 Oct 2024 11:37:13 +0200 Subject: [PATCH] lib: return error code if bf_send() fails bf_send() calls bf_send_request() and bf_recv_response(), both return non-zero on failure. While the success check is performed on their return value, once the error is logged errno is returned by bf_send(). Errno is not set by bf_send_request() not bf_recv_response(), effectively returning 0 from bf_send() and hiding the error. --- src/libbpfilter/generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libbpfilter/generic.c b/src/libbpfilter/generic.c index a2ac2af4..dcef79bf 100644 --- a/src/libbpfilter/generic.c +++ b/src/libbpfilter/generic.c @@ -35,11 +35,11 @@ int bf_send(const struct bf_request *request, struct bf_response **response) r = bf_send_request(fd, request); if (r < 0) - return bf_err(errno, "bpfilter: failed to send request to the daemon"); + return bf_err(r, "bpfilter: failed to send request to the daemon"); r = bf_recv_response(fd, response); if (r < 0) { - return bf_err(errno, + return bf_err(r, "bpfilter: failed to receive response from the daemon"); }