Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 14 Oct 2023 00:03:26 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f0101a0ef9ad - releng/14.0 - sysctl: emit a newline after NULL node descriptions
Message-ID:  <202310140003.39E03Qns050562@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/14.0 has been updated by emaste:

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

commit f0101a0ef9adac0d0ceb5b77de74f51cd24ea906
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-10-06 18:00:30 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-10-13 23:18:14 +0000

    sysctl: emit a newline after NULL node descriptions
    
    Previously when printing the sysctl description (via the -d flag) we
    omitted the newline if the node provided no description (i.e., NULL).
    This could be observed via e.g. `sysctl -d dev`.
    
    PR:             44034
    Reviewed by:    zlei
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D42112
    
    (cherry picked from commit 75be7e30271bb192fd27698982f2c7e56831eeef)
    (cherry picked from commit ced9fe051e31f858a9d1dbec01cf6dec483fab19)
    
    Approved by:    re (gjb)
---
 sbin/sysctl/sysctl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sbin/sysctl/sysctl.c b/sbin/sysctl/sysctl.c
index fe1a53a9d645..7ed7be95c9a5 100644
--- a/sbin/sysctl/sysctl.c
+++ b/sbin/sysctl/sysctl.c
@@ -998,8 +998,10 @@ show_info(char *name, const char *sep, int ctltype, char *fmt, int *qoid, int nl
 	bzero(buf, BUFSIZ);
 	j = sizeof(buf);
 	i = sysctl(qoid, nlen + 2, buf, &j, 0, 0);
-	if (i < 0)
+	if (i < 0) {
+		putchar('\n');
 		return (1);
+	}
 	fputs(buf, stdout);
 	return (error);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310140003.39E03Qns050562>