From ce531f97ec256e753f1750067ffe4eb30c25fa85 Mon Sep 17 00:00:00 2001 From: ae Date: Thu, 23 Jan 2014 19:31:17 +0000 Subject: Fix typo in r261084. Add to the gctl_error() an ability to specify error description even if numeric error code is already specified. Also by default set error code to EINVAL. PR: 185852 MFC after: 1 week --- sys/geom/geom_ctl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sys/geom/geom_ctl.c b/sys/geom/geom_ctl.c index afdce69..51f49c3 100644 --- a/sys/geom/geom_ctl.c +++ b/sys/geom/geom_ctl.c @@ -84,8 +84,8 @@ g_ctl_init(void) } /* - * Report an error back to the user in ascii format. Return whatever copyout - * returned, or EINVAL if it succeeded. + * Report an error back to the user in ascii format. Return nerror + * or EINVAL if nerror isn't specified. */ int gctl_error(struct gctl_req *req, const char *fmt, ...) @@ -99,9 +99,10 @@ gctl_error(struct gctl_req *req, const char *fmt, ...) if (sbuf_done(req->serror)) { if (!req->nerror) req->nerror = EEXIST; - } - if (req->nerror) return (req->nerror); + } + if (!req->nerror) + req->nerror = EINVAL; va_start(ap, fmt); sbuf_vprintf(req->serror, fmt, ap); @@ -109,7 +110,7 @@ gctl_error(struct gctl_req *req, const char *fmt, ...) sbuf_finish(req->serror); if (g_debugflags & G_F_CTLDUMP) printf("gctl %p error \"%s\"\n", req, sbuf_data(req->serror)); - return (0); + return (req->nerror); } /* @@ -122,7 +123,7 @@ geom_alloc_copyin(struct gctl_req *req, void *uaddr, size_t len) void *ptr; ptr = g_malloc(len, M_WAITOK); - nreq->nerror = copyin(uaddr, ptr, len); + req->nerror = copyin(uaddr, ptr, len); if (!req->nerror) return (ptr); if (ptr != NULL) -- cgit v1.1