From 6198857fb3f4644a32d608d6b34ae73329c551b8 Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Thu, 15 Aug 2013 15:03:44 -0600
Subject: [PATCH 2/4] fix compiler warnings

---
 admserv/cgi-src40/admpw.c          |    4 +-
 admserv/cgi-src40/config.c         |    9 ++----
 admserv/cgi-src40/dsconfig.c       |    1 +
 admserv/cgi-src40/htmladmin.c      |    1 +
 admserv/cgi-src40/monreplication.c |    1 +
 admserv/cgi-src40/restartsrv.c     |    1 +
 admserv/cgi-src40/sec-activate.c   |    1 +
 admserv/cgi-src40/statpingserv.c   |    1 +
 admserv/cgi-src40/stopsrv.c        |    1 +
 admserv/cgi-src40/ugdsconfig.c     |    1 +
 admserv/cgi-src40/viewdata.c       |    1 +
 admserv/cgi-src40/viewlog.c        |    1 +
 include/libadmin/dbtlibadmin.h     |    2 -
 lib/base/file.cpp                  |    8 -----
 lib/base/nscputil.cpp              |    5 ++-
 lib/libadmin/util.c                |   53 ++++-------------------------------
 lib/libdsa/dsalib_util.c           |    8 -----
 mod_admserv/mod_admserv.c          |    5 +---
 18 files changed, 25 insertions(+), 79 deletions(-)

diff --git a/admserv/cgi-src40/admpw.c b/admserv/cgi-src40/admpw.c
index ff0dc6c..e695881 100644
--- a/admserv/cgi-src40/admpw.c
+++ b/admserv/cgi-src40/admpw.c
@@ -73,11 +73,10 @@ sha1_pw_enc(const char *pwd)
    unsigned char hash[SHA1_LENGTH];
    char *enc;
    char *retval;
-   SECStatus rc;
    int32 pwdlen = strlen(pwd);
 
    /* SHA1 hash the user's key */
