Misc code cleanup.

This commit is contained in:
Kurt Zeilenga 2000-06-10 22:39:30 +00:00
parent 06b7561096
commit a56c161bdb
35 changed files with 62 additions and 71 deletions

View File

@ -96,7 +96,7 @@ disambiguate( LDAPMessage *result, int matches, char **read_attrs, char *who )
for (;;) {
printf(" Do you wish to see a list of names? ");
fflush(stdout);
(void) memset(response, 0, sizeof(response));
(void) memset(response, '\0', sizeof(response));
fetch_buffer(response, sizeof(response), stdin);
switch (response[0]) {
case 'n' :

View File

@ -397,7 +397,7 @@ get_value( char *id, char *prompt )
* Other attributes may not.
*/
count = 1;
(void) memset(buffer, 0, sizeof(buffer));
(void) memset(buffer, '\0', sizeof(buffer));
#ifdef UOFM
if (!strcmp(id, "postalAddress") || !strcmp(id, "homePostalAddress") || !strcmp(id, "multiLineDescription") || !strcmp(id, "vacationMessage"))
#else

View File

@ -575,7 +575,7 @@ time2text( char *ldtimestr, int dateonly )
return( fmterr );
}
memset( (char *)&t, 0, sizeof( struct tm ));
memset( (char *)&t, '\0', sizeof( struct tm ));
p = ldtimestr;

View File

@ -67,7 +67,7 @@ des_string_to_key( char *str, register des_cblock *key )
length = strlen(str);
/* init key array for bits */
memset(k_char, 0, sizeof(k_char));
memset(k_char, '\0', sizeof(k_char));
#ifdef USE_DES_DEBUG
if (des_debug)
@ -116,7 +116,7 @@ des_string_to_key( char *str, register des_cblock *key )
(void) des_key_sched(key,key_sked);
(void) des_cbc_cksum((des_cblock *)in_str,key,length,key_sked,key);
/* erase key_sked */
memset((char *)key_sked, 0, sizeof(key_sked));
memset((char *)key_sked, '\0', sizeof(key_sked));
/* now fix up key parity again */
des_fixup_key_parity(key);
@ -160,8 +160,8 @@ Andrew_StringToKey(
int i;
int passlen;
memset(key, 0, sizeof(des_cblock));
memset(password, 0, sizeof(password));
memset(key, '\0', sizeof(des_cblock));
memset(password, '\0', sizeof(password));
strncpy (password, cell, 8);
passlen = strlen (str);

View File

@ -43,7 +43,7 @@ int * ber_errno_addr(void)
* Print stuff
*/
static void
ber_error_print( char *data )
ber_error_print( const char *data )
{
assert( data != NULL );
@ -147,7 +147,7 @@ ber_bprint(
assert( data != NULL );
memset( out, 0, BPLEN );
memset( out, '\0', BPLEN );
for ( ;; ) {
if ( len < 1 ) {
sprintf( buf, "\t%s\n", ( i == 0 ) ? "(end)" : out );
@ -174,7 +174,7 @@ ber_bprint(
char data[128 + BPLEN];
sprintf( data, "\t%s\n", out );
(*ber_pvt_log_print)(data);
memset( out, 0, BPLEN );
memset( out, '\0', BPLEN );
i = 0;
continue;
}

View File

@ -145,7 +145,7 @@ ber_sockbuf_add_io( Sockbuf *sb, Sockbuf_IO *sbio, int layer, void *arg )
d->sbiod_level = layer;
d->sbiod_sb = sb;
d->sbiod_io = sbio;
memset( &d->sbiod_pvt, 0, sizeof( d->sbiod_pvt ) );
memset( &d->sbiod_pvt, '\0', sizeof( d->sbiod_pvt ) );
d->sbiod_next = p;
*q = d;
@ -561,7 +561,7 @@ sb_dgram_setup( Sockbuf_IO_Desc *sbiod, void *arg )
p = LBER_MALLOC( sizeof( *p ) );
if ( p == NULL )
return -1;
memset( p, 0, sizeof( *p ) );
memset( p, '\0', sizeof( *p ) );
sbiod->sbiod_pvt = (void *)p;
if ( arg != NULL )
sbiod->sbiod_sb->sb_fd = *((int *)arg);

View File

@ -44,7 +44,7 @@ ldap_enable_cache( LDAP *ld, long timeout, ber_len_t maxmem )
ld->ld_errno = LDAP_NO_MEMORY;
return( -1 );
}
(void) memset( ld->ld_cache, 0, sizeof( LDAPCache ));
(void) memset( ld->ld_cache, '\0', sizeof( LDAPCache ));
ld->ld_cache->lc_memused = sizeof( LDAPCache );
}

View File

@ -227,7 +227,7 @@ cldap_search_s( LDAP *ld,
*res = NULL;
(void) memset( &cri, 0, sizeof( cri ));
(void) memset( &cri, '\0', sizeof( cri ));
if ( logdn != NULL ) {
ld->ld_cldapdn = logdn;

View File

@ -324,7 +324,7 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb, const char *host,
break;
}
(void)memset((char *)&sin, 0, sizeof(struct sockaddr_in));
(void)memset((char *)&sin, '\0', sizeof(struct sockaddr_in));
sin.sin_family = AF_INET;
sin.sin_port = port;
p = (char *)&sin.sin_addr;
@ -365,7 +365,7 @@ ldap_host_connected_to( Sockbuf *sb )
ber_socket_t sd;
#define DO_RETURN(x) if (ha_buf) LDAP_FREE(ha_buf); return (x);
(void)memset( (char *)&sin, 0, sizeof( struct sockaddr_in ));
(void)memset( (char *)&sin, '\0', sizeof( struct sockaddr_in ));
len = sizeof( sin );
ber_sockbuf_ctrl( sb, LBER_SB_OPT_GET_FD, &sd );

View File

@ -201,7 +201,7 @@ ldap_connect_to_path(LDAP *ld, Sockbuf *sb, const char *path, int async)
oslocal_debug(ld, "ldap_connect_to_path: Trying %s\n", path, 0, 0);
memset( &server, 0, sizeof(server) );
memset( &server, '\0', sizeof(server) );
server.sun_family = AF_UNIX;
strcpy( server.sun_path, path );

View File

@ -835,7 +835,7 @@ ldap_pvt_sasl_bind(
}
sasl_setprop( ld->ld_sasl_context, SASL_IP_LOCAL, &sin );
memset( &secprops, 0, sizeof( secprops ) );
memset( &secprops, '\0', sizeof( secprops ) );
secprops.min_ssf = ld->ld_options.ldo_sasl_minssf;
secprops.max_ssf = ld->ld_options.ldo_sasl_maxssf;
secprops.security_flags = SASL_SECURITY_LAYER;

View File

@ -901,7 +901,7 @@ time2text( char *ldtimestr, int dateonly )
return( fmterr );
}
memset( (char *)&t, 0, sizeof( struct tm ));
memset( (char *)&t, '\0', sizeof( struct tm ));
p = ldtimestr;

View File

@ -34,7 +34,7 @@ ldap_pvt_thread_rdwr_init( ldap_pvt_thread_rdwr_t *rw )
{
assert( rw != NULL );
memset( rw, 0, sizeof(ldap_pvt_thread_rdwr_t) );
memset( rw, '\0', sizeof(ldap_pvt_thread_rdwr_t) );
/* we should check return results */
ldap_pvt_thread_mutex_init( &rw->ltrw_mutex );

View File

@ -30,7 +30,7 @@ ldbm_datum_free( LDBM ldbm, Datum data )
{
if ( data.dptr ) {
free( data.dptr );
memset( &data, 0, sizeof( Datum ));
memset( &data, '\0', sizeof( Datum ));
data.dptr = NULL;
}
}
@ -263,7 +263,7 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize )
#elif DB_VERSION_MAJOR >= 2
DB_INFO dbinfo;
memset( &dbinfo, 0, sizeof( dbinfo ));
memset( &dbinfo, '\0', sizeof( dbinfo ));
#if defined( DB_VERSION_MAJOR ) && defined( DB_VERSION_MINOR ) && \
DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 4

View File

@ -436,7 +436,7 @@ add_decomp(unsigned long code)
decomps = (_decomp_t *)
realloc((char *) decomps,
sizeof(_decomp_t) * (decomps_size + 8));
(void) memset((char *) (decomps + decomps_size), 0,
(void) memset((char *) (decomps + decomps_size), '\0',
sizeof(_decomp_t) << 3);
decomps_size += 8;
}

View File

@ -1077,7 +1077,7 @@ _ure_make_symbol(ucs2_t *sym, unsigned long limit, unsigned long *consumed,
* Build the next symbol so we can test to see if it is already in the
* symbol table.
*/
(void) memset((char *) &symbol, 0, sizeof(_ure_symtab_t));
(void) memset((char *) &symbol, '\0', sizeof(_ure_symtab_t));
*consumed = _ure_compile_symbol(sym, limit, &symbol, b);
/*
@ -1108,7 +1108,7 @@ _ure_make_symbol(ucs2_t *sym, unsigned long limit, unsigned long *consumed,
realloc((char *) b->symtab,
sizeof(_ure_symtab_t) * (b->symtab_size + 8));
sp = b->symtab + b->symtab_size;
(void) memset((char *) sp, 0, sizeof(_ure_symtab_t) << 3);
(void) memset((char *) sp, '\0', sizeof(_ure_symtab_t) << 3);
b->symtab_size += 8;
}
@ -1329,7 +1329,7 @@ _ure_add_state(ucs2_t nstates, ucs2_t *states, _ure_buffer_t *b)
realloc((char *) b->states.states,
sizeof(_ure_state_t) * (b->states.states_size + 8));
sp = b->states.states + b->states.states_size;
(void) memset((char *) sp, 0, sizeof(_ure_state_t) << 3);
(void) memset((char *) sp, '\0', sizeof(_ure_state_t) << 3);
b->states.states_size += 8;
}
@ -1734,7 +1734,7 @@ ure_compile(ucs2_t *re, unsigned long relen, int casefold, ure_buffer_t buf)
* Construct the minimal DFA.
*/
dfa = (ure_dfa_t) malloc(sizeof(_ure_dfa_t));
(void) memset((char *) dfa, 0, sizeof(_ure_dfa_t));
(void) memset((char *) dfa, '\0', sizeof(_ure_dfa_t));
dfa->flags = buf->flags & (_URE_DFA_CASEFOLD|_URE_DFA_BLANKLINE);

View File

@ -223,7 +223,7 @@ utbm_create_pattern(void)
utbm_pattern_t p;
p = (utbm_pattern_t) malloc(sizeof(_utbm_pattern_t));
(void) memset((char *) p, 0, sizeof(_utbm_pattern_t));
(void) memset((char *) p, '\0', sizeof(_utbm_pattern_t));
return p;
}

View File

@ -79,7 +79,7 @@ int lutil_unlockf ( int fd ) {
int lutil_lockf ( int fd ) {
struct flock file_lock;
memset( &file_lock, 0, sizeof( file_lock ) );
memset( &file_lock, '\0', sizeof( file_lock ) );
file_lock.l_type = F_WRLCK;
file_lock.l_whence = SEEK_SET;
file_lock.l_start = 0;
@ -92,7 +92,7 @@ int lutil_lockf ( int fd ) {
int lutil_unlockf ( int fd ) {
struct flock file_lock;
memset( &file_lock, 0, sizeof( file_lock ) );
memset( &file_lock, '\0', sizeof( file_lock ) );
file_lock.l_type = F_UNLCK;
file_lock.l_whence = SEEK_SET;
file_lock.l_start = 0;

View File

@ -157,14 +157,14 @@ lutil_MD5Final( unsigned char *digest, struct lutil_MD5Context *ctx )
/* Pad out to 56 mod 64 */
if (count < 8) {
/* Two lots of padding: Pad the first block to 64 bytes */
memset(p, 0, count);
memset(p, '\0', count);
lutil_MD5Transform(ctx->buf, ctx->in);
/* Now fill the next block with 56 bytes */
memset(ctx->in, 0, 56);
memset(ctx->in, '\0', 56);
} else {
/* Pad block to 56 bytes */
memset(p, 0, count-8);
memset(p, '\0', count-8);
}
/* Append length in bits and transform */
@ -176,7 +176,7 @@ lutil_MD5Final( unsigned char *digest, struct lutil_MD5Context *ctx )
putu32(ctx->buf[1], digest + 4);
putu32(ctx->buf[2], digest + 8);
putu32(ctx->buf[3], digest + 12);
memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
memset(ctx, '\0', sizeof(ctx)); /* In case it's sensitive */
}
#ifndef ASM_MD5

View File

@ -33,7 +33,7 @@ int lutil_pair( LBER_SOCKET_T sds[2] )
if ( sd == AC_SOCKET_INVALID )
return sd;
(void) memset( (void*) &si, 0, len );
(void) memset( (void*) &si, '\0', len );
si.sin_family = AF_INET;
si.sin_port = 0;
si.sin_addr.s_addr = htonl( INADDR_LOOPBACK );

View File

@ -141,7 +141,7 @@ access_allowed(
}
ACL_INIT(mask);
memset(matches, 0, sizeof(matches));
memset(matches, '\0', sizeof(matches));
control = ACL_BREAK;
a = NULL;
@ -171,7 +171,7 @@ access_allowed(
break;
}
memset(matches, 0, sizeof(matches));
memset(matches, '\0', sizeof(matches));
}
if ( ACL_IS_INVALID( mask ) ) {

View File

@ -19,7 +19,7 @@
int back_dnssrv_LTX_init_module(int argc, char *argv[]) {
BackendInfo bi;
memset( &bi, 0, sizeof(bi) );
memset( &bi, '\0', sizeof(bi) );
bi.bi_type = "dnssrv";
bi.bi_init = dnssrv_back_initialize;

View File

@ -36,7 +36,7 @@
int back_ldap_LTX_init_module(int argc, char *argv[]) {
BackendInfo bi;
memset( &bi, 0, sizeof(bi) );
memset( &bi, '\0', sizeof(bi) );
bi.bi_type = "ldap";
bi.bi_init = ldap_back_initialize;

View File

@ -23,8 +23,6 @@ LDAP_BEGIN_DECL
#define DEFAULT_DB_DIRECTORY LDAP_RUNDIR LDAP_DIRSEP "openldap-ldbm"
#define DEFAULT_MODE 0600
#define SUBLEN 3
#define DN_BASE_PREFIX SLAP_INDEX_EQUALITY_PREFIX
#define DN_ONE_PREFIX '%'
#define DN_SUBTREE_PREFIX '@'

View File

@ -36,6 +36,7 @@ typedef struct ldbm_entry_info {
Entry *lei_lrunext; /* for cache lru list */
Entry *lei_lruprev;
} EntryInfo;
#undef LEI
#define LEI(e) ((EntryInfo *) ((e)->e_private))
static int cache_delete_entry_internal(Cache *cache, Entry *e);

View File

@ -173,7 +173,7 @@ idl_fetch(
if ( (tmp[i] = idl_fetch_one( be, db, data )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
"idl_fetch of (%s) returns NULL\n", data.dptr, 0, 0 );
"idl_fetch: one returned NULL\n", 0, 0, 0 );
continue;
}
@ -313,8 +313,8 @@ idl_change_first(
/* delete old key block */
if ( (rc = ldbm_cache_delete( db, bkey )) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"ldbm_delete of (%s) returns %d\n", bkey.dptr, rc,
0 );
"idl_change_first: ldbm_cache_delete returned %d\n",
rc, 0, 0 );
return( rc );
}
@ -323,7 +323,7 @@ idl_change_first(
if ( (rc = idl_store( be, db, bkey, b )) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"idl_store of (%s) returns %d\n", bkey.dptr, rc, 0 );
"idl_change_first: idl_store returned %d\n", rc, 0, 0 );
return( rc );
}
@ -331,7 +331,7 @@ idl_change_first(
ID_BLOCK_ID(h, pos) = ID_BLOCK_ID(b, 0);
if ( (rc = idl_store( be, db, hkey, h )) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"idl_store of (%s) returns %d\n", hkey.dptr, rc, 0 );
"idl_change_first: idl_store returned %d\n", rc, 0, 0 );
return( rc );
}
@ -352,11 +352,6 @@ idl_insert_key(
Datum k2;
if ( (idl = idl_fetch_one( be, db, key )) == NULL ) {
#ifdef LDBM_DEBUG
Statslog( LDAP_DEBUG_STATS, "=> idl_insert_key(): no key yet\n",
0, 0, 0, 0, 0 );
#endif
idl = idl_alloc( 1 );
ID_BLOCK_ID(idl, ID_BLOCK_NIDS(idl)++) = id;
rc = idl_store( be, db, key, idl );
@ -449,8 +444,8 @@ idl_insert_key(
cont_id( k2, ID_BLOCK_ID(idl, i) );
if ( (tmp = idl_fetch_one( be, db, k2 )) == NULL ) {
Debug( LDAP_DEBUG_ANY, "nonexistent continuation block (%s)\n",
k2.dptr, 0, 0 );
Debug( LDAP_DEBUG_ANY, "idl_insert_key: nonexistent continuation block\n",
0, 0, 0 );
cont_free( k2 );
idl_free( idl );
return( -1 );
@ -461,7 +456,7 @@ idl_insert_key(
case 0: /* id inserted ok */
if ( (rc = idl_store( be, db, k2, tmp )) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"idl_store of (%s) returns %d\n", k2.dptr, rc, 0 );
"idl_insert_key: idl_store returned %d\n", rc, 0, 0 );
}
break;
@ -494,8 +489,8 @@ idl_insert_key(
cont_id( k2, ID_BLOCK_ID(idl, i) );
if ( (tmp2 = idl_fetch_one( be, db, k2 )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
"idl_fetch_one (%s) returns NULL\n",
k2.dptr, 0, 0 );
"idl_insert_key: idl_fetch_one returned NULL\n",
0, 0, 0 );
/* split the original block */
cont_free( k2 );
goto split;
@ -523,7 +518,7 @@ idl_insert_key(
memcpy(k3.dptr, k2.dptr, k3.dsize);
if ( (rc = idl_store( be, db, k3, tmp )) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"idl_store of (%s) returns %d\n", k3.dptr, rc, 0 );
"idl_insert_key: idl_store returned %d\n", rc, 0, 0 );
}
free( k3.dptr );
@ -550,7 +545,7 @@ idl_insert_key(
*/
if ( rc == 2 ) {
Debug( LDAP_DEBUG_ANY,
"id %ld already in next block\n",
"idl_insert_key: id %ld already in next block\n",
id, 0, 0 );
}
@ -772,7 +767,7 @@ idl_delete_key (
if ( (tmp = idl_fetch_one( be, db, data )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
"idl_fetch of (%s) returns NULL\n", data.dptr, 0, 0 );
"idl_delete_key: idl_fetch of returned NULL\n", 0, 0, 0 );
continue;
}
/*

View File

@ -20,7 +20,7 @@
int back_ldbm_LTX_init_module(int argc, char *argv[]) {
BackendInfo bi;
memset( &bi, 0, sizeof(bi) );
memset( &bi, '\0', sizeof(bi) );
bi.bi_type = "ldbm";
bi.bi_init = ldbm_back_initialize;

View File

@ -15,7 +15,7 @@
int back_passwd_LTX_init_module(int argc, char *argv[]) {
BackendInfo bi;
memset( &bi, 0, sizeof(bi) );
memset( &bi, '\0', sizeof(bi) );
bi.bi_type = "passwd";
bi.bi_init = passwd_back_initialize;

View File

@ -36,7 +36,7 @@ ldap_pvt_thread_mutex_t perl_interpreter_mutex;
int back_perl_LTX_init_module(int argc, char *argv[]) {
BackendInfo bi;
memset( &bi, 0, sizeof(bi) );
memset( &bi, '\0', sizeof(bi) );
bi.bi_type = "perl";
bi.bi_init = perl_back_initialize;
@ -125,7 +125,7 @@ perl_back_db_init(
)
{
be->be_private = (PerlBackend *) ch_malloc( sizeof(PerlBackend) );
memset( be->be_private, 0, sizeof(PerlBackend));
memset( be->be_private, '\0', sizeof(PerlBackend));
Debug( LDAP_DEBUG_TRACE, "perl backend db init\n", 0, 0, 0 );

View File

@ -19,7 +19,7 @@
int back_shell_LTX_init_module(int argc, char *argv[]) {
BackendInfo bi;
memset( &bi, 0, sizeof(bi) );
memset( &bi, '\0', sizeof(bi) );
bi.bi_type = "shell";
bi.bi_init = shell_back_initialize;

View File

@ -24,7 +24,7 @@
int backsql_LTX_init_module(int argc, char *argv[]) {
BackendInfo bi;
memset( &bi, 0, sizeof(bi) );
memset( &bi, '\0', sizeof(bi) );
bi.bi_type = "sql";
bi.bi_init = backbacksql_initialize;

View File

@ -25,7 +25,7 @@ ldap_pvt_thread_mutex_t tcl_interpreter_mutex;
void back_tcl_LTX_init_module(int argc, char *argv[]) {
BackendInfo bi;
memset( &bi, 0, sizeof(bi) );
memset( &bi, '\0', sizeof(bi) );
bi.bi_type = "tcl";
bi.bi_init = tcl_back_initialize;

View File

@ -135,7 +135,7 @@ int sasl_init( void )
#ifdef RESTRICT_SASL
{
sasl_security_properties_t secprops;
memset(&secprops, 0, sizeof(secprops));
memset(&secprops, '\0', sizeof(secprops));
secprops.security_flags = SASL_SEC_NOPLAINTEXT | SASL_SEC_NOANONYMOUS;
secprops.property_names = NULL;
secprops.property_values = NULL;

View File

@ -703,9 +703,6 @@ LIBSLAPD_F (int) slapMode;
#define SLAP_MODE 0x0003
#define SLAP_TRUNCATE_MODE 0x0100
#ifdef SLAPD_BDB2
#define SLAP_TIMED_MODE 0x1000
#endif
/* temporary aliases */
typedef BackendDB Backend;

View File

@ -63,7 +63,7 @@ St_add(
st->st_data[ ind ]->hostname = strdup( ri->ri_hostname );
st->st_data[ ind ]->port = ri->ri_port;
memset( st->st_data[ ind ]->last, 0, sizeof( st->st_data[ ind ]->last ));
memset( st->st_data[ ind ]->last, '\0', sizeof( st->st_data[ ind ]->last ));
st->st_data[ ind ]->seq = 0;
ldap_pvt_thread_mutex_unlock( &(st->st_mutex ));