cdbw(3): Make cdbw_output descr parameter type less confusing.

This is a string of _up to_ 16 bytes, used with strncpy(..., 16).
Specifying `const char descr[16]', while formally equivalent to
`const char *descr' in standard C, now provokes the ire of gcc when
the caller does not provide a buffer of at least 16 bytes.
This commit is contained in:
riastradh 2023-08-08 10:34:08 +00:00
parent a636a908ed
commit 72254be91c
3 changed files with 9 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cdbw.h,v 1.2 2012/06/03 21:21:45 joerg Exp $ */
/* $NetBSD: cdbw.h,v 1.3 2023/08/08 10:34:08 riastradh Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
* All rights reserved.
@ -50,7 +50,7 @@ int cdbw_put_data(struct cdbw *, const void *, size_t,
int cdbw_put_key(struct cdbw *, const void *, size_t,
uint32_t);
uint32_t cdbw_stable_seeder(void);
int cdbw_output(struct cdbw *, int, const char[16],
int cdbw_output(struct cdbw *, int, const char *,
uint32_t (*)(void));
void cdbw_close(struct cdbw *);

View File

@ -1,4 +1,4 @@
.\" $NetBSD: cdbw.3,v 1.8 2014/02/06 15:50:40 rmind Exp $
.\" $NetBSD: cdbw.3,v 1.9 2023/08/08 10:34:08 riastradh Exp $
.\"
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -74,7 +74,7 @@
.Fo cdbw_output
.Fa "struct cdbw *cdbw"
.Fa "int output"
.Fa "const char descr[16]"
.Fa "const char *descr"
.Fa "uint32_t (*seedgen)(void)"
.Fc
.Ft void
@ -113,7 +113,8 @@ computes the database file and writes it to the given descriptor.
The function returns an error if the file cannot be written correctly.
The
.Fa descr
parameter provides a human readable description of the database content.
parameter, a string of up to 16 bytes, provides a human readable
description of the database content.
The
.Fa seedgen
parameter can be used to override the default PRNG.

View File

@ -1,4 +1,4 @@
/* $NetBSD: cdbw.c,v 1.8 2022/04/19 20:32:14 rillig Exp $ */
/* $NetBSD: cdbw.c,v 1.9 2023/08/08 10:34:08 riastradh Exp $ */
/*-
* Copyright (c) 2009, 2010, 2015 The NetBSD Foundation, Inc.
* All rights reserved.
@ -36,7 +36,7 @@
#endif
#include <sys/cdefs.h>
__RCSID("$NetBSD: cdbw.c,v 1.8 2022/04/19 20:32:14 rillig Exp $");
__RCSID("$NetBSD: cdbw.c,v 1.9 2023/08/08 10:34:08 riastradh Exp $");
#include "namespace.h"
@ -602,7 +602,7 @@ print_hash(struct cdbw *cdbw, struct state *state, int fd, const char *descr)
}
int
cdbw_output(struct cdbw *cdbw, int fd, const char descr[16],
cdbw_output(struct cdbw *cdbw, int fd, const char *descr,
uint32_t (*seedgen)(void))
{
struct state state;