Pass the buffer size to PROM_getpropstringA(), as in sparc.

This commit is contained in:
pk 2004-03-17 15:22:57 +00:00
parent 370bb883e5
commit fcac5c14aa
3 changed files with 17 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sbus.c,v 1.65 2003/11/09 14:28:56 martin Exp $ */
/* $NetBSD: sbus.c,v 1.66 2004/03/17 15:22:57 pk Exp $ */
/*
* Copyright (c) 1999-2002 Eduardo Horvath
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.65 2003/11/09 14:28:56 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.66 2004/03/17 15:22:57 pk Exp $");
#include "opt_ddb.h"
@ -350,7 +350,7 @@ sbus_setup_attach_args(sc, bustag, dmatag, node, sa)
char buf[32];
if (error != ENOENT ||
!node_has_property(node, "device_type") ||
strcmp(PROM_getpropstringA(node, "device_type", buf),
strcmp(PROM_getpropstringA(node, "device_type", buf, sizeof buf),
"hierarchical") != 0)
return (error);
}
@ -567,9 +567,9 @@ sbus_get_intr(sc, node, ipp, np, slot)
* somehow. Luckily, the interrupt vector has lots of free
* space and we can easily stuff the IPL in there for a while.
*/
PROM_getpropstringA(node, "device_type", buf);
if (!buf[0])
PROM_getpropstringA(node, "name", buf);
PROM_getpropstringA(node, "device_type", buf, sizeof buf);
if (buf[0] == '\0')
PROM_getpropstringA(node, "name", buf, sizeof buf);
for (i = 0; intrmap[i].in_class; i++)
if (strcmp(intrmap[i].in_class, buf) == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.h,v 1.17 2004/03/16 23:05:46 pk Exp $ */
/* $NetBSD: autoconf.h,v 1.18 2004/03/17 15:22:57 pk Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -136,7 +136,7 @@ int PROM_getpropint __P((int node, char *name, int deflt));
extern int optionsnode;
/* new interfaces: */
char *PROM_getpropstringA __P((int, char *, char *));
char *PROM_getpropstringA __P((int, char *, char *, size_t));
struct idprom *prom_getidprom(void);
void prom_getether(int, u_char *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: autoconf.c,v 1.91 2004/03/17 14:35:53 pk Exp $ */
/* $NetBSD: autoconf.c,v 1.92 2004/03/17 15:22:57 pk Exp $ */
/*
* Copyright (c) 1996
@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.91 2004/03/17 14:35:53 pk Exp $");
__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.92 2004/03/17 15:22:57 pk Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -778,7 +778,6 @@ PROM_getprop(node, name, size, nitem, bufp)
void *buf;
long len;
*nitem = 0;
len = PROM_getproplen(node, name);
if (len <= 0)
return (ENOENT);
@ -792,6 +791,9 @@ PROM_getprop(node, name, size, nitem, bufp)
buf = malloc(len, M_DEVBUF, M_NOWAIT);
if (buf == NULL)
return (ENOMEM);
} else {
if (size * (*nitem) < len)
return (ENOMEM);
}
OF_getprop(node, name, buf, len);
@ -824,17 +826,18 @@ PROM_getpropstring(node, name)
{
static char stringbuf[32];
return (PROM_getpropstringA(node, name, stringbuf));
return (PROM_getpropstringA(node, name, stringbuf, sizeof stringbuf));
}
/* Alternative PROM_getpropstring(), where caller provides the buffer */
char *
PROM_getpropstringA(node, name, buffer)
PROM_getpropstringA(node, name, buffer, bufsize)
int node;
char *name;
char *buffer;
size_t bufsize;
{
int blen;
int blen = bufsize - 1;
if (PROM_getprop(node, name, 1, &blen, &buffer) != 0)
blen = 0;