Skip to content

Commit de6da53

Browse files
tiranencukou
authored andcommitted
Fix declaration after statement for C90
In strict ISO C90 mode and on some platforms (e.g. older MSVC), it is not allowed to declare new variables after a statement. I also find it good practice to declare first. Fixes error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] python-ldap#53 Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent a62695e commit de6da53

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ env:
4141
global:
4242
# -Wno-int-in-bool-context: don't complain about PyMem_MALLOC()
4343
# -Werror: turn all warnings into fatal errors
44-
- CFLAGS="-Wno-int-in-bool-context -Werror"
44+
# -Werror=declaration-after-statement: strict ISO C90
45+
- CFLAGS="-std=c90 -Wno-int-in-bool-context -Werror -Werror=declaration-after-statement"
4546
# pass CFLAGS and WITH_GCOV to tox tasks
4647
- TOX_TESTENV_PASSENV="CFLAGS WITH_GCOV"
4748

Modules/LDAPObject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,9 @@ l_ldap_result4( LDAPObject* self, PyObject *args )
998998
int res_msgid = 0;
999999
char *retoid = 0;
10001000
PyObject *valuestr = NULL;
1001+
int result = LDAP_SUCCESS;
1002+
char **refs = NULL;
1003+
LDAPControl **serverctrls = 0;
10011004

10021005
if (!PyArg_ParseTuple( args, "|iidiii", &msgid, &all, &timeout, &add_ctrls, &add_intermediates, &add_extop ))
10031006
return NULL;
@@ -1033,9 +1036,6 @@ l_ldap_result4( LDAPObject* self, PyObject *args )
10331036
if (msg)
10341037
res_msgid = ldap_msgid(msg);
10351038

1036-
int result = LDAP_SUCCESS;
1037-
char **refs = NULL;
1038-
LDAPControl **serverctrls = 0;
10391039
if (res_type == LDAP_RES_SEARCH_ENTRY) {
10401040
/* LDAPmessage_to_python will parse entries and read the controls for each entry */
10411041
} else if (res_type == LDAP_RES_SEARCH_REFERENCE) {

Modules/constants.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ LDAPerror( LDAP *l, char *msg )
6060
PyObject *info;
6161
PyObject *str;
6262
PyObject *pyerrno;
63+
char *matched, *error;
6364

6465
/* at first save errno for later use before it gets overwritten by another call */
6566
myerrno = errno;
6667

67-
char *matched, *error;
68-
6968
opt_errnum = ldap_get_option(l, LDAP_OPT_ERROR_NUMBER, &errnum);
7069
if (opt_errnum != LDAP_OPT_SUCCESS)
7170
errnum = opt_errnum;

Modules/ldapmodule.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ PyObject* init_ldap_module(void)
4141
{
4242
PyObject *m, *d;
4343

44-
/* Initialize LDAP class */
45-
if (PyType_Ready(&LDAP_Type) < 0)
46-
return NULL;
47-
4844
/* Create the module and add the functions */
4945
#if PY_MAJOR_VERSION >= 3
5046
static struct PyModuleDef ldap_moduledef = {
@@ -58,6 +54,11 @@ PyObject* init_ldap_module(void)
5854
#else
5955
m = Py_InitModule("_ldap", methods);
6056
#endif
57+
/* Initialize LDAP class */
58+
if (PyType_Ready(&LDAP_Type) < 0) {
59+
Py_DECREF(m);
60+
return NULL;
61+
}
6162

6263
/* Add some symbolic constants to the module */
6364
d = PyModule_GetDict(m);

Modules/message.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ LDAPmessage_to_python(LDAP *ld, LDAPMessage *m, int add_ctrls, int add_intermedi
9292
) {
9393
PyObject* valuelist;
9494
PyObject* pyattr;
95+
struct berval **bvals;
96+
9597
pyattr = PyUnicode_FromString(attr);
9698

97-
struct berval ** bvals =
98-
ldap_get_values_len( ld, entry, attr );
99+
bvals = ldap_get_values_len( ld, entry, attr );
99100

100101
/* Find which list to append to */
101102
if ( PyDict_Contains( attrdict, pyattr ) ) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy