From: Kurt Zeilenga Date: Wed, 18 Oct 2000 00:29:21 +0000 (+0000) Subject: remove lint X-Git-Tag: LDBM_PRE_GIANT_RWLOCK~1711 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7fad68f7b4f851b068ecc409249e298303d6d196;p=openldap remove lint --- diff --git a/libraries/liblutil/debug.c b/libraries/liblutil/debug.c index 1e3a51f8b5..e56c159a0a 100644 --- a/libraries/liblutil/debug.c +++ b/libraries/liblutil/debug.c @@ -3,26 +3,11 @@ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file */ -/* - * Copyright (c) 1996, 1998 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ #include "portable.h" #include +#include #include #include @@ -32,8 +17,6 @@ #include "ldap_defaults.h" #include "lber.h" -static FILE *log_file; - struct M2S { char *mnemonic; @@ -49,7 +32,22 @@ struct DEBUGLEVEL static struct DEBUGLEVEL **levelArray; static long numLevels = 0; -int global_level = 0; +static FILE *log_file = NULL; +static int global_level = 0; + +#if 0 +#ifdef LDAP_SYSLOG +static int use_syslog = 0; + +static int debug2syslog(int l) { + switch (l) { + /* insert mapping cases here */ + default: + } + return LOG_DEBUG +} +#endif +#endif static char *lutil_levels[] = {"emergency", "alert", "critical", "error", "warning", "notice", @@ -122,91 +120,89 @@ void lutil_log_int(FILE* file, char *subsys, int level, const char *fmt, va_list struct tm *today; int i; - if ( levelArray == NULL ) return; /* logging isn't set up */ - /* - * Look for the subsystem in the level array. When we find it, break out of the - * loop. - */ - for( i = 0; i < numLevels; i++ ) - { + if ( levelArray == NULL ) return; /* logging isn't set up */ + + /* + * Look for the subsystem in the level array. When we find it, + * break out of the loop. + */ + for( i = 0; i < numLevels; i++ ) { if ( levelArray[i] == NULL ) return; if ( ! strcasecmp( levelArray[i]->subsystem, subsys ) ) break; } - /* - * If we didn't find the subsystem, or the set level is less than - * the requested output level, don't output it. - */ - if ( (level > global_level) && - ((i > numLevels ) || ( level > levelArray[i]->level )) ) + /* + * If we didn't find the subsystem, or the set level is less than + * the requested output level, don't output it. + */ + if ( (level > global_level) && + ((i > numLevels ) || ( level > levelArray[i]->level )) ) + { return; - -#if 0 -#ifdef HAVE_WINSOCK - if( log_file == NULL ) { - log_file = fopen( LDAP_RUNDIR LDAP_DIRSEP "openldap.log", "w" ); - - if ( log_file == NULL ) - log_file = fopen( "openldap.log", "w" ); - - if ( log_file == NULL ) - return; - - ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, log_file ); } -#endif -#endif - /* - * Stick the time in the buffer to output. Kurt doesn't like - * doing this here, but NT can't pipe to a timestamp program - * like Unix can, and I don't think it costs much. - */ +#ifdef HAVE_WINSOCK +#define BUFOFFSET 18 + /* + * Stick the time in the buffer to output when using Winsock + * as NT can't pipe to a timestamp program like Unix can. + * This, of course, makes some logs hard to read. + */ time( &now ); today = localtime( &now ); sprintf( buffer, "%4d%02d%02d:%02d:%02d:%02d ", today->tm_year + 1900, today->tm_mon + 1, today->tm_mday, today->tm_hour, today->tm_min, today->tm_sec ); +#else +#define BUFOFFSET 0 +#endif - /* - * format the output data. - */ + /* + * format the output data. + */ #ifdef HAVE_VSNPRINTF - vsnprintf( &buffer[18], sizeof(buffer)-18, fmt, vl ); + vsnprintf( &buffer[BUFOFFSET], sizeof(buffer)-BUFOFFSET, fmt, vl ); #else - vsprintf( &buffer[18], fmt, vl ); + vsprintf( &buffer[BUFOFFSET], fmt, vl ); #endif buffer[sizeof(buffer)-1] = '\0'; - /* - * If the user set up a file using - * ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, file), use - * it. Otherwise, just output to stderr. - */ - if( file != NULL ) { - fputs( buffer, file ); - fflush( file ); +#if 0 +#ifdef LDAP_SYSLOG + /* we're configured to use syslog */ + if( use_syslog ) { + syslog( debug2syslog(level), buffer ); + return; } - else - { - fputs( buffer, stderr ); - } +#endif +#endif -/* - * Kurt or someone needs to decide what to do about this. This - * code will log to syslog if the level is less than a normal - * debug level (meaning a warning or error of some kind). However, - * having the code here means that ldap_syslog has to be defined. - */ #if 0 -#ifdef LDAP_SYSLOG - if ( level < LDAP_LEVEL_ENTRY && level >= ldap_syslog ) - { - syslog( level, buffer ); +#ifdef HAVE_WINSOCK + if( log_file == NULL ) { + log_file = fopen( LDAP_RUNDIR LDAP_DIRSEP "openldap.log", "w" ); + + if ( log_file == NULL ) + log_file = fopen( "openldap.log", "w" ); + + if ( log_file == NULL ) + return; + + ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, log_file ); } #endif #endif + + if( file != NULL ) { + /* + * Use stderr unless file was specified via: + * ber_set_option( NULL, LBER_OPT_LOG_PRINT_FILE, file) + */ + file = stderr; + } + + fputs( buffer, file ); } /* diff --git a/libraries/liblutil/hash.c b/libraries/liblutil/hash.c index f801ffe317..172b0b8d8d 100644 --- a/libraries/liblutil/hash.c +++ b/libraries/liblutil/hash.c @@ -5,15 +5,11 @@ */ #include "portable.h" -#include - -/* include socket.h to get sys/types.h and/or winsock2.h */ -#include #include /* offset and prime for 32-bit FNV-1 */ -#define HASH_OFFSET 0x811c9dc5 +#define HASH_OFFSET 0x811c9dc5U #define HASH_PRIME 16777619 @@ -60,8 +56,8 @@ lutil_HASHFinal( unsigned char *digest, struct lutil_HASHContext *ctx ) { ber_uint_t h = ctx->hash; - digest[0] = h & 0xff; - digest[1] = (h>>8) & 0xff; - digest[2] = (h>>16) & 0xff; - digest[3] = (h>>24) & 0xff; + digest[0] = h & 0xffU; + digest[1] = (h>>8) & 0xffU; + digest[2] = (h>>16) & 0xffU; + digest[3] = (h>>24) & 0xffU; } diff --git a/libraries/liblutil/passwd.c b/libraries/liblutil/passwd.c index 427af165a0..8fc3a07ac9 100644 --- a/libraries/liblutil/passwd.c +++ b/libraries/liblutil/passwd.c @@ -521,9 +521,10 @@ static int chk_smd5( /* hash credentials with salt */ lutil_MD5Init(&MD5context); lutil_MD5Update(&MD5context, - (const unsigned char *) cred->bv_val, cred->bv_len ); + (const unsigned char *) cred->bv_val, + cred->bv_len ); lutil_MD5Update(&MD5context, - (const unsigned char *) &orig_pass[sizeof(MD5digest)], + &orig_pass[sizeof(MD5digest)], rc - sizeof(MD5digest)); lutil_MD5Final(MD5digest, &MD5context); @@ -558,7 +559,8 @@ static int chk_md5( /* hash credentials with salt */ lutil_MD5Init(&MD5context); lutil_MD5Update(&MD5context, - (const unsigned char *) cred->bv_val, cred->bv_len ); + (const unsigned char *) cred->bv_val, + cred->bv_len ); lutil_MD5Final(MD5digest, &MD5context); /* compare */ diff --git a/libraries/liblutil/sockpair.c b/libraries/liblutil/sockpair.c index 648009d315..ba42133df6 100644 --- a/libraries/liblutil/sockpair.c +++ b/libraries/liblutil/sockpair.c @@ -20,18 +20,19 @@ * this function is best implemented using a single pipe() call. */ -int lutil_pair( LBER_SOCKET_T sds[2] ) +int lutil_pair( ber_socket_t sds[2] ) { #ifdef USE_PIPE return pipe( sds ); #else struct sockaddr_in si; int rc, len = sizeof(si); - LBER_SOCKET_T sd; + ber_socket_t sd; sd = socket( AF_INET, SOCK_DGRAM, 0 ); - if ( sd == AC_SOCKET_INVALID ) + if ( sd == AC_SOCKET_INVALID ) { return sd; + } (void) memset( (void*) &si, '\0', len ); si.sin_family = AF_INET;