[tpop3d-discuss] [patch] auth_ldap.c

Paul Makepeace Paul.Makepeace at realprogrammers.com
Fri, 18 Jul 2003 01:08:44 +0100


Not sure if this is already on the radar, but.. gcc 3.3.1 prerelease
moans,

auth_ldap.c: In function `try_ldap_connect_bind':
auth_ldap.c:242: warning: `ret' might be used uninitialized in this
function
auth_ldap.c: In function `auth_ldap_new_user_pass':
auth_ldap.c:329: warning: passing arg 3 of `try_ldap_bind' discards
qualifiers from pointer target type
auth_ldap.c:375:25: pasting "." and "mailbox" does not give a valid
preprocessing token
[repeated several times]

@@ -240,4 +240,4 @@
  * Try to connect to the LDAP server and bind. */
-static int try_ldap_connect_bind(char *who, char *passwd) {
-    int ret, i;
+static int try_ldap_connect_bind(const char *who, const char *passwd) {
+    int ret = !LDAP_SUCCESS, i; /* XXX */
     for (i = 0; i < 3; ++i) {
@@ -262,3 +262,3 @@
  * Try a bind against the LDAP server. */
-static int try_ldap_bind(LDAP *ld, char *who, char *passwd) {
+static int try_ldap_bind(LDAP *ld, const char *who, const char *passwd) {
     int ret, i;
@@ -369,5 +369,5 @@
         /* Check that we've retrieved all the attributes we need. */
-#define GOT_ATTR(a)     if (ldapinfo.attr.##a && !a) { \
+#define GOT_ATTR(a)     if (ldapinfo.attr.a && !a) { \
                             log_print(LOG_ERR, _("auth_ldap_new_user_pass: did not find required attribute `%s' for %s"), \
-                                      ldapinfo.attr.##a, who); \
+                                      ldapinfo.attr.a, who); \
   
Nice to get rid of that uninitialized ret warning; I'm not sure about
how errno (set during ldap_open) relates to the error codes in ldap.h
or what an appropriate default would be (LDAP_OTHER?
LDAP_SERVER_DOWN?). I think it's definitely a bug leaving it as is
though - if it gets a default of zero it'll be considered a success.
(#define LDAP_SUCCESS 0x00)

(ldap_open() is deprecated, btw.)

Paul

-- 
Paul Makepeace ....................................... http://paulm.com/

"If volume matters as much as they claim, then everyone knows cows don't
 talk."
   -- http://paulm.com/toys/surrealism/