Subject: standards/25343: datum structure defines dsize as int
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <murray@river-styx.org>
List: netbsd-bugs
Date: 04/27/2004 07:56:20
>Number:         25343
>Category:       standards
>Synopsis:       <ndbm.h> datum structure defines dsize as int
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    standards-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 27 07:57:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Murray Armfield
>Release:        NetBSD-current
>Organization:
>Environment:
NetBSD ra 2.0E NetBSD 2.0E (RA.MP) #0: Sun Apr 25 10:36:47 EST 2004  admin@ra:/usr/obj/sys/arch/i386/compile/RA.MP i386
>Description:
The NetBSD header file <ndbm.h> defines the datum structure member
dsize as an int. Posix says it should be a size_t. Considering this
variable stores, "The size of the object pointed to by dptr" (Posix),
this seems not quite right.
>How-To-Repeat:
Inspect <ndbm.h> in NetBSD
Inspect <ndbm.h> in Posix
>Fix:
--- include/ndbm.h.orig 2003-08-08 23:35:29.000000000 +1000
+++ include/ndbm.h
@@ -38,9 +38,15 @@
 #define        _NDBM_H_

 #include <sys/cdefs.h>
+#include <machine/ansi.h>
 #include <sys/featuretest.h>
 #include <db.h>

+#ifdef  _BSD_SIZE_T_
+typedef _BSD_SIZE_T_   size_t;
+#undef  _BSD_SIZE_T_
+#endif
+
 #if defined(_NETBSD_SOURCE)
 /* Map dbm interface onto db(3). */
 #define DBM_RDONLY     O_RDONLY
@@ -59,8 +65,8 @@
 #endif

 typedef struct {
-       void *dptr;
-       int dsize;              /* XXX */
+       void *dptr;     /* A pointer to the application's data. */
+       int dsize;      /* The size of the object pointed to by dptr. */
 } datum;

 typedef DB DBM;
>Release-Note:
>Audit-Trail:
>Unformatted: