Mercurial > illumos > illumos-gate
changeset 13583:fabd461f883f
2023 libnisdb is inconsistently const-y
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>
Reviewed by: Joshua M. Clulow <josh@sysmgr.org>
Approved by: Gordon Ross <gwr@nexenta.com>
author | Richard Lowe <richlowe@richlowe.net> |
---|---|
date | Mon, 16 May 2011 05:36:40 +0100 |
parents | 64b0427edfc3 |
children | fc320b2833d3 |
files | usr/src/lib/libnisdb/db_dictionary.cc usr/src/lib/libnisdb/db_mindex.cc usr/src/lib/libnisdb/db_mindex2.cc usr/src/lib/libnisdb/db_mindex3.cc usr/src/lib/libnisdb/db_table.cc usr/src/lib/libnisdb/ldap_glob.c usr/src/lib/libnisdb/ldap_glob.h usr/src/lib/libnisdb/ldap_util.c usr/src/lib/libnisdb/ldap_util.h usr/src/lib/libnisdb/nis_db.cc usr/src/lib/libnisdb/nis_db.h |
diffstat | 11 files changed, 80 insertions(+), 90 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/lib/libnisdb/db_dictionary.cc Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/db_dictionary.cc Mon May 16 05:36:40 2011 +0100 @@ -26,8 +26,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "db_headers.h" #include "db_entry.h" #include "db_dictionary.h" @@ -1509,7 +1507,7 @@ db *res; int lstat; db_status dstat; - char *myself = "db_dictionary::find_table"; + const char *myself = "db_dictionary::find_table"; res = find_table_noLDAP(tab, where, searchDeferred, doLoad); /* If found, or shouldn't try LDAP, we're done */ @@ -1992,9 +1990,9 @@ static int close_standby_list() { - db *database; - int i, ret; - char *myself = "close_standby_list"; + db *database; + int i, ret; + const char *myself = "close_standby_list"; MUTEXLOCK(db_standby_list, "close_standby_list"); @@ -2046,8 +2044,8 @@ int add_to_standby_list(db* database) { - int i; - char *myself = "add_to_standby_list"; + int i; + const char *myself = "add_to_standby_list"; MUTEXLOCK(db_standby_list, "add_to_standby_list"); @@ -2239,7 +2237,7 @@ WRITELOCK(this, DB_LOCK_ERROR, "w db_dictionary::defer"); db_table_desc *tbl = find_table_desc(table); int res; - char *myself = "db_dictionary::defer"; + const char *myself = "db_dictionary::defer"; if (tbl != NULL) { db_table_desc *clone, *savenext = tbl->next;
--- a/usr/src/lib/libnisdb/db_mindex.cc Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/db_mindex.cc Mon May 16 05:36:40 2011 +0100 @@ -924,7 +924,7 @@ bool_t valid; db_index_entry *rp = NULL; db_status rstat; - char *myself = "db_mindex::add"; + const char *myself = "db_mindex::add"; /* * The argument q is only NULL when we know that there are
--- a/usr/src/lib/libnisdb/db_mindex2.cc Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/db_mindex2.cc Mon May 16 05:36:40 2011 +0100 @@ -149,9 +149,9 @@ zotypes updateMappingObj(__nis_table_mapping_t *t, char **objNameP, bool_t *isMasterP) { - zotypes type = NIS_BOGUS_OBJ; - char *objName = 0; - char *myself = "updateMappingObj"; + zotypes type = NIS_BOGUS_OBJ; + char *objName = 0; + const char *myself = "updateMappingObj"; if (t != 0) objName = t->objName; @@ -216,7 +216,7 @@ __nis_table_mapping_t *t; __nis_buffer_t b = {0, 0}; char *objPath; - char *myself = "mappingFromObj"; + const char *myself = "mappingFromObj"; if (obj == 0 || obj->zo_data.zo_type == NIS_ENTRY_OBJ) return (0); @@ -252,7 +252,7 @@ bool_t doLDAP, asObj; int stat = LDAP_SUCCESS; char *objPath = 0, buf[MAXPATHLEN+NIS_MAXNAMELEN+1]; - char *myself = "db_mindex::selectMapping"; + const char *myself = "db_mindex::selectMapping"; /* * If 'table' is NULL, we try to find a mapping for 'obj'. @@ -454,7 +454,7 @@ db_result *dbres; db_query *qi; nis_object *oldObj = 0; - char *myself = "db_mindex::updateTableEntry"; + const char *myself = "db_mindex::updateTableEntry"; if (table == 0 || e == 0) return (LDAP_PARAM_ERROR); @@ -688,7 +688,7 @@ findDirEntryMapping(__nis_table_mapping_t *t, entry_object *e, char **name) { __nis_table_mapping_t *x; char *entryName; - char *myself = "findDirEntryMapping"; + const char *myself = "findDirEntryMapping"; __nis_buffer_t b = {0, 0}; if (e == 0 || e->en_cols.en_cols_len != 2 || @@ -735,7 +735,7 @@ nis_attr attr; nis_object *dirObj; db_status dstat; - char *myself = "db_mindex::queryLDAP"; + const char *myself = "db_mindex::queryLDAP"; if (!useLDAPrespository || table == 0) return (LDAP_SUCCESS); @@ -1173,7 +1173,7 @@ int numEa, doUnlock = 0; db *dbase = 0; db_mindex *dbm = 0; - char *myself = "db_mindex::storeObjLDAP"; + const char *myself = "db_mindex::storeObjLDAP"; if (t == 0 || o == 0) return (LDAP_SUCCESS); @@ -1287,7 +1287,7 @@ db_query *q, *qo, **qa; __nis_rule_value_t *rv = 0; int stat; - char *myself = "db_mindex::storeLDAP"; + const char *myself = "db_mindex::storeLDAP"; if (!useLDAPrespository || table == 0) return (LDAP_SUCCESS);
--- a/usr/src/lib/libnisdb/db_mindex3.cc Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/db_mindex3.cc Mon May 16 05:36:40 2011 +0100 @@ -99,7 +99,7 @@ __entries_from_ldap_arg_t *arg; int stat; db_status dstat; - char *myself = "db_mindex::entriesFromLDAP"; + const char *myself = "db_mindex::entriesFromLDAP"; arg = (__entries_from_ldap_arg_t *)am(myself, sizeof (*arg)); if (arg == 0) { @@ -343,7 +343,7 @@ bool_t doEnum; db_status dstat; struct timeval start; - char *myself = + const char *myself = "db_mindex::entriesFromLDAPreal"; if (arg == 0) @@ -708,9 +708,9 @@ o.zo_ttl = to->zo_ttl; } else { tc = 0; - o.zo_owner = ""; - o.zo_group = ""; - o.zo_domain = ""; + o.zo_owner = (nis_name)""; + o.zo_group = (nis_name)""; + o.zo_domain = (nis_name)""; } o.zo_data.zo_type = NIS_ENTRY_OBJ;
--- a/usr/src/lib/libnisdb/db_table.cc Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/db_table.cc Mon May 16 05:36:40 2011 +0100 @@ -26,8 +26,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <malloc.h> #include <string.h> @@ -398,7 +396,7 @@ db_status db_table::allocateEnumArray(long oldSize, long newSize) { entry_object **newEnumArray; - char *myself = "db_table::allocateEnumArray"; + const char *myself = "db_table::allocateEnumArray"; if (enumCount.flag > 0) { if (enumIndex.ptr == 0) { @@ -558,7 +556,7 @@ void db_table::setEntryExp(entryp where, entry_obj *obj, int initialLoad) { nis_object *o; - char *myself = "db_table::setEntryExp"; + const char *myself = "db_table::setEntryExp"; /* * If we don't know what type of object this is yet, we @@ -766,7 +764,7 @@ db_table::configure(char *tablePath) { long i; struct timeval now; - char *myself = "db_table::configure"; + const char *myself = "db_table::configure"; (void) gettimeofday(&now, NULL); @@ -951,7 +949,7 @@ */ void db_table::setEnumMode(long enumNum) { - char *myself = "setEnumMode"; + const char *myself = "setEnumMode"; enumMode.flag++; if (enumMode.flag == 1) {
--- a/usr/src/lib/libnisdb/ldap_glob.c Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/ldap_glob.c Mon May 16 05:36:40 2011 +0100 @@ -24,8 +24,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include "ldap_glob.h" /* These are the local versions we use if the app doesn't provide overrides */ @@ -71,23 +69,23 @@ } int -__local_lockTransLog(char *msg, int wr, int trylock) { +__local_lockTransLog(const char *msg, int wr, int trylock) { return (0); } void -__local_unlockTransLog(char *msg, int wr) { +__local_unlockTransLog(const char *msg, int wr) { } int __local__nis_lock_db_table(nis_name name, int readwrite, int *trylock, - char *msg) { + const char *msg) { return (1); } int __local__nis_ulock_db_table(nis_name name, int readwrite, int remove, - char *msg) { + const char *msg) { return (1); }
--- a/usr/src/lib/libnisdb/ldap_glob.h Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/ldap_glob.h Mon May 16 05:36:40 2011 +0100 @@ -24,8 +24,6 @@ * All rights reserved. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #ifndef _LDAP_GLOB_H #define _LDAP_GLOB_H @@ -61,12 +59,12 @@ extern int addUpdate(log_entry_t type, char *name, int numAttr, nis_attr *attr, nis_object *obj, nis_object *oldDir, uint32_t ttime); -extern int lockTransLog(char *msg, int wr, int trylock); -extern void unlockTransLog(char *msg, int wr); +extern int lockTransLog(const char *msg, int wr, int trylock); +extern void unlockTransLog(const char *msg, int wr); extern int __nis_lock_db_table(nis_name name, int readwrite, - int *trylock, char *msg); + int *trylock, const char *msg); extern int __nis_ulock_db_table(nis_name name, int readwrite, - int remove, char *msg); + int remove, const char *msg); #ifdef __cplusplus }
--- a/usr/src/lib/libnisdb/ldap_util.c Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/ldap_util.c Mon May 16 05:36:40 2011 +0100 @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <stdlib.h> #include <strings.h> @@ -49,7 +47,7 @@ * Log a message to the appropriate place. */ void -logmsg(int msgtype, int priority, char *fmt, ...) { +logmsg(int msgtype, int priority, const char *fmt, ...) { va_list ap; struct timeval tp; @@ -199,7 +197,7 @@ * zero bytes is legal, and returns a NULL pointer. */ void * -am(char *msg, int size) { +am(const char *msg, int size) { void *p; if (size > 0) { @@ -227,7 +225,7 @@ * on a NULL pointer. */ int -slen(char *str) { +slen(const char *str) { return ((str != 0) ? strlen(str) : 0); } @@ -236,7 +234,7 @@ * like strdup(), but don't die if 'str' is a NULL pointer. */ char * -sdup(char *msg, int allocate, char *str) { +sdup(const char *msg, int allocate, char *str) { char *s; if (!allocate) @@ -259,7 +257,7 @@ * NULL pointer or two. If deallocate!=0, free() the input strings. */ char * -scat(char *msg, int deallocate, char *s1, char *s2) { +scat(const char *msg, int deallocate, char *s1, char *s2) { char *n; int l1 = 0, l2 = 0; @@ -437,7 +435,7 @@ * result to '*buf'. */ int -vp2buf(char *msg, char **buf, int buflen, char *fmt, va_list ap) { +vp2buf(const char *msg, char **buf, int buflen, const char *fmt, va_list ap) { char *newbuf = am(msg, STDBUFSIZE); int size = 0; @@ -482,7 +480,7 @@ /* sprintf to the specified __nis_buffer_t */ void -bp2buf(char *msg, __nis_buffer_t *b, char *fmt, ...) { +bp2buf(const char *msg, __nis_buffer_t *b, const char *fmt, ...) { va_list ap; va_start(ap, fmt); @@ -492,7 +490,7 @@ /* Copy 'buf' to the specified __nis_buffer_t */ void -bc2buf(char *msg, void *buf, int len, __nis_buffer_t *b) { +bc2buf(const char *msg, void *buf, int len, __nis_buffer_t *b) { void *new; /* @@ -517,7 +515,7 @@ /* Like bc2buf(), but remove any trailing NUL bytes */ void -sbc2buf(char *msg, void *buf, int len, __nis_buffer_t *b) { +sbc2buf(const char *msg, void *buf, int len, __nis_buffer_t *b) { if (buf == 0 || len <= 0 || b == 0) return; /* Snip off trailing NULs */
--- a/usr/src/lib/libnisdb/ldap_util.h Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/ldap_util.h Mon May 16 05:36:40 2011 +0100 @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdarg.h> #include <syslog.h> @@ -83,26 +81,27 @@ extern unsigned long numMisaligned; /* Exported functions */ -void logmsg(int msgtype, int priority, char *fmt, ...); +void logmsg(int msgtype, int priority, const char *fmt, ...); void reportError(int error, char *fmt, ...); int getError(char **message); void clearError(void); void logError(int priority); -void *am(char *msg, int size); -int slen(char *str); -char *sdup(char *msg, int allocate, char *str); -char *scat(char *msg, int deallocate, char *s1, char *s2); +void *am(const char *msg, int size); +int slen(const char *str); +char *sdup(const char *msg, int allocate, char *str); +char *scat(const char *msg, int deallocate, char *s1, char *s2); void sfree(void *ptr); char lastChar(__nis_single_value_t *v); void *appendString2SingleVal(char *str, __nis_single_value_t *v, int *newLen); int scmp(char *s, __nis_single_value_t *v); int scasecmp(char *s, __nis_single_value_t *v); -int vp2buf(char *msg, char **buf, int buflen, char *fmt, va_list ap); +int vp2buf(const char *msg, char **buf, int buflen, const char *fmt, + va_list ap); void p2buf(char *msg, char *fmt, ...); -void bp2buf(char *msg, __nis_buffer_t *b, char *fmt, ...); -void bc2buf(char *msg, void *buf, int len, __nis_buffer_t *b); -void sbc2buf(char *msg, void *buf, int len, __nis_buffer_t *b); +void bp2buf(const char *msg, __nis_buffer_t *b, const char *fmt, ...); +void bc2buf(const char *msg, void *buf, int len, __nis_buffer_t *b); +void sbc2buf(const char *msg, void *buf, int len, __nis_buffer_t *b); void c2buf(char *msg, void *buf, int len); void sc2buf(char *msg, void *buf, int len); void printbuf(void);
--- a/usr/src/lib/libnisdb/nis_db.cc Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/nis_db.cc Mon May 16 05:36:40 2011 +0100 @@ -61,11 +61,11 @@ * 'tbl_prototype' is used to create a table that holds a directory. */ static table_col cols[2] = { - {"object", TA_BINARY+TA_XDR, 0}, - {"name", TA_CASE+TA_SEARCHABLE, 0} + {(char *)"object", TA_BINARY+TA_XDR, 0}, + {(char *)"name", TA_CASE+TA_SEARCHABLE, 0} }; -table_obj tbl_prototype = { "DIRECTORY", 2, ' ', {2, &cols[0]}, NULL }; +table_obj tbl_prototype = { (char *)"DIRECTORY", 2, ' ', {2, &cols[0]}, NULL }; } /* @@ -148,10 +148,10 @@ } -char +const char *db_perror(db_status dbstat) { - char *str = NULL; + const char *str = NULL; switch (dbstat) { case DB_SUCCESS: @@ -449,9 +449,9 @@ * Both the return value and '*tableP' must be freed by the caller. */ char * -entryName(char *msg, char *objName, char **tableP) { - char *name, *table, *dir; - char *myself = "entryName"; +entryName(const char *msg, char *objName, char **tableP) { + char *name, *table, *dir; + const char *myself = "entryName"; if (msg == 0) msg = myself; @@ -505,7 +505,7 @@ db_mindex *mindex; nis_object *o; int lstat; - char *myself = "dbFindObject"; + const char *myself = "dbFindObject"; if (objName == 0) RETSTAT(0, DB_BADQUERY); @@ -548,7 +548,7 @@ RETSTAT(0, DB_LOCK_ERROR); } - attr.zattr_ndx = "name"; + attr.zattr_ndx = (char *)"name"; attr.zattr_val.zattr_val_val = name; attr.zattr_val.zattr_val_len = slen(name) + 1; @@ -611,7 +611,7 @@ ldapFindObj(__nis_table_mapping_t *t, char *objName, int *statP) { nis_object *o; int stat; - char *myself = "ldapFindObj"; + const char *myself = "ldapFindObj"; if (t == 0) { char *table, tbuf[MAXPATHLEN + NIS_MAXNAMELEN + 1]; @@ -656,7 +656,7 @@ nis_object *o; db_status stat = DB_SUCCESS; int lstat = LDAP_SUCCESS; - char *myself = "findObj"; + const char *myself = "findObj"; o = dbFindObject(name, &stat); @@ -695,7 +695,7 @@ db_status stat; nisdb_obj_del_t *nod, *tmp; int xid; - char *myself = "dbDeleteObj"; + const char *myself = "dbDeleteObj"; if (objName == 0) return (DB_SUCCESS); @@ -772,7 +772,7 @@ nis_attr attr; db_query *query; db_status stat; - char *myself = "dbTouchObj"; + const char *myself = "dbTouchObj"; table = internalTableName(objName); if (table == 0) @@ -804,7 +804,7 @@ return (DB_BADTABLE); } - attr.zattr_ndx = "name"; + attr.zattr_ndx = (char *)"name"; attr.zattr_val.zattr_val_val = ent; attr.zattr_val.zattr_val_len = slen(ent) + 1; @@ -833,7 +833,7 @@ table_col tc[NIS_MAXCOLUMNS+1]; table_obj tobj, *t; int i; - char *myself = "dbCreateTable"; + const char *myself = "dbCreateTable"; if (intName == 0 || obj == 0) return (DB_BADTABLE); @@ -879,7 +879,7 @@ db_status stat; char *ent, *table, *objTable; int rstat, isDir = 0, isTable = 0; - char *myself = "refreshObj"; + const char *myself = "refreshObj"; if (o == 0) /* Delete it */ @@ -973,7 +973,7 @@ if (strcmp(ROOTDIRFILE, objTable) == 0) { sfree(objTable); - rstat = update_root_object(ROOTOBJFILE, o); + rstat = update_root_object((nis_name)ROOTOBJFILE, o); if (rstat == 1) stat = DB_SUCCESS; else @@ -1018,7 +1018,7 @@ } /* Construct suitable nis_attr and entry_object */ - attr.zattr_ndx = "name"; + attr.zattr_ndx = (char *)"name"; attr.zattr_val.zattr_val_val = ent; attr.zattr_val.zattr_val_len = slen(ent) + 1; @@ -1026,7 +1026,7 @@ ec[1].ec_value.ec_value_val = ent; ec[1].ec_value.ec_value_len = attr.zattr_val.zattr_val_len; - eo.en_type = "IN_DIRECTORY"; + eo.en_type = (char *)"IN_DIRECTORY"; eo.en_cols.en_cols_val = ec; eo.en_cols.en_cols_len = 2; @@ -1224,7 +1224,7 @@ int lstat, doDestroy; nis_object *obj = 0; db_status dstat; - char *myself = "dbCreateFromLDAP"; + const char *myself = "dbCreateFromLDAP"; if (!useLDAPrespository) { if (ldapStat != 0) @@ -1279,7 +1279,7 @@ db *dbase; db_table_desc *tbl = 0; db_mindex *mindex; - char *myself = "loadAllLDAP"; + const char *myself = "loadAllLDAP"; /* * If the 'cookie' and '*cookie' are non-NULL, start scanning @@ -1416,7 +1416,8 @@ ent = 0; } else { objPath = 0; - ent = entryName(myself, t->objName, &objPath); + ent = entryName(myself, t->objName, + &objPath); if (ent == 0 || objPath == 0) { logmsg(MSG_NOTIMECHECK, LOG_ERR, "%s: Error deriving entry/DB-table names for %s:%s; skipping up-load", @@ -1474,7 +1475,7 @@ nis_attr attr; db_query *q; - attr.zattr_ndx = "name"; + attr.zattr_ndx = (char *)"name"; attr.zattr_val.zattr_val_val = ent; attr.zattr_val.zattr_val_len = slen(ent) + 1;
--- a/usr/src/lib/libnisdb/nis_db.h Mon May 16 03:33:25 2011 +0100 +++ b/usr/src/lib/libnisdb/nis_db.h Mon May 16 05:36:40 2011 +0100 @@ -39,7 +39,7 @@ extern int useLDAPrespository; void db_free_result(db_result *dr); -char *entryName(char *msg, char *objName, char **tableP); +char *entryName(const char *msg, char *objName, char **tableP); nis_object *dbFindObject(char *objName, db_status *statP); db_status dbDeleteObj(char *objName); db_status dbTouchObj(char *objName);