Skip to content

Commit c4f559c

Browse files
committed
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] Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent ece4738 commit c4f559c

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ matrix:
3737
- python: 3.6
3838
env: TOXENV=doc
3939

40+
env:
41+
global:
42+
# -Werror=declaration-after-statement: strict ISO C90
43+
- CFLAGS="-std=c90 -Werror=declaration-after-statement"
44+
# pass CFLAGS and WITH_GCOV to tox tasks
45+
- TOX_TESTENV_PASSENV="CFLAGS WITH_GCOV"
46+
4047
install:
4148
- pip install "pip>=7.1.0"
4249
- pip install tox-travis tox codecov coverage

Modules/LDAPObject.c

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

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

1037-
int result = LDAP_SUCCESS;
1038-
char **refs = NULL;
1039-
LDAPControl **serverctrls = 0;
10401040
if (res_type == LDAP_RES_SEARCH_ENTRY) {
10411041
/* LDAPmessage_to_python will parse entries and read the controls for each entry */
10421042
} 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/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