Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F163351714
D57252.id179242.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
7 KB
Referenced Files
None
Subscribers
None
D57252.id179242.diff
View Options
diff --git a/contrib/ncurses/include/ncurses_defs b/contrib/ncurses/include/ncurses_defs
--- a/contrib/ncurses/include/ncurses_defs
+++ b/contrib/ncurses/include/ncurses_defs
@@ -34,7 +34,7 @@
BROKEN_LINKER
BSD_TPUTS
-CGETENT_CONST /* nothing */
+CGETENT_CONST const
CPP_HAS_PARAM_INIT
CURSES_ACS_ARRAY acs_map
CURSES_WACS_ARRAY _nc_wacs
diff --git a/contrib/telnet/libtelnet/getent.c b/contrib/telnet/libtelnet/getent.c
--- a/contrib/telnet/libtelnet/getent.c
+++ b/contrib/telnet/libtelnet/getent.c
@@ -39,17 +39,17 @@
#include "misc-proto.h"
static char *area;
-static char gettytab[] = "/etc/gettytab";
+static const char * const dba[] = { "/etc/gettytab", NULL };
/*ARGSUSED*/
int
getent(char *cp __unused, const char *name)
{
int retval;
- char *tempnam, *dba[2] = { gettytab, NULL };
+ char *tempnam;
tempnam = strdup(name);
- retval = cgetent(&area, dba, tempnam) == 0 ? 1 : 0;
+ retval = cgetent(&area, dba, tempnam) == 0 ? 1 : 0;
free(tempnam);
return(retval);
}
diff --git a/include/stdlib.h b/include/stdlib.h
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -279,10 +279,10 @@
/* getcap(3) functions */
char *cgetcap(char *, const char *, int);
int cgetclose(void);
-int cgetent(char **, char **, const char *);
-int cgetfirst(char **, char **);
+int cgetent(char **, const char * const *, const char *);
+int cgetfirst(char **, const char * const *);
int cgetmatch(const char *, const char *);
-int cgetnext(char **, char **);
+int cgetnext(char **, const char * const *);
int cgetnum(char *, const char *, long *);
int cgetset(const char *);
int cgetstr(char *, const char *, char **);
diff --git a/lib/libc/gen/disklabel.c b/lib/libc/gen/disklabel.c
--- a/lib/libc/gen/disklabel.c
+++ b/lib/libc/gen/disklabel.c
@@ -54,6 +54,8 @@
return (0);
}
+static const char *db_array[] = { _PATH_DISKTAB, NULL };
+
struct disklabel *
getdiskbyname(const char *name)
{
@@ -61,13 +63,12 @@
struct disklabel *dp = &disk;
struct partition *pp;
char *buf;
- char *db_array[2] = { _PATH_DISKTAB, 0 };
char *cp, *cq; /* can't be register */
char p, max, psize[3], pbsize[3],
pfsize[3], poffset[3], ptype[3];
u_int32_t *dx;
- if (cgetent(&buf, db_array, (char *) name) < 0)
+ if (cgetent(&buf, db_array, name) < 0)
return NULL;
bzero((char *)&disk, sizeof(disk));
diff --git a/lib/libc/gen/getcap.3 b/lib/libc/gen/getcap.3
--- a/lib/libc/gen/getcap.3
+++ b/lib/libc/gen/getcap.3
@@ -28,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd March 22, 2002
+.Dd May 26, 2026
.Dt GETCAP 3
.Os
.Sh NAME
@@ -48,7 +48,7 @@
.Sh SYNOPSIS
.In stdlib.h
.Ft int
-.Fn cgetent "char **buf" "char **db_array" "const char *name"
+.Fn cgetent "char **buf" "const char * const *db_array" "const char *name"
.Ft int
.Fn cgetset "const char *ent"
.Ft int
@@ -62,9 +62,9 @@
.Ft int
.Fn cgetustr "char *buf" "const char *cap" "char **str"
.Ft int
-.Fn cgetfirst "char **buf" "char **db_array"
+.Fn cgetfirst "char **buf" "const char * const *db_array"
.Ft int
-.Fn cgetnext "char **buf" "char **db_array"
+.Fn cgetnext "char **buf" "const char * const *db_array"
.Ft int
.Fn cgetclose "void"
.Sh DESCRIPTION
diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c
--- a/lib/libc/gen/getcap.c
+++ b/lib/libc/gen/getcap.c
@@ -62,7 +62,8 @@
static int gottoprec; /* Flag indicating retrieval of toprecord */
static int cdbget(DB *, char **, const char *);
-static int getent(char **, u_int *, char **, int, const char *, int, char *);
+static int getent(char **, u_int *, const char * const *, int,
+ const char *, int, char *);
static int nfcmp(char *, char *);
/*
@@ -154,7 +155,7 @@
* reference loop is detected.
*/
int
-cgetent(char **buf, char **db_array, const char *name)
+cgetent(char **buf, const char * const *db_array, const char *name)
{
u_int dummy;
@@ -180,11 +181,12 @@
* MAX_RECURSION.
*/
static int
-getent(char **cap, u_int *len, char **db_array, int fd, const char *name,
- int depth, char *nfield)
+getent(char **cap, u_int *len, const char * const *db_array, int fd,
+ const char *name, int depth, char *nfield)
{
DB *capdbp;
- char *r_end, *rp, **db_p;
+ const char * const *db_p;
+ char *r_end, *rp;
int myfd, eof, foundit, retval;
char *record, *cbuf;
int tc_not_resolved;
@@ -611,7 +613,7 @@
int
-cgetfirst(char **buf, char **db_array)
+cgetfirst(char **buf, const char * const *db_array)
{
(void)cgetclose();
return (cgetnext(buf, db_array));
@@ -619,7 +621,7 @@
static FILE *pfp;
static int slash;
-static char **dbp;
+static const char * const *dbp;
int
cgetclose(void)
@@ -640,7 +642,7 @@
* upon returning an entry with more remaining, and -1 if an error occurs.
*/
int
-cgetnext(char **bp, char **db_array)
+cgetnext(char **bp, const char * const *db_array)
{
size_t len;
int done, hadreaderr, savederrno, status;
diff --git a/lib/libutil/login_cap.c b/lib/libutil/login_cap.c
--- a/lib/libutil/login_cap.c
+++ b/lib/libutil/login_cap.c
@@ -299,8 +299,7 @@
const char *msg = NULL;
const char *dir;
char userpath[MAXPATHLEN];
-
- static char *login_dbarray[] = { NULL, NULL, NULL };
+ const char *login_dbarray[] = { NULL, NULL, NULL };
me = (name != NULL && strcmp(name, LOGIN_MECLASS) == 0);
dir = (!me || pwd == NULL) ? NULL : pwd->pw_dir;
diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c
--- a/libexec/getty/subr.c
+++ b/libexec/getty/subr.c
@@ -54,6 +54,7 @@
void
gettable(const char *name)
{
+ static const char *dba[2] = { _PATH_GETTYTAB, NULL };
char *buf = NULL;
struct gettystrs *sp;
struct gettynums *np;
@@ -61,15 +62,9 @@
long n;
int l;
char *p;
- static char path_gettytab[PATH_MAX];
- char *dba[2];
static int firsttime = 1;
- strlcpy(path_gettytab, _PATH_GETTYTAB, sizeof(path_gettytab));
- dba[0] = path_gettytab;
- dba[1] = NULL;
-
if (firsttime) {
/*
* we need to strdup() anything in the strings array
diff --git a/usr.bin/cap_mkdb/cap_mkdb.c b/usr.bin/cap_mkdb/cap_mkdb.c
--- a/usr.bin/cap_mkdb/cap_mkdb.c
+++ b/usr.bin/cap_mkdb/cap_mkdb.c
@@ -40,7 +40,7 @@
#include <string.h>
#include <unistd.h>
-static void db_build(char **);
+static void db_build(const char * const *);
static void dounlink(void);
static void usage(void);
@@ -113,7 +113,7 @@
if (atexit(dounlink))
err(1, "atexit");
- db_build(argv);
+ db_build((const char * const *)argv);
if (capdbp->close(capdbp) < 0)
err(1, "%s", capname);
@@ -142,7 +142,7 @@
* details above.
*/
static void
-db_build(char **ifiles)
+db_build(const char * const *ifiles)
{
DBT key, data;
recno_t reccnt;
diff --git a/usr.bin/tip/tip/remote.c b/usr.bin/tip/tip/remote.c
--- a/usr.bin/tip/tip/remote.c
+++ b/usr.bin/tip/tip/remote.c
@@ -53,7 +53,7 @@
"di", "es", "ex", "fo", "rc", "re", "pa", 0
};
-static char *db_array[3] = { _PATH_REMOTE, 0, 0 };
+static const char *db_array[] = { _PATH_REMOTE, NULL, NULL };
#define cgetflag(f) (cgetcap(bp, f, ':') != NULL)
diff --git a/usr.sbin/lpr/common_source/printcap.c b/usr.sbin/lpr/common_source/printcap.c
--- a/usr.sbin/lpr/common_source/printcap.c
+++ b/usr.sbin/lpr/common_source/printcap.c
@@ -54,7 +54,7 @@
/*
* Routines and data used in processing the printcap file.
*/
-static char *printcapdb[] = { __DECONST(char *, _PATH_PRINTCAP), NULL };
+static const char *printcapdb[] = { _PATH_PRINTCAP, NULL };
static char *capdb_canonical_name(const char *_bp);
static int capdb_getaltlog(char *_bp, const char *_shrt,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 23, 10:19 AM (8 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
35398610
Default Alt Text
D57252.id179242.diff (7 KB)
Attached To
Mode
D57252: libc: Constify the getcap API
Attached
Detach File
Event Timeline
Log In to Comment