svn commit: r334935 - in stable/11/stand: common i386/libi386 libsa uboot/lib userboot/userboot zfs
Ian Lepore
ian at FreeBSD.org
Sun Jun 10 22:26:18 UTC 2018
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;
};
More information about the svn-src-all
mailing list