On Wed, Sep 19, 2018 at 12:46:37PM -0600, Theo de Raadt wrote:
> Not sure it matters, but I should point out a difference.
>
> Your diff makes
>
> dev_mkdb --
>
> illegal.
>
> In a POSIX world, many programs have to use getopt. Not sure if this is one.
True, I did not consider that, sorry. Better keep getopt, also since both NetBSD
and DragonFlyBSD have command line options for dev_mkdb.
Below a minimal cleanup diff:
-) bzero => memset, bcopy => memcpy
-) no brackets around return
-) remove extra line in usage()
no (intended) functional change.
Clemens
Index: usr.sbin/dev_mkdb/dev_mkdb.c
===================================================================
RCS file: /cvs/src/usr.sbin/dev_mkdb/dev_mkdb.c,v
retrieving revision 1.16
diff -u -p -r1.16 dev_mkdb.c
--- usr.sbin/dev_mkdb/dev_mkdb.c 9 Aug 2018 14:30:28 -0000 1.16
+++ usr.sbin/dev_mkdb/dev_mkdb.c 20 Sep 2018 07:27:48 -0000
@@ -83,7 +83,7 @@ main(int argc, char *argv[])
(void)snprintf(dbtmp, sizeof(dbtmp), "%sdev.tmp", _PATH_VARRUN);
(void)snprintf(dbname, sizeof(dbname), "%sdev.db", _PATH_VARRUN);
- bzero(&info, sizeof(info));
+ memset(&info, 0, sizeof(info));
info.bsize = 8192;
db = dbopen(dbtmp, O_CREAT|O_EXLOCK|O_RDWR|O_TRUNC,
S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, DB_HASH, &info);
@@ -96,7 +96,7 @@ main(int argc, char *argv[])
* that the structure may contain padding, so we have to clear it
* out here.
*/
- bzero(&bkey, sizeof(bkey));
+ memset(&bkey, 0, sizeof(bkey));
key.data = &bkey;
key.size = sizeof(bkey);
data.data = buf;
@@ -119,7 +119,7 @@ main(int argc, char *argv[])
* Create the data; nul terminate the name so caller doesn't
* have to.
*/
- bcopy(dp->d_name, buf, dp->d_namlen);
+ memcpy(buf, dp->d_name, dp->d_namlen);
buf[dp->d_namlen] = '\0';
data.size = dp->d_namlen + 1;
if ((db->put)(db, &key, &data, 0))
@@ -129,13 +129,12 @@ main(int argc, char *argv[])
if (rename(dbtmp, dbname))
err(1, "rename %s to %s", dbtmp, dbname);
- return (0);
+ return 0;
}
void
usage(void)
{
-
(void)fprintf(stderr, "usage: dev_mkdb\n");
exit(1);
}