Strip %b and DDB formats out of kprintf, as they are no longer supported.
This commit is contained in:
parent
8bd030c63a
commit
5b0a45ec9b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_prf.c,v 1.75 2000/07/04 15:33:31 jdolecek Exp $ */
|
||||
/* $NetBSD: subr_prf.c,v 1.76 2000/08/09 10:22:31 tv Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1986, 1988, 1991, 1993
|
||||
@ -121,7 +121,7 @@ do { \
|
||||
#define TOCONS 0x01 /* to the console */
|
||||
#define TOTTY 0x02 /* to the process' tty */
|
||||
#define TOLOG 0x04 /* to the kernel message buffer */
|
||||
#define TOBUFONLY 0x08 /* to the buffer (only) [for sprintf] */
|
||||
#define TOBUFONLY 0x08 /* to the buffer (only) [for snprintf] */
|
||||
#define TODDB 0x10 /* to ddb console */
|
||||
|
||||
/* max size buffer kprintf needs to print quad_t [size in base 8 + \0] */
|
||||
@ -331,7 +331,7 @@ klogpri(level)
|
||||
char snbuf[KPRINTF_BUFSIZE];
|
||||
|
||||
putchar('<', TOLOG, NULL);
|
||||
sprintf(snbuf, "%d", level);
|
||||
snprintf(snbuf, sizeof(snbuf), "%d", level);
|
||||
for (p = snbuf ; *p ; p++)
|
||||
putchar(*p, TOLOG, NULL);
|
||||
putchar('>', TOLOG, NULL);
|
||||
@ -587,7 +587,7 @@ db_printf(fmt, va_alist)
|
||||
|
||||
|
||||
/*
|
||||
* normal kernel printf functions: printf, vprintf, sprintf
|
||||
* normal kernel printf functions: printf, vprintf, snprintf, vsnprintf
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -729,10 +729,9 @@ vsnprintf(buf, size, fmt, ap)
|
||||
}
|
||||
|
||||
/*
|
||||
* bitmask_snprintf: print a kernel-printf "%b" message to a buffer
|
||||
* bitmask_snprintf: print an interpreted bitmask to a buffer
|
||||
*
|
||||
* => returns pointer to the buffer
|
||||
* => XXX: useful vs. kernel %b?
|
||||
*/
|
||||
char *
|
||||
bitmask_snprintf(val, p, buf, buflen)
|
||||
@ -768,7 +767,7 @@ bitmask_snprintf(val, p, buf, buflen)
|
||||
if (sbase == 0)
|
||||
return (buf); /* punt if not oct, dec, or hex */
|
||||
|
||||
sprintf(snbuf, sbase, val);
|
||||
snprintf(snbuf, sizeof(snbuf), sbase, val);
|
||||
for (q = snbuf ; *q ; q++) {
|
||||
*bp++ = *q;
|
||||
left--;
|
||||
@ -795,11 +794,11 @@ bitmask_snprintf(val, p, buf, buflen)
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* Chris Torek's new style %b format is identified by a leading \177
|
||||
* Chris Torek's new bitmask format is identified by a leading \177
|
||||
*/
|
||||
sep = '<';
|
||||
if (ch != '\177') {
|
||||
/* old (standard) %b format. */
|
||||
/* old (standard) format. */
|
||||
for (;(bit = *p++) != 0;) {
|
||||
if (val & (1 << (bit - 1))) {
|
||||
PUTBYTE(bp, sep, left);
|
||||
@ -812,7 +811,7 @@ bitmask_snprintf(val, p, buf, buflen)
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
/* new quad-capable %b format; also does fields. */
|
||||
/* new quad-capable format; also does fields. */
|
||||
field = val;
|
||||
while ((ch = *p++) != '\0') {
|
||||
bit = *p++; /* now 0-origin */
|
||||
@ -875,41 +874,7 @@ out:
|
||||
* this version based on vfprintf() from libc which was derived from
|
||||
* software contributed to Berkeley by Chris Torek.
|
||||
*
|
||||
* Two additional formats:
|
||||
*
|
||||
* The format %b is supported to decode error registers.
|
||||
* Its usage is:
|
||||
*
|
||||
* printf("reg=%b\n", regval, "<base><arg>*");
|
||||
*
|
||||
* where <base> is the output base expressed as a control character, e.g.
|
||||
* \10 gives octal; \20 gives hex. Each arg is a sequence of characters,
|
||||
* the first of which gives the bit number to be inspected (origin 1), and
|
||||
* the next characters (up to a control character, i.e. a character <= 32),
|
||||
* give the name of the register. Thus:
|
||||
*
|
||||
* kprintf("reg=%b\n", 3, "\10\2BITTWO\1BITONE\n");
|
||||
*
|
||||
* would produce output:
|
||||
*
|
||||
* reg=3<BITTWO,BITONE>
|
||||
*
|
||||
* The format %: passes an additional format string and argument list
|
||||
* recursively. Its usage is:
|
||||
*
|
||||
* fn(char *fmt, ...)
|
||||
* {
|
||||
* va_list ap;
|
||||
* va_start(ap, fmt);
|
||||
* printf("prefix: %: suffix\n", fmt, ap);
|
||||
* va_end(ap);
|
||||
* }
|
||||
*
|
||||
* this is the actual printf innards
|
||||
*
|
||||
* This code is large and complicated...
|
||||
*
|
||||
* NOTE: The kprintf mutex must be held of we're going TOBUF or TOCONS!
|
||||
* NOTE: The kprintf mutex must be held if we're going TOBUF or TOCONS!
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -1022,94 +987,6 @@ kprintf(fmt0, oflags, vp, sbuf, ap)
|
||||
|
||||
rflag: ch = *fmt++;
|
||||
reswitch: switch (ch) {
|
||||
/* XXX: non-standard '%:' format */
|
||||
#ifndef __powerpc__
|
||||
case ':':
|
||||
if (oflags != TOBUFONLY) {
|
||||
cp = va_arg(ap, char *);
|
||||
kprintf(cp, oflags, vp,
|
||||
NULL, va_arg(ap, va_list));
|
||||
}
|
||||
continue; /* no output */
|
||||
#endif
|
||||
/* XXX: non-standard '%b' format */
|
||||
case 'b': {
|
||||
char *b, *z;
|
||||
int tmp;
|
||||
_uquad = va_arg(ap, int);
|
||||
b = va_arg(ap, char *);
|
||||
if (*b == 8)
|
||||
sprintf(buf, "%qo", (unsigned long long)_uquad);
|
||||
else if (*b == 10)
|
||||
sprintf(buf, "%qd", (unsigned long long)_uquad);
|
||||
else if (*b == 16)
|
||||
sprintf(buf, "%qx", (unsigned long long)_uquad);
|
||||
else
|
||||
break;
|
||||
b++;
|
||||
|
||||
z = buf;
|
||||
while (*z) {
|
||||
ret++;
|
||||
KPRINTF_PUTCHAR(*z++);
|
||||
}
|
||||
|
||||
if (_uquad) {
|
||||
tmp = 0;
|
||||
while ((n = *b++) != 0) {
|
||||
if (_uquad & (1 << (n - 1))) {
|
||||
ret++;
|
||||
KPRINTF_PUTCHAR(tmp ? ',':'<');
|
||||
while ((n = *b) > ' ') {
|
||||
ret++;
|
||||
KPRINTF_PUTCHAR(n);
|
||||
b++;
|
||||
}
|
||||
tmp = 1;
|
||||
} else {
|
||||
while(*b > ' ')
|
||||
b++;
|
||||
}
|
||||
}
|
||||
if (tmp) {
|
||||
ret++;
|
||||
KPRINTF_PUTCHAR('>');
|
||||
}
|
||||
}
|
||||
continue; /* no output */
|
||||
}
|
||||
|
||||
#ifdef DDB
|
||||
/* XXX: non-standard '%r' format (print int in db_radix) */
|
||||
case 'r':
|
||||
if (db_radix == 16)
|
||||
goto case_z; /* signed hex */
|
||||
_uquad = SARG();
|
||||
if ((quad_t)_uquad < 0) {
|
||||
_uquad = -_uquad;
|
||||
sign = '-';
|
||||
}
|
||||
base = (db_radix == 8) ? OCT : DEC;
|
||||
goto number;
|
||||
|
||||
|
||||
/* XXX: non-standard '%z' format ("signed hex", a "hex %i")*/
|
||||
case 'z':
|
||||
case_z:
|
||||
xdigs = "0123456789abcdef";
|
||||
ch = 'x'; /* the 'x' in '0x' (below) */
|
||||
_uquad = SARG();
|
||||
base = HEX;
|
||||
/* leading 0x/X only if non-zero */
|
||||
if (flags & ALT && _uquad != 0)
|
||||
flags |= HEXPREFIX;
|
||||
if ((quad_t)_uquad < 0) {
|
||||
_uquad = -_uquad;
|
||||
sign = '-';
|
||||
}
|
||||
goto number;
|
||||
#endif
|
||||
|
||||
case ' ':
|
||||
/*
|
||||
* ``If the space and + flags both appear, the space
|
||||
@ -1201,28 +1078,6 @@ reswitch: switch (ch) {
|
||||
base = DEC;
|
||||
goto number;
|
||||
case 'n':
|
||||
#ifdef DDB
|
||||
/* XXX: non-standard '%n' format */
|
||||
/*
|
||||
* XXX: HACK! DDB wants '%n' to be a '%u' printed
|
||||
* in db_radix format. this should die since '%n'
|
||||
* is already defined in standard printf to write
|
||||
* the number of chars printed so far to the arg (which
|
||||
* should be a pointer.
|
||||
*/
|
||||
if (oflags & TODDB) {
|
||||
if (db_radix == 16)
|
||||
ch = 'x'; /* convert to %x */
|
||||
else if (db_radix == 8)
|
||||
ch = 'o'; /* convert to %o */
|
||||
else
|
||||
ch = 'u'; /* convert to %u */
|
||||
|
||||
/* ... and start again */
|
||||
goto reswitch;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (flags & QUADINT)
|
||||
*va_arg(ap, quad_t *) = ret;
|
||||
else if (flags & LONGINT)
|
||||
|
Loading…
Reference in New Issue
Block a user