Skip to content

Commit 849995d

Browse files
committed
Fix [-Wstrict-prototypes] warnings in LDAP extension
errno is a global variable/macro which is implementation defined and should not be reused
1 parent 12c4100 commit 849995d

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

ext/ldap/ldap.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
14321432
LDAPControl **lserverctrls = NULL;
14331433
int ldap_attrsonly = 0, ldap_sizelimit = -1, ldap_timelimit = -1, ldap_deref = -1;
14341434
int old_ldap_sizelimit = -1, old_ldap_timelimit = -1, old_ldap_deref = -1;
1435-
int num_attribs = 0, ret = 1, i, errno, argcount = ZEND_NUM_ARGS();
1435+
int num_attribs = 0, ret = 1, i, php_ldap_errno, argcount = ZEND_NUM_ARGS();
14361436

14371437
if (zend_parse_parameters(argcount, "zzz|a/lllla/", &link, &base_dn, &filter, &attrs, &attrsonly,
14381438
&sizelimit, &timelimit, &deref, &serverctrls) == FAILURE) {
@@ -1617,30 +1617,30 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope)
16171617
php_set_opts(ld->link, ldap_sizelimit, ldap_timelimit, ldap_deref, &old_ldap_sizelimit, &old_ldap_timelimit, &old_ldap_deref);
16181618

16191619
/* Run the actual search */
1620-
errno = ldap_search_ext_s(ld->link, ZSTR_VAL(ldap_base_dn), scope, ZSTR_VAL(ldap_filter), ldap_attrs, ldap_attrsonly, lserverctrls, NULL, NULL, ldap_sizelimit, &ldap_res);
1620+
php_ldap_errno = ldap_search_ext_s(ld->link, ZSTR_VAL(ldap_base_dn), scope, ZSTR_VAL(ldap_filter), ldap_attrs, ldap_attrsonly, lserverctrls, NULL, NULL, ldap_sizelimit, &ldap_res);
16211621

1622-
if (errno != LDAP_SUCCESS
1623-
&& errno != LDAP_SIZELIMIT_EXCEEDED
1622+
if (php_ldap_errno != LDAP_SUCCESS
1623+
&& php_ldap_errno != LDAP_SIZELIMIT_EXCEEDED
16241624
#ifdef LDAP_ADMINLIMIT_EXCEEDED
1625-
&& errno != LDAP_ADMINLIMIT_EXCEEDED
1625+
&& php_ldap_errno != LDAP_ADMINLIMIT_EXCEEDED
16261626
#endif
16271627
#ifdef LDAP_REFERRAL
1628-
&& errno != LDAP_REFERRAL
1628+
&& php_ldap_errno != LDAP_REFERRAL
16291629
#endif
16301630
) {
16311631
/* ldap_res should be freed regardless of return value of ldap_search_ext_s()
16321632
* see: https://linux.die.net/man/3/ldap_search_ext_s */
16331633
if (ldap_res != NULL) {
16341634
ldap_msgfree(ldap_res);
16351635
}
1636-
php_error_docref(NULL, E_WARNING, "Search: %s", ldap_err2string(errno));
1636+
php_error_docref(NULL, E_WARNING, "Search: %s", ldap_err2string(php_ldap_errno));
16371637
ret = 0;
16381638
} else {
1639-
if (errno == LDAP_SIZELIMIT_EXCEEDED) {
1639+
if (php_ldap_errno == LDAP_SIZELIMIT_EXCEEDED) {
16401640
php_error_docref(NULL, E_WARNING, "Partial search results returned: Sizelimit exceeded");
16411641
}
16421642
#ifdef LDAP_ADMINLIMIT_EXCEEDED
1643-
else if (errno == LDAP_ADMINLIMIT_EXCEEDED) {
1643+
else if (php_ldap_errno == LDAP_ADMINLIMIT_EXCEEDED) {
16441644
php_error_docref(NULL, E_WARNING, "Partial search results returned: Adminlimit exceeded");
16451645
}
16461646
#endif
@@ -2892,7 +2892,7 @@ PHP_FUNCTION(ldap_compare)
28922892
size_t dn_len, attr_len, value_len;
28932893
ldap_linkdata *ld;
28942894
LDAPControl **lserverctrls = NULL;
2895-
int errno;
2895+
int php_ldap_errno;
28962896
struct berval lvalue;
28972897

28982898
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rsss|a", &link, &dn, &dn_len, &attr, &attr_len, &value, &value_len, &serverctrls) != SUCCESS) {
@@ -2914,9 +2914,9 @@ PHP_FUNCTION(ldap_compare)
29142914
lvalue.bv_val = value;
29152915
lvalue.bv_len = value_len;
29162916

2917-
errno = ldap_compare_ext_s(ld->link, dn, attr, &lvalue, lserverctrls, NULL);
2917+
php_ldap_errno = ldap_compare_ext_s(ld->link, dn, attr, &lvalue, lserverctrls, NULL);
29182918

2919-
switch (errno) {
2919+
switch (php_ldap_errno) {
29202920
case LDAP_COMPARE_TRUE:
29212921
RETVAL_TRUE;
29222922
break;
@@ -2926,7 +2926,7 @@ PHP_FUNCTION(ldap_compare)
29262926
break;
29272927

29282928
default:
2929-
php_error_docref(NULL, E_WARNING, "Compare: %s", ldap_err2string(errno));
2929+
php_error_docref(NULL, E_WARNING, "Compare: %s", ldap_err2string(php_ldap_errno));
29302930
RETVAL_LONG(-1);
29312931
}
29322932

0 commit comments

Comments
 (0)