Use new printf features rather than local kludges.

This commit is contained in:
Poul-Henning Kamp 1996-01-24 21:12:23 +00:00
parent 120f078334
commit 1ce9bf88c3
11 changed files with 43 additions and 140 deletions

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: if_ed.c,v 1.91 1995/12/15 00:54:07 bde Exp $
* $Id: if_ed.c,v 1.92 1995/12/15 07:31:40 davidg Exp $
*/
/*
@ -1465,8 +1465,8 @@ ed_attach(isa_dev)
/*
* Print additional info when attached
*/
printf("ed%d: address %s, ", isa_dev->id_unit,
ether_sprintf(sc->arpcom.ac_enaddr));
printf("ed%d: address %6D, ", isa_dev->id_unit,
sc->arpcom.ac_enaddr, ":");
if (sc->type_str && (*sc->type_str != 0))
printf("type %s ", sc->type_str);

View File

@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: if_ed.c,v 1.91 1995/12/15 00:54:07 bde Exp $
* $Id: if_ed.c,v 1.92 1995/12/15 07:31:40 davidg Exp $
*/
/*
@ -1465,8 +1465,8 @@ ed_attach(isa_dev)
/*
* Print additional info when attached
*/
printf("ed%d: address %s, ", isa_dev->id_unit,
ether_sprintf(sc->arpcom.ac_enaddr));
printf("ed%d: address %6D, ", isa_dev->id_unit,
sc->arpcom.ac_enaddr, ":");
if (sc->type_str && (*sc->type_str != 0))
printf("type %s ", sc->type_str);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if.c 8.3 (Berkeley) 1/4/94
* $Id: if.c,v 1.24 1995/12/09 20:47:08 phk Exp $
* $Id: if.c,v 1.25 1995/12/20 21:53:38 wollman Exp $
*/
#include <sys/param.h>
@ -62,7 +62,6 @@ static void ifinit __P((void *));
static void if_qflush __P((struct ifqueue *));
static void if_slowtimo __P((void *));
static void link_rtrequest __P((int, struct rtentry *, struct sockaddr *));
static char *sprint_d __P((u_int, char *, int));
SYSINIT(interfaces, SI_SUB_PROTO_IF, SI_ORDER_FIRST, ifinit, NULL)
@ -104,8 +103,8 @@ if_attach(ifp)
struct ifnet *ifp;
{
unsigned socksize, ifasize;
int namelen, unitlen, masklen;
char workbuf[12], *unitname;
int namelen, masklen;
char workbuf[64];
register struct ifnet **p = &ifnet;
register struct sockaddr_dl *sdl;
register struct ifaddr *ifa;
@ -130,12 +129,9 @@ if_attach(ifp)
/*
* create a Link Level name for this device
*/
unitname = sprint_d((u_int)ifp->if_unit, workbuf, sizeof(workbuf));
namelen = strlen(ifp->if_name);
unitlen = strlen(unitname);
namelen = sprintf(workbuf, "%s%d", ifp->if_name, ifp->if_unit);
#define _offsetof(t, m) ((int)((caddr_t)&((t *)0)->m))
masklen = _offsetof(struct sockaddr_dl, sdl_data[0]) +
unitlen + namelen;
masklen = _offsetof(struct sockaddr_dl, sdl_data[0]) + namelen;
socksize = masklen + ifp->if_addrlen;
#define ROUNDUP(a) (1 + (((a) - 1) | (sizeof(long) - 1)))
socksize = ROUNDUP(socksize);
@ -148,9 +144,8 @@ if_attach(ifp)
sdl = (struct sockaddr_dl *)(ifa + 1);
sdl->sdl_len = socksize;
sdl->sdl_family = AF_LINK;
bcopy(ifp->if_name, sdl->sdl_data, namelen);
bcopy(unitname, namelen + (caddr_t)sdl->sdl_data, unitlen);
sdl->sdl_nlen = (namelen += unitlen);
bcopy(workbuf, sdl->sdl_data, namelen);
sdl->sdl_nlen = namelen;
sdl->sdl_index = ifp->if_index;
sdl->sdl_type = ifp->if_type;
ifnet_addrs[if_index - 1] = ifa;
@ -159,6 +154,7 @@ if_attach(ifp)
ifa->ifa_rtrequest = link_rtrequest;
ifp->if_addrlist = ifa;
ifa->ifa_addr = (struct sockaddr *)sdl;
sdl = (struct sockaddr_dl *)(socksize + (caddr_t)sdl);
ifa->ifa_netmask = (struct sockaddr *)sdl;
sdl->sdl_len = masklen;
@ -681,17 +677,14 @@ ifconf(cmd, data)
ifrp = ifc->ifc_req;
for (; space > sizeof (ifr) && ifp; ifp = ifp->if_next) {
char workbuf[12], *unitname;
int unitlen, ifnlen;
char workbuf[64];
int ifnlen;
unitname = sprint_d(ifp->if_unit, workbuf, sizeof workbuf);
unitlen = strlen(unitname);
ifnlen = strlen(ifp->if_name);
if(unitlen + ifnlen + 1 > sizeof ifr.ifr_name) {
ifnlen = sprintf(workbuf, "%s%d", ifp->if_name, ifp->if_unit);
if(ifnlen + 1 > sizeof ifr.ifr_name) {
error = ENAMETOOLONG;
} else {
strcpy(ifr.ifr_name, ifp->if_name);
strcpy(&ifr.ifr_name[ifnlen], unitname);
strcpy(ifr.ifr_name, workbuf);
}
if ((ifa = ifp->if_addrlist) == 0) {
@ -741,21 +734,4 @@ ifconf(cmd, data)
return (error);
}
static char *
sprint_d(n, buf, buflen)
u_int n;
char *buf;
int buflen;
{
register char *cp = buf + buflen - 1;
*cp = 0;
do {
cp--;
*cp = "0123456789"[n % 10];
n /= 10;
} while (n != 0);
return (cp);
}
SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers");

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
* $Id: if_ethersubr.c,v 1.12 1995/12/09 20:47:11 phk Exp $
* $Id: if_ethersubr.c,v 1.13 1995/12/20 21:53:40 wollman Exp $
*/
#include <sys/param.h>
@ -486,27 +486,6 @@ ether_input(ifp, eh, m)
splx(s);
}
/*
* Convert Ethernet address to printable (loggable) representation.
*/
static char digits[] = "0123456789abcdef";
char *
ether_sprintf(ap)
register u_char *ap;
{
register i;
static char etherbuf[18];
register char *cp = etherbuf;
for (i = 0; i < 6; i++) {
*cp++ = digits[*ap >> 4];
*cp++ = digits[*ap++ & 0xf];
*cp++ = ':';
}
*--cp = 0;
return (etherbuf);
}
/*
* Perform common duties while attaching to interface list
*/

View File

@ -69,7 +69,7 @@
* Paul Mackerras (paulus@cs.anu.edu.au).
*/
/* $Id: if_ppp.c,v 1.28 1995/11/13 22:09:39 peter Exp $ */
/* $Id: if_ppp.c,v 1.29 1995/12/14 09:53:13 phk Exp $ */
/* from if_ppp.c,v 1.5 1995/08/16 01:36:38 paulus Exp */
/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
@ -1413,7 +1413,6 @@ pppdumpm(m0)
char buf[3*MAX_DUMP_BYTES+4];
char *bp = buf;
struct mbuf *m;
static char digits[] = "0123456789abcdef";
for (m = m0; m; m = m->m_next) {
int l = m->m_len;
@ -1422,8 +1421,8 @@ pppdumpm(m0)
while (l--) {
if (bp > buf + sizeof(buf) - 4)
goto done;
*bp++ = digits[*rptr >> 4]; /* convert byte to ascii hex */
*bp++ = digits[*rptr++ & 0xf];
*bp++ = hex2ascii(*rptr >> 4);
*bp++ = hex2ascii(*rptr++ & 0xf);
}
if (m->m_next) {

View File

@ -70,7 +70,7 @@
* Paul Mackerras (paulus@cs.anu.edu.au).
*/
/* $Id: ppp_tty.c,v 1.3 1995/11/01 00:58:43 peter Exp $ */
/* $Id: ppp_tty.c,v 1.4 1995/12/14 09:53:20 phk Exp $ */
/* from Id: ppp_tty.c,v 1.3 1995/08/16 01:36:40 paulus Exp */
/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
@ -134,7 +134,6 @@ static void pppasyncrelinq __P((struct ppp_softc *));
static void pppasyncsetmtu __P((struct ppp_softc *));
static void ppp_timeout __P((void *));
static void pppgetm __P((struct ppp_softc *sc));
static void pppdumpb __P((u_char *b, int l));
static void ppplogchar __P((struct ppp_softc *, int));
/*
@ -1100,33 +1099,10 @@ ppplogchar(sc, c)
sc->sc_rawin[sc->sc_rawin_count++] = c;
if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
|| c < 0 && sc->sc_rawin_count > 0) {
printf("ppp%d input: ", sc->sc_if.if_unit);
pppdumpb(sc->sc_rawin, sc->sc_rawin_count);
printf("ppp%d input: %*D", sc->sc_if.if_unit,
sc->sc_rawin_count, sc->sc_rawin, " ");
sc->sc_rawin_count = 0;
}
}
static void
pppdumpb(b, l)
u_char *b;
int l;
{
char buf[3*MAX_DUMP_BYTES+4];
char *bp = buf;
static char digits[] = "0123456789abcdef";
while (l--) {
if (bp >= buf + sizeof(buf) - 3) {
*bp++ = '>';
break;
}
*bp++ = digits[*b >> 4]; /* convert byte to ascii hex */
*bp++ = digits[*b++ & 0xf];
*bp++ = ' ';
}
*bp = 0;
printf("%s\n", buf);
}
#endif /* NPPP > 0 */

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_ether.c 8.1 (Berkeley) 6/10/93
* $Id: if_ether.c,v 1.24 1995/12/16 00:05:40 bde Exp $
* $Id: if_ether.c,v 1.25 1995/12/20 21:53:51 wollman Exp $
*/
/*
@ -465,8 +465,8 @@ in_arpinput(m)
}
if (isaddr.s_addr == myaddr.s_addr) {
log(LOG_ERR,
"duplicate IP address %s! sent from ethernet address: %s\n",
inet_ntoa(isaddr), ether_sprintf(ea->arp_sha));
"duplicate IP address %s! sent from ethernet address: %6D\n",
inet_ntoa(isaddr), ea->arp_sha, ":");
itaddr = myaddr;
goto reply;
}
@ -474,8 +474,8 @@ in_arpinput(m)
if (la && (rt = la->la_rt) && (sdl = SDL(rt->rt_gateway))) {
if (sdl->sdl_alen &&
bcmp((caddr_t)ea->arp_sha, LLADDR(sdl), sdl->sdl_alen))
log(LOG_INFO, "arp info overwritten for %s by %s\n",
inet_ntoa(isaddr), ether_sprintf(ea->arp_sha));
log(LOG_INFO, "arp info overwritten for %s by %6D\n",
inet_ntoa(isaddr), ea->arp_sha, ":");
(void)memcpy(LLADDR(sdl), ea->arp_sha, sizeof(ea->arp_sha));
sdl->sdl_alen = sizeof(ea->arp_sha);
if (rt->rt_expire)

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)clnp_debug.c 8.1 (Berkeley) 6/10/93
* $Id: clnp_debug.c,v 1.2 1994/08/02 07:49:35 davidg Exp $
* $Id: clnp_debug.c,v 1.3 1995/05/30 08:10:14 rgrimes Exp $
*/
/***********************************************************
@ -60,7 +60,7 @@ SOFTWARE.
/*
* ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
*/
/* $Header: /home/ncvs/src/sys/netiso/clnp_debug.c,v 1.2 1994/08/02 07:49:35 davidg Exp $ */
/* $Header: /home/ncvs/src/sys/netiso/clnp_debug.c,v 1.3 1995/05/30 08:10:14 rgrimes Exp $ */
/* $Source: /home/ncvs/src/sys/netiso/clnp_debug.c,v $ */
#include <sys/param.h>
@ -133,7 +133,6 @@ main()
#endif /* TESTDEBUG */
unsigned int clnp_debug;
static char letters[] = "0123456789abcdef";
/*
* Print buffer in hex, return addr of where we left off.
@ -149,8 +148,8 @@ char *where; /* where to put data */
for (i=0; i<len; i++) {
register int j = ((u_char *)src)[i];
*where++ = letters[j >> 4];
*where++ = letters[j & 0x0f];
*where++ = hex2ascii[j >> 4];
*where++ = hex2ascii[j & 0x0f];
}
return where;
}

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94
* $Id: nfs_vnops.c,v 1.30 1995/11/21 15:51:39 bde Exp $
* $Id: nfs_vnops.c,v 1.31 1995/12/07 12:47:29 davidg Exp $
*/
/*
@ -2447,7 +2447,6 @@ nfs_readdirplusrpc(vp, uiop, cred)
}
return (error);
}
static char hextoasc[] = "0123456789abcdef";
/*
* Silly rename. To make the NFS filesystem that is stateless look a little
@ -2481,12 +2480,7 @@ nfs_sillyrename(dvp, vp, cnp)
/* Fudge together a funny name */
pid = cnp->cn_proc->p_pid;
bcopy(".nfsAxxxx4.4", sp->s_name, 13);
sp->s_namlen = 12;
sp->s_name[8] = hextoasc[pid & 0xf];
sp->s_name[7] = hextoasc[(pid >> 4) & 0xf];
sp->s_name[6] = hextoasc[(pid >> 8) & 0xf];
sp->s_name[5] = hextoasc[(pid >> 12) & 0xf];
sp->s_namelen = sprintf(sp->s_name, ".nfsA%04x4.4", pid);
/* Try lookitups until we get one that isn't there */
while (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred,

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* @(#)nfs_vnops.c 8.5 (Berkeley) 2/13/94
* $Id: nfs_vnops.c,v 1.30 1995/11/21 15:51:39 bde Exp $
* $Id: nfs_vnops.c,v 1.31 1995/12/07 12:47:29 davidg Exp $
*/
/*
@ -2447,7 +2447,6 @@ nfs_readdirplusrpc(vp, uiop, cred)
}
return (error);
}
static char hextoasc[] = "0123456789abcdef";
/*
* Silly rename. To make the NFS filesystem that is stateless look a little
@ -2481,12 +2480,7 @@ nfs_sillyrename(dvp, vp, cnp)
/* Fudge together a funny name */
pid = cnp->cn_proc->p_pid;
bcopy(".nfsAxxxx4.4", sp->s_name, 13);
sp->s_namlen = 12;
sp->s_name[8] = hextoasc[pid & 0xf];
sp->s_name[7] = hextoasc[(pid >> 4) & 0xf];
sp->s_name[6] = hextoasc[(pid >> 8) & 0xf];
sp->s_name[5] = hextoasc[(pid >> 12) & 0xf];
sp->s_namelen = sprintf(sp->s_name, ".nfsA%04x4.4", pid);
/* Try lookitups until we get one that isn't there */
while (nfs_lookitup(dvp, sp->s_name, sp->s_namlen, sp->s_cred,

View File

@ -21,7 +21,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: pdq.c,v 1.6 1995/10/29 15:33:31 phk Exp $
* $Id: pdq.c,v 1.7 1996/01/24 20:01:27 wollman Exp $
*
* Revision 1.8 1995/03/14 01:52:52 thomas
* Update for new FreeBSD PCI Interrupt interface
@ -200,28 +200,14 @@ pdq_print_fddi_chars(
pdq_t *pdq,
const pdq_response_status_chars_get_t *rsp)
{
const char hexchars[] = "0123456789abcdef";
printf(PDQ_OS_PREFIX "DEC %s FDDI %s Controller\n",
PDQ_OS_PREFIX_ARGS, pdq_descriptions[pdq->pdq_type],
pdq_station_types[rsp->status_chars_get.station_type]);
printf(PDQ_OS_PREFIX "FDDI address %c%c:%c%c:%c%c:%c%c:%c%c:%c%c, FW=%c%c%c%c, HW=%c",
PDQ_OS_PREFIX_ARGS,
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[0] >> 4],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[0] & 0x0F],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[1] >> 4],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[1] & 0x0F],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[2] >> 4],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[2] & 0x0F],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[3] >> 4],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[3] & 0x0F],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[4] >> 4],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[4] & 0x0F],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[5] >> 4],
hexchars[pdq->pdq_hwaddr.lanaddr_bytes[5] & 0x0F],
pdq->pdq_fwrev.fwrev_bytes[0], pdq->pdq_fwrev.fwrev_bytes[1],
pdq->pdq_fwrev.fwrev_bytes[2], pdq->pdq_fwrev.fwrev_bytes[3],
printf(PDQ_OS_PREFIX "FDDI address %6D, FW=%4.4s, HW=%c",
PDQ_OS_PREFIX_ARGS, pdq->pdq_hwaddr.lanaddr_bytes, ":",
pdq->pdq_fwrev.fwrev_bytes,
rsp->status_chars_get.module_rev.fwrev_bytes[0]);
if (rsp->status_chars_get.smt_version_id < PDQ_ARRAY_SIZE(pdq_smt_versions)) {