Skip to content

Commit e1519d6

Browse files
author
Ard Biesheuvel
committed
GCC fixes
1 parent c84c564 commit e1519d6

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

ext/pdo_firebird/config.m4

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,19 @@ if test "$PHP_PDO_FIREBIRD" != "no"; then
3131
-L$FIREBIRD_LIBDIR
3232
])
3333

34+
if test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then
35+
pdo_inc_path=$prefix/include/php/ext
36+
elif test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then
37+
pdo_inc_path=$abs_srcdir/ext
38+
elif test -f ext/pdo/php_pdo_driver.h; then
39+
pdo_inc_path=ext
40+
else
41+
AC_MSG_ERROR([Cannot find php_pdo_driver.h.])
42+
fi
43+
3444
PHP_ADD_LIBRARY_WITH_PATH($FIREBIRD_LIBNAME, $FIREBIRD_LIBDIR, PDO_FIREBIRD_SHARED_LIBADD)
3545
PHP_ADD_INCLUDE($FIREBIRD_INCDIR)
3646
AC_DEFINE(HAVE_PDO_FIREBIRD,1,[ ])
37-
PHP_NEW_EXTENSION(pdo_firebird, pdo_firebird.c firebird_driver.c firebird_statement.c, $ext_shared)
47+
PHP_NEW_EXTENSION(pdo_firebird, pdo_firebird.c firebird_driver.c firebird_statement.c, $ext_shared,,-I$pdo_inc_path)
3848
PHP_SUBST(PDO_FIREBIRD_SHARED_LIBADD)
3949
fi

ext/pdo_firebird/firebird_driver.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "config.h"
2323
#endif
2424

25+
#define _GNU_SOURCE
26+
2527
#include "php.h"
2628
#include "php_ini.h"
2729
#include "ext/standard/info.h"
@@ -30,14 +32,12 @@
3032
#include "php_pdo_firebird.h"
3133
#include "php_pdo_firebird_int.h"
3234