-   rc = PK11_HashBuf(SEC_OID_SHA1, hash, (unsigned char *)pwd, pwdlen);
+   PK11_HashBuf(SEC_OID_SHA1, hash, (unsigned char *)pwd, pwdlen);
    /* convert to base64 */
    if (!(enc = BTOA_DataToAscii(hash, sizeof(hash)))) {
       return NULL;
@@ -181,6 +180,7 @@ int main(int argc, char *argv[])
     int errorcode = 0;
     char *configdir = util_get_conf_dir();
 	    
+    (void)_ai; /* get rid of unused variable warning */
     logMsg(" In %s\n", argv[0]);
 
     i18nInit();
diff --git a/admserv/cgi-src40/config.c b/admserv/cgi-src40/config.c
index 74e0a0c..ddb4af3 100644
--- a/admserv/cgi-src40/config.c
+++ b/admserv/cgi-src40/config.c
@@ -155,9 +155,8 @@ int main(int argc, char *argv[])
   char           **inputs = 0;
   char           *operation = 0;
   char           *qs = 0;
-  char           *nameptr, *valptr, *val;
+  char           *nameptr, *valptr;
   char           error_info[128];
-  char           *valsbuf[2];
   int            setFlag = 0, getFlag = 0, forceSetFlag = 0;
   int            ignorePsetErrors = 0;
   AttributeList  resultList, nvl;
@@ -176,11 +175,9 @@ int main(int argc, char *argv[])
   while (waitforever);
 #endif
 
+  (void)_ai; /* get rid of unused variable warning */
   i18nResource = res_find_and_init_resource(PROPERTYDIR, RESOURCE_FILE);
 
-  valsbuf[0] = NULL;
-  valsbuf[1] = NULL;
-
   memset((void *)errp, 0, sizeof(int));
   method = getenv("REQUEST_METHOD");
 
@@ -620,7 +617,7 @@ int main(int argc, char *argv[])
 #endif
 
 	errorCode = PSET_OP_OK;
-	val = psetGetAttrSingleValue(pset, nameptr, &errorCode);
+	(void)psetGetAttrSingleValue(pset, nameptr, &errorCode);
 	if (errorCode && !ignorePsetErrors) {
 	  if (forceSetFlag) 
 	    addSingleValueAttribute(addList, j++, nameptr, valptr);
diff --git a/admserv/cgi-src40/dsconfig.c b/admserv/cgi-src40/dsconfig.c
index 899836b..b35826e 100644
--- a/admserv/cgi-src40/dsconfig.c
+++ b/admserv/cgi-src40/dsconfig.c
@@ -159,6 +159,7 @@ int main(int argc, char *argv[])
 
   logMsg(" In %s\n", argv[0]);
 
+  (void)_ai; /* get rid of unused variable warning */
   i18nInit();
 
   /* GET or POST method */
diff --git a/admserv/cgi-src40/htmladmin.c b/admserv/cgi-src40/htmladmin.c
index 7110526..b168ce7 100644
--- a/admserv/cgi-src40/htmladmin.c
+++ b/admserv/cgi-src40/htmladmin.c
@@ -1582,6 +1582,7 @@ int main(int argc, char *argv[])
     const char *configdir = util_get_conf_dir();
     const char *secdir = util_get_security_dir();
 
+    (void)_ai; /* get rid of unused variable warning */
     i18nResource = res_find_and_init_resource(PROPERTYDIR, RESOURCE_FILE);
     acceptLanguage = "en";
     if (lang) acceptLanguage = strdup(lang);
diff --git a/admserv/cgi-src40/monreplication.c b/admserv/cgi-src40/monreplication.c
index 253dcaf..2b07038 100644
--- a/admserv/cgi-src40/monreplication.c
+++ b/admserv/cgi-src40/monreplication.c
@@ -85,6 +85,7 @@ int main(int argc, char *argv[])
 	char configfile[256] = {'\0'};
 	char *resstr;
 
+	(void)_ai; /* get rid of unused variable warning */
 	i18nInit();
 
 	fprintf(stdout, "Content-type: text/html;charset=utf-8\n\n");
diff --git a/admserv/cgi-src40/restartsrv.c b/admserv/cgi-src40/restartsrv.c
index 87e76bf..69d8853 100644
--- a/admserv/cgi-src40/restartsrv.c
+++ b/admserv/cgi-src40/restartsrv.c
@@ -125,6 +125,7 @@ int main(int argc, char *argv[])
   char           *acceptLanguage = (char*)"en", *lang=getenv((char*)"HTTP_ACCEPT_LANGUAGE");
   Resource       *i18nResource = NULL;
 
+  (void)_ai; /* get rid of unused variable warning */
   i18nResource = res_find_and_init_resource(PROPERTYDIR, RESOURCE_FILE);
 
   if (lang) acceptLanguage = strdup(lang);
diff --git a/admserv/cgi-src40/sec-activate.c b/admserv/cgi-src40/sec-activate.c
index a36f75f..6ae70ed 100644
--- a/admserv/cgi-src40/sec-activate.c
+++ b/admserv/cgi-src40/sec-activate.c
@@ -499,6 +499,7 @@ int main(int argc, char *argv[])
   AdmldapInfo ldapInfo = NULL;
   char *lang;
 
+  (void)_ai; /* get rid of unused variable warning */
   memset((void *)errp, 0, sizeof(int));
   method = getenv("REQUEST_METHOD");
 
diff --git a/admserv/cgi-src40/statpingserv.c b/admserv/cgi-src40/statpingserv.c
index d6e55f7..3fc5616 100644
--- a/admserv/cgi-src40/statpingserv.c
+++ b/admserv/cgi-src40/statpingserv.c
@@ -75,6 +75,7 @@ int main(int argc, char *argv[])
   char *portstr;
   struct PRFileInfo64 prfileinfo;
 
+  (void)_ai; /* get rid of unused variable warning */
   m = getenv("REQUEST_METHOD");
 
   if(!strcmp(m, "GET")) {
diff --git a/admserv/cgi-src40/stopsrv.c b/admserv/cgi-src40/stopsrv.c
index 436989e..b2b83c9 100644
--- a/admserv/cgi-src40/stopsrv.c
+++ b/admserv/cgi-src40/stopsrv.c
@@ -85,6 +85,7 @@ int main(int argc, char *argv[])
   char           *return_format = NULL;
   char           *qs = 0;
 
+  (void)_ai; /* get rid of unused variable warning */
   i18nResource = res_find_and_init_resource(PROPERTYDIR, RESOURCE_FILE);
 
   if (lang) acceptLanguage = strdup(lang);
diff --git a/admserv/cgi-src40/ugdsconfig.c b/admserv/cgi-src40/ugdsconfig.c
index 9be5332..0b23d93 100644
--- a/admserv/cgi-src40/ugdsconfig.c
+++ b/admserv/cgi-src40/ugdsconfig.c
@@ -179,6 +179,7 @@ int main(int argc, char *argv[])
     const char *configdir = util_get_conf_dir();
     const char *secdir = util_get_security_dir();
 
+    (void)_ai; /* get rid of unused variable warning */
     logMsg(" In %s\n", argv[0]);
 
     i18nInit();
diff --git a/admserv/cgi-src40/viewdata.c b/admserv/cgi-src40/viewdata.c
index 7dd5d80..5cba168 100644
--- a/admserv/cgi-src40/viewdata.c
+++ b/admserv/cgi-src40/viewdata.c
@@ -412,6 +412,7 @@ int main(int argc, char *argv[])
 
     AdmldapInfo ldapInfo = get_adm_ldapinfo(configdir, secdir);
 
+    (void)_ai; /* get rid of unused variable warning */
     i18nInit();
 
     if(!get_bindinfo(&binddn, &bindpw))
diff --git a/admserv/cgi-src40/viewlog.c b/admserv/cgi-src40/viewlog.c
index e4ec208..4a36780 100644
--- a/admserv/cgi-src40/viewlog.c
+++ b/admserv/cgi-src40/viewlog.c
@@ -341,6 +341,7 @@ int main(int argc, char *argv[])
     int rc = 0;
     char *configdir = NULL;
 
+    (void)_ai; /* get rid of unused variable warning */
     i18nInit();
 
     fprintf(stdout, "Content-type: text/html;charset=utf-8\n\n");
diff --git a/include/libadmin/dbtlibadmin.h b/include/libadmin/dbtlibadmin.h
index 24048c7..9c40647 100644
--- a/include/libadmin/dbtlibadmin.h
+++ b/include/libadmin/dbtlibadmin.h
@@ -21,8 +21,6 @@
 
 #define LIBRARY_NAME "libadmin"
 
-static char dbtlibadminid[] = "$DBT: libadmin referenced v1 $";
-
 #include "i18n.h"
 
 BEGIN_STR(libadmin)
diff --git a/lib/base/file.cpp b/lib/base/file.cpp
index ac2ece6..0ca4c9b 100644
--- a/lib/base/file.cpp
+++ b/lib/base/file.cpp
@@ -483,19 +483,11 @@ NSAPI_PUBLIC int system_errmsg_fn(char **buff, size_t maxlen)
     char static_error[128];
     char *lmsg = 0; /* Local message pointer */
     size_t msglen = 0;
-    int sys_error = 0;
     PRErrorCode nscp_error;
 #ifdef XP_WIN32
     LPTSTR sysmsg = 0;
 #endif
 
-
-    /* Grab the OS error message */
-#ifdef XP_WIN32
-    sys_error = GetLastError();
-#else
-    sys_error = errno;
-#endif
     nscp_error = PR_GetError();
 
     /* If there is a NSPR error, but it is "unknown", try to get the OSError
diff --git a/lib/base/nscputil.cpp b/lib/base/nscputil.cpp
index 77e7a6e..1fb6a27 100644
--- a/lib/base/nscputil.cpp
+++ b/lib/base/nscputil.cpp
@@ -833,11 +833,12 @@ util_waitpid(pid_t pid, int *statptr, int options)
     for(rv = 0; !rv; PR_Sleep(500)) {
 	rv = waitpid(pid, statptr, options | WNOHANG);
 	if (rv == -1) {
-	    if (errno == EINTR)
+	    if (errno == EINTR) {
 		rv = 0; /* sleep and try again */
-	    else
+	    } else {
 //		ereport(LOG_WARN, "waitpid failed for pid %d:%s", pid, system_errmsg());
 	    ;
+	    }
 	}
     }
     return rv;
