From owner-svn-src-all@freebsd.org Sun Nov 26 10:02:44 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 959E6DBB32F; Sun, 26 Nov 2017 10:02:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6C98866244; Sun, 26 Nov 2017 10:02:44 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAQA2hxw064363; Sun, 26 Nov 2017 10:02:43 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAQA2hTU064362; Sun, 26 Nov 2017 10:02:43 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201711261002.vAQA2hTU064362@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 26 Nov 2017 10:02:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326226 - head/sbin/sysctl X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: head/sbin/sysctl X-SVN-Commit-Revision: 326226 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Nov 2017 10:02:44 -0000 Author: kib Date: Sun Nov 26 10:02:43 2017 New Revision: 326226 URL: https://svnweb.freebsd.org/changeset/base/326226 Log: Improve sysctl(8) pretty printing of some structures. S_vmtotal: Use unsigned format to print unsigned memory counters from struct vmtotal. Remove unneeded cast, style locals declarations. S_efi_map: Make printing of the memory regions descriptions less MD by using uintmax_t formats. Noted by and discussed with: bde Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sbin/sysctl/sysctl.c Modified: head/sbin/sysctl/sysctl.c ============================================================================== --- head/sbin/sysctl/sysctl.c Sun Nov 26 09:29:34 2017 (r326225) +++ head/sbin/sysctl/sysctl.c Sun Nov 26 10:02:43 2017 (r326226) @@ -608,33 +608,33 @@ S_timeval(size_t l2, void *p) static int S_vmtotal(size_t l2, void *p) { - struct vmtotal *v = (struct vmtotal *)p; - int pageKilo = getpagesize() / 1024; + struct vmtotal *v; + int pageKilo; if (l2 != sizeof(*v)) { warnx("S_vmtotal %zu != %zu", l2, sizeof(*v)); return (1); } - printf( - "\nSystem wide totals computed every five seconds:" + v = p; + pageKilo = getpagesize() / 1024; + +#define pg2k(a) ((uintmax_t)(a) * pageKilo) + printf("\nSystem wide totals computed every five seconds:" " (values in kilobytes)\n"); printf("===============================================\n"); - printf( - "Processes:\t\t(RUNQ: %hd Disk Wait: %hd Page Wait: " - "%hd Sleep: %hd)\n", + printf("Processes:\t\t(RUNQ: %d Disk Wait: %d Page Wait: " + "%d Sleep: %d)\n", v->t_rq, v->t_dw, v->t_pw, v->t_sl); - printf( - "Virtual Memory:\t\t(Total: %jdK Active: %jdK)\n", - (intmax_t)v->t_vm * pageKilo, (intmax_t)v->t_avm * pageKilo); - printf("Real Memory:\t\t(Total: %jdK Active: %jdK)\n", - (intmax_t)v->t_rm * pageKilo, (intmax_t)v->t_arm * pageKilo); - printf("Shared Virtual Memory:\t(Total: %jdK Active: %jdK)\n", - (intmax_t)v->t_vmshr * pageKilo, (intmax_t)v->t_avmshr * pageKilo); - printf("Shared Real Memory:\t(Total: %jdK Active: %jdK)\n", - (intmax_t)v->t_rmshr * pageKilo, (intmax_t)v->t_armshr * pageKilo); - printf("Free Memory:\t%jdK", (intmax_t)v->t_free * pageKilo); - + printf("Virtual Memory:\t\t(Total: %juK Active: %juK)\n", + pg2k(v->t_vm), pg2k(v->t_avm)); + printf("Real Memory:\t\t(Total: %juK Active: %juK)\n", + pg2k(v->t_rm), pg2k(v->t_arm)); + printf("Shared Virtual Memory:\t(Total: %juK Active: %juK)\n", + pg2k(v->t_vmshr), pg2k(v->t_avmshr)); + printf("Shared Real Memory:\t(Total: %juK Active: %juK)\n", + pg2k(v->t_rmshr), pg2k(v->t_armshr)); + printf("Free Memory:\t%juK", pg2k(v->t_free)); return (0); } @@ -695,8 +695,9 @@ S_efi_map(size_t l2, void *p) type = types[map->md_type]; else type = ""; - printf("\n%23s %012lx %12p %08lx ", type, map->md_phys, - map->md_virt, map->md_pages); + printf("\n%23s %012jx %12p %08jx ", type, + (uintmax_t)map->md_phys, map->md_virt, + (uintmax_t)map->md_pages); if (map->md_attr & EFI_MD_ATTR_UC) printf("UC "); if (map->md_attr & EFI_MD_ATTR_WC)