On 26/02/09 16:31, Charles Jardine wrote:
I have built a 64 bit version of Perl 5.10.0 under SLES 10 (x86-64).
I am now installing DBI and DBD::Oracle.
Both of these modules produce alarming warnings at compile time.
E.g.
DBI.xs: In function ‘dbih_setup_fbav’:
DBI.xs:1549: warning: format ‘%ld’ expects type ‘long int’, but argument 3 has
type ‘int’
[snip]
I wondered why I had never seen this before. It turns out that
Perl 5.10.0 has an improvement in this area. For gcc, the
declaration of PerlIO_printf has been enhanced by the addition
of '__attribute__((format(__printf__,2,3)))'. This, for the
first time, allows gcc to check the types of PerlIO_printf's arguments.
I have now looked at the DBI situation more carefully. The new warnings
have revealed that there are a very small number cases where %ld or
%lx format elements have been used without the requisite casting
of arguments. The omissions have probably done no damage on 32-bit
platforms, but may have led to incorrect trace output on some 64-bit
architectures.
I attach a patch against DBI-1.607 to fix these micro-bugs.
While I was there, on line 888 of DBI.xs, I have interchanged the
order of two arguments. I believe this fixes a bug in the tracing
of set_trace itself.
--
Charles Jardine - Computing Service, University of Cambridge
[email protected] Tel: +44 1223 334506, Fax: +44 1223 334679
diff -r -u DBI-1.607/DBI.xs DBI-1.607.patched/DBI.xs
--- DBI-1.607/DBI.xs 2008-07-22 21:47:32.000000000 +0100
+++ DBI-1.607.patched/DBI.xs 2009-02-27 16:45:19.150114514 +0000
@@ -884,7 +884,7 @@
neatsvpv(h,0),
(long)(level & DBIc_TRACE_FLAGS_MASK),
(long)(level & DBIc_TRACE_LEVEL_MASK),
- DBIc_TRACE_LEVEL(imp_xxh), DBIc_TRACE_FLAGS(imp_xxh),
+ (long)DBIc_TRACE_FLAGS(imp_xxh),
(long)DBIc_TRACE_LEVEL(imp_xxh),
XS_VERSION, dbi_build_opt, (int)PerlProc_getpid());
if (!PL_dowarn)
PerlIO_printf(DBIc_LOGPIO(imp_xxh)," Note: perl is running
without the recommended perl -w option\n");
@@ -1546,14 +1546,14 @@
return av;
/* we need to adjust the size of the array */
if (DBIc_TRACE_LEVEL(imp_sth) >= 2)
- PerlIO_printf(DBILOGFP," dbih_setup_fbav realloc from %ld to
%ld fields\n", av_len(av)+1, i);
+ PerlIO_printf(DBILOGFP," dbih_setup_fbav realloc from %ld to
%ld fields\n", (long)(av_len(av)+1), (long)i);
SvREADONLY_off(av);
if (i < av_len(av)+1) /* trim to size if too big */
av_fill(av, i-1);
}
else {
if (DBIc_TRACE_LEVEL(imp_sth) >= 5)
- PerlIO_printf(DBILOGFP," dbih_setup_fbav alloc for %ld
fields\n", i);
+ PerlIO_printf(DBILOGFP," dbih_setup_fbav alloc for %ld
fields\n", (long)i);
av = newAV();
DBIc_FIELDS_AV(imp_sth) = av;
@@ -1567,7 +1567,7 @@
while(i--) /* field 1 stored at index 0 */
av_store(av, i, newSV(0));
if (DBIc_TRACE_LEVEL(imp_sth) >= 6)
- PerlIO_printf(DBILOGFP," dbih_setup_fbav now %ld fields\n",
av_len(av)+1);
+ PerlIO_printf(DBILOGFP," dbih_setup_fbav now %ld fields\n",
(long)(av_len(av)+1));
SvREADONLY_on(av); /* protect against shift @$row etc */
return av;
}
diff -r -u DBI-1.607/DBIXS.h DBI-1.607.patched/DBIXS.h
--- DBI-1.607/DBIXS.h 2008-05-28 14:01:29.000000000 +0100
+++ DBI-1.607.patched/DBIXS.h 2009-02-27 16:30:18.343030577 +0000
@@ -304,7 +304,8 @@
if (!DBIc_ACTIVE(imp) && ph_com && !dirty \
&& ++DBIc_ACTIVE_KIDS(ph_com) > DBIc_KIDS(ph_com)) \
croak("panic: DBI active kids (%ld) > kids (%ld)", \
- DBIc_ACTIVE_KIDS(ph_com), DBIc_KIDS(ph_com)); \
+ (long)DBIc_ACTIVE_KIDS(ph_com), \
+ (long)DBIc_KIDS(ph_com)); \
DBIc_FLAGS(imp) |= DBIcf_ACTIVE; \
} while(0)
#define DBIc_ACTIVE_off(imp) /* adjust parent's active kid count */ \
@@ -314,7 +315,8 @@
&& (--DBIc_ACTIVE_KIDS(ph_com) > DBIc_KIDS(ph_com) \
|| DBIc_ACTIVE_KIDS(ph_com) < 0) ) \
croak("panic: DBI active kids (%ld) < 0 or > kids (%ld)", \
- DBIc_ACTIVE_KIDS(ph_com), DBIc_KIDS(ph_com)); \
+ (long)DBIc_ACTIVE_KIDS(ph_com), \
+ (long)DBIc_KIDS(ph_com)); \
DBIc_FLAGS(imp) &= ~DBIcf_ACTIVE; \
} while(0)