From owner-svn-src-stable-11@freebsd.org Sun Jun 10 22:26:18 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D611D101177B; Sun, 10 Jun 2018 22:26:17 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8355C7BC3F; Sun, 10 Jun 2018 22:26:17 +0000 (UTC) (envelope-from ian@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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 645AE12E91; Sun, 10 Jun 2018 22:26:17 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w5AMQH29098739; Sun, 10 Jun 2018 22:26:17 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w5AMQFgJ098732; Sun, 10 Jun 2018 22:26:15 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201806102226.w5AMQFgJ098732@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Sun, 10 Jun 2018 22:26:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r334935 - in stable/11/stand: common i386/libi386 libsa uboot/lib userboot/userboot zfs X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11/stand: common i386/libi386 libsa uboot/lib userboot/userboot zfs X-SVN-Commit-Revision: 334935 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Jun 2018 22:26:18 -0000 Author: ian Date: Sun Jun 10 22:26:15 2018 New Revision: 334935 URL: https://svnweb.freebsd.org/changeset/base/334935 Log: MFC r334656, r334665, r334695 r334656: Add vsnprintf() to libsa. Alpha-sort the printf prototypes in stand.h. r334665: Make the v*printf() functions in libsa return int instead of void. This makes them compatible with the C standard signatures, avoiding spurious mismatch errors in the places where the oddball requirements of standalone code end up putting two declarations of the same function in play. r334695: Remove comments and assertions that are no longer valid after r330809. r330809 replaced duplication of devdesc struct fields with an embedded copy of the devdesc struct, to avoid fragility. That means all the scattered comments indicating that structs must match are no longer valid. Likewise asserts that attempted to mitigate some of the old fragility. Reviewed by: imp@ Modified: stable/11/stand/common/disk.h stable/11/stand/i386/libi386/biosdisk.c stable/11/stand/i386/libi386/libi386.h stable/11/stand/libsa/printf.c stable/11/stand/libsa/stand.h stable/11/stand/uboot/lib/libuboot.h stable/11/stand/userboot/userboot/main.c stable/11/stand/zfs/libzfs.h Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/common/disk.h ============================================================================== --- stable/11/stand/common/disk.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/common/disk.h Sun Jun 10 22:26:15 2018 (r334935) @@ -81,9 +81,8 @@ #ifndef _DISK_H #define _DISK_H -/* Note: Must match the 'struct devdesc' in stand.h */ struct disk_devdesc { - struct devdesc dd; + struct devdesc dd; /* Must be first. */ int d_slice; int d_partition; uint64_t d_offset; Modified: stable/11/stand/i386/libi386/biosdisk.c ============================================================================== --- stable/11/stand/i386/libi386/biosdisk.c Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/i386/libi386/biosdisk.c Sun Jun 10 22:26:15 2018 (r334935) @@ -78,8 +78,6 @@ struct ptable { #include "geliboot.c" #endif /* LOADER_GELI_SUPPORT */ -CTASSERT(sizeof(struct i386_devdesc) >= sizeof(struct disk_devdesc)); - #define BIOS_NUMDRIVES 0x475 #define BIOSDISK_SECSIZE 512 #define BUFSIZE (1 * BIOSDISK_SECSIZE) Modified: stable/11/stand/i386/libi386/libi386.h ============================================================================== --- stable/11/stand/i386/libi386/libi386.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/i386/libi386/libi386.h Sun Jun 10 22:26:15 2018 (r334935) @@ -29,11 +29,9 @@ /* * i386 fully-qualified device descriptor. - * Note, this must match struct zfs_devdesc for zfs support. */ -/* Note: Must match the 'struct devdesc' in stand.h */ struct i386_devdesc { - struct devdesc dd; + struct devdesc dd; /* Must be first. */ union { struct Modified: stable/11/stand/libsa/printf.c ============================================================================== --- stable/11/stand/libsa/printf.c Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/libsa/printf.c Sun Jun 10 22:26:15 2018 (r334935) @@ -80,11 +80,11 @@ printf(const char *fmt, ...) return retval; } -void +int vprintf(const char *fmt, va_list ap) { - kvprintf(fmt, putchar_wrapper, NULL, 10, ap); + return (kvprintf(fmt, putchar_wrapper, NULL, 10, ap)); } int @@ -140,13 +140,32 @@ snprintf(char *buf, size_t size, const char *cfmt, ... return retval; } -void +int +vsnprintf(char *buf, size_t size, const char *cfmt, va_list ap) +{ + struct print_buf arg; + int retval; + + arg.buf = buf; + arg.size = size; + + retval = kvprintf(cfmt, &snprint_func, &arg, 10, ap); + + if (arg.size >= 1) + *(arg.buf)++ = 0; + + return (retval); +} + +int vsprintf(char *buf, const char *cfmt, va_list ap) { int retval; retval = kvprintf(cfmt, NULL, (void *)buf, 10, ap); buf[retval] = '\0'; + + return (retval); } /* Modified: stable/11/stand/libsa/stand.h ============================================================================== --- stable/11/stand/libsa/stand.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/libsa/stand.h Sun Jun 10 22:26:15 2018 (r334935) @@ -268,10 +268,11 @@ extern void *reallocf(void *ptr, size_t size); extern void mallocstats(void); extern int printf(const char *fmt, ...) __printflike(1, 2); -extern void vprintf(const char *fmt, __va_list); extern int sprintf(char *buf, const char *cfmt, ...) __printflike(2, 3); extern int snprintf(char *buf, size_t size, const char *cfmt, ...) __printflike(3, 4); -extern void vsprintf(char *buf, const char *cfmt, __va_list); +extern int vprintf(const char *fmt, __va_list); +extern int vsprintf(char *buf, const char *cfmt, __va_list); +extern int vsnprintf(char *buf, size_t size, const char *cfmt, __va_list); extern void twiddle(u_int callerdiv); extern void twiddle_divisor(u_int globaldiv); Modified: stable/11/stand/uboot/lib/libuboot.h ============================================================================== --- stable/11/stand/uboot/lib/libuboot.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/uboot/lib/libuboot.h Sun Jun 10 22:26:15 2018 (r334935) @@ -27,9 +27,8 @@ * $FreeBSD$ */ -/* Note: Must match the 'struct devdesc' in stand.h */ struct uboot_devdesc { - struct devdesc dd; + struct devdesc dd; /* Must be first. */ union { struct { int slice; Modified: stable/11/stand/userboot/userboot/main.c ============================================================================== --- stable/11/stand/userboot/userboot/main.c Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/userboot/userboot/main.c Sun Jun 10 22:26:15 2018 (r334935) @@ -159,7 +159,6 @@ extract_currdev(void) //bzero(&dev, sizeof(dev)); #if defined(USERBOOT_ZFS_SUPPORT) - CTASSERT(sizeof(struct disk_devdesc) >= sizeof(struct zfs_devdesc)); if (userboot_zfs_found) { struct zfs_devdesc zdev; Modified: stable/11/stand/zfs/libzfs.h ============================================================================== --- stable/11/stand/zfs/libzfs.h Sun Jun 10 22:11:51 2018 (r334934) +++ stable/11/stand/zfs/libzfs.h Sun Jun 10 22:26:15 2018 (r334935) @@ -33,12 +33,9 @@ /* * ZFS fully-qualified device descriptor. - * Arch-specific device descriptors should be binary compatible with this - * structure if they are to support ZFS. */ -/* Note: Must match the 'struct devdesc' in stand.h */ struct zfs_devdesc { - struct devdesc dd; + struct devdesc dd; /* Must be first. */ uint64_t pool_guid; uint64_t root_guid; };