歡迎您光臨本站 註冊首頁

警告:賦值時將整數賦給指針,未作類型轉換

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

警告:賦值時將整數賦給指針,未作類型轉換

小聲的問一句,我編譯在http://developer.novell.com/documentation/samplecode/cldap_sample/index.htm上的例子程序,編譯的時候使用 gcc -lldap veriPassword.c 出現一個警告
veriPassword.c:45: 警告:賦值時將整數賦給指針,未作類型轉換
就是if ((ld = ldap_init (ldapHost, ldapPort)) == NULL)
我man了一下ldap_init 返回值是LDAP*啊

請哪位幫我看看 問題處在哪了?多謝
#include <stdio.h>
#include <stdlib.h>
#include <ldap.h>



static char usage[] =
  "\n Usage:   verpass <host name> <port number> <login dn> <password>"
  "\n          <object dn> <test password>\n"
  "\n Example: verpass Acme.com 389 cn=admin,o=Acme secret"
  "\n          cn=james,ou=Sales,o=Acme testpass\n";


int
main (int argc, char *argv[])
{

  LDAP *ld;
  int version, ldapPort, rc;
  char *ldapHost, *loginDN, *password, *objectDN, *testPassword;
  struct timeval timeOut = { 10, 0 };    /* 10 second connection timeout */

if (argc != 7)
    {
      printf ("%s", usage);
      return (1);
    }

  ldapHost = argv[1];
  ldapPort = atoi (argv[2]);
  loginDN = argv[3];
  password = argv[4];
  objectDN = argv[5];
  testPassword = argv[6];

  /* Set LDAP version to 3 and set connection timeout. */
  ldap_set_option (NULL, LDAP_OPT_PROTOCOL_VERSION, &version);
  ldap_set_option (NULL, LDAP_OPT_NETWORK_TIMEOUT, &timeOut);

  /* Initialize the LDAP session */
  if ((ld = ldap_init (ldapHost, ldapPort)) == NULL)
    {
      printf ("\n\tLDAP session initialization failed\n");
      return (1);
    }
  printf ("\n\tLDAP session initialized\n");

  /* Bind to the server */
  rc = ldap_simple_bind_s (ld, loginDN, password);
  if (rc != LDAP_SUCCESS)
    {
      printf ("ldap_simple_bind_s: %s\n", ldap_err2string (rc));
      ldap_unbind_s (ld);
      return (1);
    }
  printf ("\n\tBind successful\n");


  /*
   * Compare the test password with the userPassword attribute
   * of the object.
   */
  rc = ldap_compare_s (ld,    /* LDAP session handle */
               objectDN,    /* the object to verify password on */
               "userPassword",    /* attribute to compare */
               testPassword);    /* the password to verify */

  if (rc == LDAP_COMPARE_TRUE)
    printf ("\n\tThe password is correct.\n");
  else if (rc == LDAP_COMPARE_FALSE)
    printf ("\n\tThe password is not correct.\n");
  else
    {
      printf ("\n\tldap_compare_s: %s\n", ldap_err2string (rc));
      ldap_unbind_s (ld);
      return (1);
    }

  ldap_unbind_s (ld);

  return (0);

  return 0;

}

[火星人 ] 警告:賦值時將整數賦給指針,未作類型轉換已經有364次圍觀

http://coctec.com/docs/service/show-post-20187.html