33-
#define _GNU_SOURCE
34-
3535
/* map driver specific error message to PDO error */
3636
void _firebird_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, char const *file, long line TSRMLS_DC) /* {{{ */
3737
{
3838
pdo_firebird_db_handle *H = stmt ? ((pdo_firebird_stmt *)stmt->driver_data)->H
3939
: (pdo_firebird_db_handle *)dbh->driver_data;
40-
long *error_code = stmt ? &stmt->error_code : &dbh->error_code;
40+
enum pdo_error_type *error_code = stmt ? &stmt->error_code : &dbh->error_code;
4141

4242
switch (isc_sqlcode(H->isc_status)) {
4343

@@ -273,14 +273,13 @@ static long firebird_handle_doer(pdo_dbh_t *dbh, const char *sql, long sql_len T
273273
static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquotedlen, /* {{{ */
274274
char **quoted, int *quotedlen TSRMLS_DC)
275275
{
276-
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
277276
int qcount = 0;
278277
char const *c;
279278

280279
/* Firebird only requires single quotes to be doubled if string lengths are used */
281280

282281
/* count the number of ' characters */
283-
for (c = unquoted; c = strchr(c,'\''); qcount++, c++);
282+
for (c = unquoted; (c = strchr(c,'\'')); qcount++, c++);
284283

285284
if (!qcount) {
286285
return 0;
@@ -292,7 +291,7 @@ static int firebird_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unqu
292291
*quoted = c = emalloc(*quotedlen+1);
293292

294293
/* foreach (chunk that ends in a quote) */
295-
for (l = unquoted; r = strchr(l,'\''); l = r+1) {
294+
for (l = unquoted; (r = strchr(l,'\'')); l = r+1) {
296295

297296
/* copy the chunk */
298297
strncpy(c, l, r-l);
@@ -362,7 +361,7 @@ static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
362361
/* if (the value is really being changed and a transaction is open) */
363362
if ((Z_LVAL_P(val)?1:0) ^ dbh->auto_commit && dbh->in_txn) {
364363

365-
if (dbh->auto_commit = Z_BVAL_P(val)) {
364+
if ((dbh->auto_commit = Z_BVAL_P(val))) {
366365
/* just keep the running transaction but commit it */
367366
if (isc_commit_retaining(H->isc_status, &H->tr)) {
368367
RECORD_ERROR(dbh);
@@ -401,8 +400,7 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
401400
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
402401

403402
switch (attr) {
404-
char tmp[200] = "Firebird 1.0/Interbase 6";
405-
info_func_t info_func;
403+
char tmp[200];
406404

407405
case PDO_ATTR_AUTOCOMMIT:
408406
ZVAL_LONG(val,dbh->auto_commit);
@@ -414,20 +412,23 @@ static int firebird_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
414412

415413
case PDO_ATTR_CLIENT_VERSION: {
416414
#if defined(__GNUC__) || defined(PHP_WIN32)
415+
info_func_t info_func = NULL;
417416
#ifdef __GNUC__
418-
info_func_t info_func = (info_func_t)dlsym(RTLD_DEFAULT, "isc_get_client_version");
417+
info_func = (info_func_t)dlsym(RTLD_DEFAULT, "isc_get_client_version");
419418
#else
420419
HMODULE l = GetModuleHandle("fbclient");
421420

422421
if (!l && !(l = GetModuleHandle("gds32"))) {
423-
return 0;
422+
break;
424423
}
425424
info_func = (info_func_t)GetProcAddress(l, "isc_get_client_version");
426425
#endif
427426
if (info_func) {
428427
info_func(tmp);
428+
ZVAL_STRING(val,tmp,1);
429+
} else {
430+
ZVAL_STRING(val,"Firebird 1.0/Interbase 6",1);
429431
}
430-
ZVAL_STRING(val,tmp,1);
431432
#else
432433
ZVAL_NULL(val);
433434
#endif
@@ -458,7 +459,7 @@ static int pdo_firebird_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval
458459
if (sqlcode) {
459460
add_next_index_long(info, sqlcode);
460461

461-
while (l = isc_interprete(&buf[i],&s)) {
462+
while ((l = isc_interprete(&buf[i],&s))) {
462463
i += l;
463464
strcpy(&buf[i++], " ");
464465
}
@@ -504,7 +505,6 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM
504505
isc_dpb_user_name, isc_dpb_password, isc_dpb_lc_ctype, isc_dpb_sql_role_name };
505506
char const *dpb_values[] = { dbh->username, dbh->password, vars[1].optval, vars[2].optval };
506507
char dpb_buffer[256] = { isc_dpb_version1 }, *dpb;
507-
short len;
508508

509509
dpb = dpb_buffer + 1;
510510

ext/pdo_firebird/firebird_statement.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
109109
return 1;
110110
} while (0);
111111

112-
RECORD_ERROR(stmt->dbh);
112+
RECORD_ERROR(stmt);
113113

114114
return 0;
115115
}
@@ -163,6 +163,7 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{
163163

164164
return 1;
165165
}
166+
/* }}} */
166167

167168
/* internal function to override return types of parameters */
168169
static void set_param_type(enum pdo_param_type *param_type, XSQLVAR const *var) /* {{{ */
@@ -419,6 +420,8 @@ static int firebird_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_dat
419420
return 1;
420421
}
421422
return 0;
423+
default:
424+
;
422425
}
423426
return 1;
424427
}

ext/pdo_firebird/php_pdo_firebird_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#define PDO_FB_DIALECT 3
3333

34-
#define SHORT_MAX (1 << 8*sizeof(short)-1)
34+
#define SHORT_MAX (1 << (8*sizeof(short)-1))
3535

3636
#if SIZEOF_LONG == 8
3737
# define LL_MASK l

0 commit comments

Comments
 (0)