git: 58cb3626762d - main - Fix for 90e2971 that caused some geli commands to return the wrong exit status.

From: Kirk McKusick <mckusick_at_FreeBSD.org>
Date: Fri, 29 Jul 2022 18:12:10 UTC
The branch main has been updated by mckusick:

URL: https://cgit.FreeBSD.org/src/commit/?id=58cb3626762d8ec9c499a664223190648479fc5a

commit 58cb3626762d8ec9c499a664223190648479fc5a
Author:     Kirk McKusick <mckusick@FreeBSD.org>
AuthorDate: 2022-07-29 18:11:09 +0000
Commit:     Kirk McKusick <mckusick@FreeBSD.org>
CommitDate: 2022-07-29 18:11:46 +0000

    Fix for 90e2971 that caused some geli commands to return the wrong exit status.
    
    The reported problem is that some geli commands exit with a
    success status when they should exit with a failed status.
    
    The gctl_error() function is defined differently in the kernel
    (in sys/geom/geom_ctl.c) versus in the geom user facilities (in
    sbin/geom/misc/subr.c). In the kernel, calling gctl_error() causes
    an error return to be set while in the user version it does not.
    It was only by a quirk that had been added to the user geom return
    processing that I "cleaned up" that the lack of the user implementaion
    to set the error return showed up.
    
    This patch adds the missing setting of the error code when calling
    the user facility gctl_error().
    
    Reported by:  Jenkins
    Debugging by: Alan Somers
    Debugging by: Cy Schubert
    Debugging by: Li-Wen Hsu
---
 sbin/geom/misc/subr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sbin/geom/misc/subr.c b/sbin/geom/misc/subr.c
index 3985ae56edc6..297a1cc09a36 100644
--- a/sbin/geom/misc/subr.c
+++ b/sbin/geom/misc/subr.c
@@ -398,6 +398,8 @@ gctl_error(struct gctl_req *req, const char *error, ...)
 		fprintf(stderr, "\n");
 	}
 	va_end(ap);
+	if (req != NULL && req->nerror == 0)
+		req->nerror = EINVAL;
 }
 
 static void *