Fix printf formats, remove unused variables, add missing prototypes in slapd,
add static/const, add some return types or change to void return type.
This commit is contained in:
Hallvard Furuseth 1999-09-02 08:05:17 +00:00
parent 1886192447
commit c09a2c63e7
29 changed files with 73 additions and 72 deletions

View file

@ -20,7 +20,6 @@
static char *binddn = NULL;
static char *passwd = NULL;
static char *base = NULL;
static char *ldaphost = NULL;
static int ldapport = 0;
static int not, verbose, contoper;

View file

@ -32,7 +32,6 @@
static char *binddn = NULL;
static char *passwd = NULL;
static char *base = NULL;
static char *ldaphost = NULL;
static int ldapport = 0;
static int not, verbose, contoper;

View file

@ -68,7 +68,7 @@ Salt;
typedef struct hash_t
{
char *name;
const char *name;
unsigned int namesz;
char *(*func) (const char *, Salt *);
unsigned char takes_salt;
@ -89,7 +89,7 @@ static int auto_gen_pw = 0;
* pw_encode() essentially base64 encodes a password and its salt
*/
char *
static char *
pw_encode (unsigned char *passwd, Salt * salt, unsigned int len)
{
int salted = salt && salt->salt && salt->len;
@ -123,7 +123,7 @@ pw_encode (unsigned char *passwd, Salt * salt, unsigned int len)
* if you'd like to write a better salt generator, please, be my guest.
*/
void
static void
make_salt (Salt * salt, unsigned int len)
{
@ -141,7 +141,7 @@ make_salt (Salt * salt, unsigned int len)
* password generator
*/
char *
static char *
gen_pass (unsigned int len)
{
static const unsigned char autogen[] =
@ -160,7 +160,7 @@ gen_pass (unsigned int len)
}
#ifdef SLAPD_CLEARTEXT
char *
static char *
hash_none (const char *pw_in, Salt * salt)
{
return (strdup (pw_in));
@ -168,7 +168,7 @@ hash_none (const char *pw_in, Salt * salt)
#endif
#ifdef SLAPD_CRYPT
char *
static char *
hash_crypt (const char *pw_in, Salt * salt)
{
static const unsigned char crypt64[] =
@ -198,7 +198,7 @@ hash_crypt (const char *pw_in, Salt * salt)
}
#endif
char *
static char *
hash_md5 (const char *pw_in, Salt * salt)
{
lutil_MD5_CTX MD5context;
@ -214,7 +214,7 @@ hash_md5 (const char *pw_in, Salt * salt)
return (pw_encode (MD5digest, salt, sizeof (MD5digest)));
}
char *
static char *
hash_sha1 (const char *pw_in, Salt * salt)
{
lutil_SHA1_CTX SHA1context;
@ -230,7 +230,7 @@ hash_sha1 (const char *pw_in, Salt * salt)
return (pw_encode (SHA1digest, salt, sizeof (SHA1digest)));
}
static Hash hashes[] =
static const Hash hashes[] =
{
#ifdef SLAPD_CLEARTEXT
{"none", 4, hash_none, 0, HASHTYPE_NONE, HASHTYPE_NONE, 0},
@ -245,7 +245,7 @@ static Hash hashes[] =
{NULL, 0, NULL, 0, HASHTYPE_NONE, HASHTYPE_NONE, 0}
};
int
static int
modify_dn (LDAP * ld, char *targetdn, char *pwattr, char *oldpw,
char *newpw, HashTypes htype, Salt * salt)
{
@ -325,8 +325,8 @@ modify_dn (LDAP * ld, char *targetdn, char *pwattr, char *oldpw,
return (ret);
}
void
usage (char *s)
static void
usage(const char *s)
{
fprintf (stderr, "Usage: %s [options] [filter]\n", s);
fprintf (stderr, " -a attrib\tpassword attribute (default: " LDAP_PASSWD_ATTRIB ")\n");

View file

@ -21,7 +21,7 @@
#define DEFSEP "="
static void
usage( char *s )
usage( const char *s )
{
fprintf( stderr,
"usage: %s [options] filter [attributes...]\nwhere:\n"
@ -561,7 +561,8 @@ static int dosearch(
}
void print_entry(
static void
print_entry(
LDAP *ld,
LDAPMessage *entry,
int attrsonly)
@ -679,7 +680,7 @@ void print_entry(
}
int
static int
write_ldif( int type, char *name, char *value, ber_len_t vallen )
{
char *ldif;

View file

@ -1026,8 +1026,8 @@ dgram_read( Sockbuf *sb, void *buf, ber_len_t len )
if ( sb->sb_debug ) {
ber_log_printf( LDAP_DEBUG_ANY, sb->sb_debug,
"dgram_read udp_read %d bytes\n",
rc );
"dgram_read udp_read %ld bytes\n",
(long) rc );
if ( rc > 0 )
ber_log_bprint( LDAP_DEBUG_PACKETS, sb->sb_debug,
buf, rc );

View file

@ -261,8 +261,8 @@ ldap_add_result_to_cache( LDAP *ld, LDAPMessage *result )
LDAPMessage *m, **mp, *req, *new, *prev;
int err, keep;
Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %d, type %d\n",
result->lm_msgid, result->lm_msgtype, 0 );
Debug( LDAP_DEBUG_TRACE, "ldap_add_result_to_cache: id %ld, type %ld\n",
(long) result->lm_msgid, (long) result->lm_msgtype, 0 );
if ( ld->ld_cache == NULL ||
( ld->ld_cache->lc_enabled == 0 )) {
@ -394,8 +394,8 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
prev = NULL;
hash = cache_hash( &reqber );
for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULL; m = next ) {
Debug( LDAP_DEBUG_TRACE,"cc: examining id %d,type %d\n",
m->lm_msgid, m->lm_msgtype, 0 );
Debug( LDAP_DEBUG_TRACE,"cc: examining id %ld,type %ld\n",
(long) m->lm_msgid, (long) m->lm_msgtype, 0 );
if ( difftime(c_time, m->lm_time) > ld->ld_cache->lc_timeout ) {
/* delete expired message */
next = m->lm_next;
@ -441,8 +441,8 @@ ldap_check_cache( LDAP *ld, ber_tag_t msgtype, BerElement *request )
prev->lm_chain = new;
}
prev = new;
Debug( LDAP_DEBUG_TRACE, "cc: added type %d\n",
new->lm_msgtype, 0, 0 );
Debug( LDAP_DEBUG_TRACE, "cc: added type %ld\n",
(long) new->lm_msgtype, 0, 0 );
}
Debug( LDAP_DEBUG_TRACE, "cc: result returned from cache\n", 0, 0, 0 );

View file

@ -123,7 +123,7 @@ decode_answer( unsigned char *answer, ber_len_t len )
rr_len = _getshort( p );
p += INT16SZ;
if ( class == C_IN && type == T_TXT ) {
int i, n, pref, txt_len;
int pref, txt_len;
char *q, *r;
q = (char *)p;

View file

@ -187,8 +187,8 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s, struct sockaddr_in *sin, int async)
tv.tv_sec = opt_tv->tv_sec;
}
osip_debug(ld, "ldap_connect_timeout: fd: %d tm: %d async: %d\n",
s, opt_tv ? tv.tv_sec : -1, async);
osip_debug(ld, "ldap_connect_timeout: fd: %d tm: %ld async: %d\n",
s, opt_tv ? tv.tv_sec : -1L, async);
if ( ldap_pvt_ndelay_on(ld, s) == -1 )
return ( -1 );

View file

@ -340,7 +340,7 @@ try_read1msg(
if (( lr = ldap_find_request_by_msgid( ld, id )) == NULL ) {
Debug( LDAP_DEBUG_ANY,
"no request for response with msgid %ld (tossing)\n",
id, 0, 0 );
(long) id, 0, 0 );
ber_free( ber, 1 );
return( -2 ); /* continue looking */
}
@ -352,10 +352,10 @@ try_read1msg(
return( -1 );
}
Debug( LDAP_DEBUG_TRACE, "ldap_read: %s msgid %ld, original id %d\n",
Debug( LDAP_DEBUG_TRACE, "ldap_read: %s msgid %ld, original id %ld\n",
( tag == LDAP_RES_SEARCH_ENTRY ) ? "entry" :
( tag == LDAP_RES_SEARCH_REFERENCE ) ? "reference" : "result",
id, lr->lr_origid );
(long) id, (long) lr->lr_origid );
id = lr->lr_origid;
refer_cnt = 0;
@ -428,7 +428,7 @@ Debug( LDAP_DEBUG_TRACE,
id = lr->lr_msgid;
tag = lr->lr_res_msgtype;
Debug( LDAP_DEBUG_ANY, "request %ld done\n",
id, 0, 0 );
(long) id, 0, 0 );
Debug( LDAP_DEBUG_TRACE,
"res_errno: %d, res_error: <%s>, res_matched: <%s>\n",
lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "",
@ -510,8 +510,8 @@ lr->lr_res_matched ? lr->lr_res_matched : "" );
return( -2 ); /* continue looking */
}
Debug( LDAP_DEBUG_TRACE, "adding response id %d type %d:\n",
new->lm_msgid, new->lm_msgtype, 0 );
Debug( LDAP_DEBUG_TRACE, "adding response id %ld type %ld:\n",
(long) new->lm_msgid, (long) new->lm_msgtype, 0 );
/* part of a search response - add to end of list of entries */
for ( tmp = l; tmp->lm_chain != NULL &&

View file

@ -1260,9 +1260,6 @@ ldap_str2attributetype( const char * s, int * code, const char ** errp )
int seen_substr = 0;
int seen_syntax = 0;
int seen_usage = 0;
int seen_kind = 0;
int seen_must = 0;
int seen_may = 0;
LDAP_ATTRIBUTE_TYPE * at;
char ** ssdummy;
const char * savepos;

View file

@ -517,7 +517,7 @@ acl_check_modlist(
}
#ifdef SLAPD_ACI_ENABLED
char *
static char *
aci_bvstrdup (struct berval *bv)
{
char *s;
@ -530,7 +530,7 @@ aci_bvstrdup (struct berval *bv)
return(s);
}
int
static int
aci_strbvcmp (char *s, struct berval *bv)
{
int res, len;
@ -546,7 +546,7 @@ aci_strbvcmp (char *s, struct berval *bv)
return(0);
}
int
static int
aci_get_part (struct berval *list, int ix, char sep, struct berval *bv)
{
int len;
@ -581,7 +581,7 @@ aci_get_part (struct berval *list, int ix, char sep, struct berval *bv)
return(bv->bv_len);
}
int
static int
aci_list_has_right (struct berval *list, int access, int action)
{
struct berval bv;
@ -640,7 +640,7 @@ aci_list_has_right (struct berval *list, int access, int action)
#endif
}
int
static int
aci_list_has_attr (struct berval *list, char *attr)
{
struct berval bv;
@ -654,10 +654,10 @@ aci_list_has_attr (struct berval *list, char *attr)
return(0);
}
int
static int
aci_list_has_attr_right (struct berval *list, char *attr, int access, int action)
{
struct berval bv, entry;
struct berval bv;
int i, found;
/* loop through each rights/attr pair, skip first part (action) */
@ -674,7 +674,7 @@ aci_list_has_attr_right (struct berval *list, char *attr, int access, int action
return(found);
}
int
static int
aci_list_has_permission (struct berval *list, char *attr, int access)
{
struct berval perm, actn;
@ -707,7 +707,7 @@ aci_list_has_permission (struct berval *list, char *attr, int access)
return(0);
}
int
static int
aci_group_member (
struct berval *subj,
char *grpoc,

View file

@ -48,6 +48,9 @@ struct ldapinfo {
struct ldapconn *ldap_back_getconn(struct ldapinfo *li, struct slap_conn *conn,
struct slap_op *op);
void ldap_back_dobind(struct ldapconn *lc, Operation *op);
int ldap_back_op_result(struct ldapconn *lc, Operation *op);
int back_ldap_LTX_init_module(int argc, char *argv[]);
LDAP_END_DECL

View file

@ -91,6 +91,7 @@ ldap_back_getconn(struct ldapinfo *li, Connection *conn, Operation *op)
return( lc );
}
void
ldap_back_dobind(struct ldapconn *lc, Operation *op)
{
if (lc->bound)
@ -103,6 +104,7 @@ ldap_back_dobind(struct ldapconn *lc, Operation *op)
lc->bound = 1;
}
int
ldap_back_op_result(struct ldapconn *lc, Operation *op)
{
int err;

View file

@ -32,6 +32,9 @@
#include "slap.h"
#include "back-ldap.h"
static void ldap_send_entry( Backend *be, Operation *op, struct ldapconn *lc,
LDAPMessage *e, char **attrs, int attrsonly );
int
ldap_back_search(
Backend *be,
@ -125,6 +128,7 @@ fail: return( ldap_back_op_result(lc, op) );
return( 0 );
}
static void
ldap_send_entry(
Backend *be,
Operation *op,

View file

@ -278,7 +278,6 @@ dn2entry_rw(
int rw
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
ID id;
Entry *e = NULL;
char *pdn;

View file

@ -21,7 +21,6 @@
static ID
next_id_read( Backend *be )
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
ID id = NOID;
Datum key, data;
DBCache *db;

View file

@ -353,7 +353,6 @@ search_candidates(
int manageDSAit
)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_private;
ID_BLOCK *candidates;
Filter *f, *rf, *af, *lf;

View file

@ -36,7 +36,7 @@ shell_back_add(
/* write out the request to the add process */
fprintf( wfp, "ADD\n" );
fprintf( wfp, "msgid: %ld\n", op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
ldap_pvt_thread_mutex_lock( &entry2str_mutex );
fprintf( wfp, "%s", entry2str( e, &len ) );

View file

@ -43,7 +43,7 @@ shell_back_bind(
/* write out the request to the bind process */
fprintf( wfp, "BIND\n" );
fprintf( wfp, "msgid: %ld\n", op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
fprintf( wfp, "method: %d\n", method );

View file

@ -37,7 +37,7 @@ shell_back_compare(
/* write out the request to the compare process */
fprintf( wfp, "COMPARE\n" );
fprintf( wfp, "msgid: %ld\n", op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
fprintf( wfp, "%s: %s\n", ava->ava_type, ava->ava_value.bv_val );

View file

@ -36,7 +36,7 @@ shell_back_delete(
/* write out the request to the delete process */
fprintf( wfp, "DELETE\n" );
fprintf( wfp, "msgid: %ld\n", op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
fclose( wfp );

View file

@ -38,7 +38,7 @@ shell_back_modify(
/* write out the request to the modify process */
fprintf( wfp, "MODIFY\n" );
fprintf( wfp, "msgid: %ld\n", op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
for ( ; ml != NULL; ml = ml->ml_next ) {

View file

@ -52,7 +52,7 @@ shell_back_modrdn(
/* write out the request to the modrdn process */
fprintf( wfp, "MODRDN\n" );
fprintf( wfp, "msgid: %ld\n", op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", dn );
fprintf( wfp, "newrdn: %s\n", newrdn );

View file

@ -27,9 +27,7 @@ shell_back_search(
)
{
struct shellinfo *si = (struct shellinfo *) be->be_private;
int i, rc, bsize, len;
int err;
char *matched, *info;
int i;
FILE *rfp, *wfp;
if ( si->si_search == NULL ) {
@ -47,7 +45,7 @@ shell_back_search(
/* write out the request to the search process */
fprintf( wfp, "SEARCH\n" );
fprintf( wfp, "msgid: %ld\n", op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "base: %s\n", base );
fprintf( wfp, "scope: %d\n", scope );

View file

@ -35,7 +35,7 @@ shell_back_unbind(
/* write out the request to the unbind process */
fprintf( wfp, "UNBIND\n" );
fprintf( wfp, "msgid: %ld\n", op->o_msgid );
fprintf( wfp, "msgid: %ld\n", (long) op->o_msgid );
print_suffixes( wfp, be );
fprintf( wfp, "dn: %s\n", (conn->c_dn ? conn->c_dn : "") );
fclose( wfp );

View file

@ -59,7 +59,6 @@ static
volatile sig_atomic_t slapd_shutdown = 0;
static ldap_pvt_thread_t listener_tid;
static volatile sig_atomic_t slapd_listener = 0;
static struct slap_daemon {
ldap_pvt_thread_mutex_t sd_mutex;
@ -170,7 +169,7 @@ static void slapd_close(ber_socket_t s) {
}
Listener *
static Listener *
open_listener(
const char* url,
int port,
@ -447,7 +446,7 @@ slapd_daemon_task(
int err = sock_errno();
Debug( LDAP_DEBUG_ANY,
"daemon: listen(%s, 5) failed errno=%d (%s)\n",
(long) slap_listeners[l]->sl_url, err,
slap_listeners[l]->sl_url, err,
sock_errstr(err) );
return( (void*)-1 );
}
@ -742,7 +741,7 @@ slapd_daemon_task(
}
#else
for ( i = 0; i < nfds; i++ ) {
int a, r, w;
int r, w;
int is_listener = 0;
for ( l = 0; slap_listeners[l] != NULL; l++ ) {

View file

@ -368,6 +368,9 @@ Syntax *syn_find_desc LDAP_P((const char *syndesc, int *slen));
int syn_add LDAP_P((LDAP_SYNTAX *syn, slap_syntax_check_func *check, const char **err));
MatchingRule *mr_find LDAP_P((const char *mrname));
int mr_add LDAP_P((LDAP_MATCHING_RULE *mr, slap_mr_normalize_func *normalize, slap_mr_compare_func *compare, const char **err));
int case_ignore_normalize LDAP_P((struct berval *val, struct berval **normalized));
int register_syntax LDAP_P((char *desc, slap_syntax_check_func *check ));
int register_matching_rule LDAP_P((char * desc, slap_mr_normalize_func *normalize, slap_mr_compare_func *compare));
void schema_info LDAP_P((Connection *conn, Operation *op, char **attrs, int attrsonly));
int schema_init LDAP_P((void));

View file

@ -556,8 +556,10 @@ diff_centroids(
int nentries
)
{
#ifdef LDBM_ORDERED
Datum okey, nkey;
Datum olast, nlast;
#endif
Datum lastkey, key;
Datum data;
LDAPMod **mods;
@ -573,10 +575,6 @@ diff_centroids(
fflush( stdout );
}
ldbm_datum_init( okey );
ldbm_datum_init( nkey );
ldbm_datum_init( olast );
ldbm_datum_init( nlast );
ldbm_datum_init( lastkey );
ldbm_datum_init( key );
ldbm_datum_init( data );
@ -618,6 +616,11 @@ diff_centroids(
* dual traversal, yielding O(N) performance.
*/
ldbm_datum_init( okey );
ldbm_datum_init( nkey );
ldbm_datum_init( olast );
ldbm_datum_init( nlast );
olast.dptr = NULL;
nlast.dptr = NULL;

View file

@ -89,12 +89,8 @@ main( int argc, char **argv )
scount = 0; ssize = 0;
if ( (bvals = ldap_get_values_len( ld, e, attrs[i] )) != NULL ) {
for ( j = 0; bvals[j] != NULL; j++ ) {
Datum key, data;
char *w;
ldbm_datum_init( key );
ldbm_datum_init( data );
/* update value count */
vcount++;
vsize += bvals[j]->bv_len;