diff --git a/lib/libadmin/util.c b/lib/libadmin/util.c
index be651b4..29c77b5 100644
--- a/lib/libadmin/util.c
+++ b/lib/libadmin/util.c
@@ -1558,17 +1558,19 @@ util_ldap_init(
         if (secure > 0) {
 #if defined(USE_OPENLDAP)
             int optval = 0;
+#else
+            LDAP *myld = NULL;
 #endif /* !USE_OPENLDAP */
             int ssl_strength = 0;
-            LDAP *myld = NULL;
 
+#if !defined(USE_OPENLDAP)
             /* we can only use the set functions below with a real
                LDAP* if it has already gone through ldapssl_init -
                so, use NULL if using starttls */
             if (secure == 1) {
                 myld = ld;
             }
-
+#endif
             /* verify certificate only */
 #if defined(USE_OPENLDAP)
             ssl_strength = LDAP_OPT_X_TLS_NEVER;
@@ -1683,55 +1685,12 @@ util_ldap_bind(
 {
     int rc = LDAP_SUCCESS;
     int err = LDAP_SUCCESS;
-    int secure = 0;
     struct berval bvcreds = {0, NULL};
     LDAPMessage *result = NULL;
     struct berval *servercredp = NULL;
-#if defined(USE_OPENLDAP)
-    /* openldap doesn't have a SSL/TLS yes/no flag - so grab the
-       ldapurl, parse it, and see if it is a secure one */
-    char *ldapurl = NULL;
-
-    ldap_get_option(ld, LDAP_OPT_URI, &ldapurl);
-    if (ldapurl && !PL_strncasecmp(ldapurl, "ldaps", 5)) {
-        secure = 1;
-    }
-    PL_strfree(ldapurl);
-    ldapurl = NULL;
-#else /* !USE_OPENLDAP */
-    ldap_get_option(ld, LDAP_OPT_SSL, &secure);
-#endif
 
-#ifdef EXTERNAL_AUTH_SUPPORTED
-    if (secure && mech && !strcmp(mech, LDAP_SASL_EXTERNAL)) {
-        /* SSL connections will use the server's security context
-           and cert for client auth */
-        rc = slapd_SSL_client_auth(ld);
-
-        if (rc != 0) {
-#ifdef DEBUG
-            fprintf(stderr, "util_ldap_bind: "
-                    "Error: could not configure the server for cert "
-                    "auth - error %d - make sure the server is "
-                    "correctly configured for SSL/TLS\n", rc);
-#endif
-            goto done;
-        } else {
-#ifdef DEBUG
-            fprintf(stderr, "util_ldap_bind: "
-                    "Set up conn to use client auth\n");
-#endif
-        }
-        bvcreds.bv_val = NULL; /* ignore username and passed in creds */
-        bvcreds.bv_len = 0; /* for external auth */
-        bindid = NULL;
-    } else { /* other type of auth */
-#endif /* EXTERNAL_AUTH_SUPPORTED */
-        bvcreds.bv_val = (char *)creds;
-        bvcreds.bv_len = creds ? strlen(creds) : 0;
-#ifdef EXTERNAL_AUTH_SUPPORTED
-    }
-#endif /* EXTERNAL_AUTH_SUPPORTED */
+    bvcreds.bv_val = (char *)creds;
+    bvcreds.bv_len = creds ? strlen(creds) : 0;
 
     /* The connection has been set up - now do the actual bind, depending on
        the mechanism and arguments */
diff --git a/lib/libdsa/dsalib_util.c b/lib/libdsa/dsalib_util.c
index da875df..803f86d 100644
--- a/lib/libdsa/dsalib_util.c
+++ b/lib/libdsa/dsalib_util.c
@@ -402,18 +402,10 @@ ds_system_errmsg(void)
     static char static_error[BUFSIZ];
     char *lmsg = 0; /* Local message pointer */
     size_t msglen = 0;
-    int sys_error = 0;
 #ifdef XP_WIN32
     LPTSTR sysmsg = 0;
 #endif
 
-    /* Grab the OS error message */
-#ifdef XP_WIN32
-    sys_error = GetLastError();
-#else
-    sys_error = errno;
-#endif
-
 #if defined(XP_WIN32)
     msglen = FormatMessage(
 	FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER,
diff --git a/mod_admserv/mod_admserv.c b/mod_admserv/mod_admserv.c
index 9eca803..744364c 100644
--- a/mod_admserv/mod_admserv.c
+++ b/mod_admserv/mod_admserv.c
@@ -2641,7 +2641,7 @@ static int
 authenticate_user(LdapServerData *data, char *baseDN, char *user, const char *pw, request_rec *r)
 {
   LDAP           *server;
-  char           *uid, *userdn, *ldapURL;
+  char           *userdn, *ldapURL;
   int             ldapError = LDAP_SUCCESS;
   int             pw_expiring = 0;
   int tries = 0;
@@ -2686,13 +2686,10 @@ authenticate_user(LdapServerData *data, char *baseDN, char *user, const char *pw
 
           return DECLINED; /* fall back to final check against admpw */
       }
-
-      uid = user;
   } else {
       /* it's a DN */
 
       userdn = user;
-      uid    = NULL;
 
       /* strip the leading "ldap:", if present */
 
-- 
1.7.1

