Обсуждение: Re: [HACKERS] New compile warnings
Tom Lane wrote:
>Bruce Momjian <pgman@candle.pha.pa.us> writes:
>
>
>>I am seeing the following compile warnings in CVS. I am using for perl:
>> Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
>>
>>
>
>I believe these two:
>
>
>
>>plperl.c:948: warning: `ret_hv' might be used uninitialized in this function
>>plperl.c:949: warning: `ret_av' might be used uninitialized in this function
>>
>>
>
>indicate an actual bug --- at least, it's far from clear that the code
>can't try to use an uninitialized value. I trust that the authors of
>plperl will step up and fix it; I'm not sufficiently clear on what cases
>they are trying to support to want to touch it.
>
>
I don't currently have the resources to clean this up properly. The
attached patch tries to make clear in a comment what the code is doing,
and also initializes these variables to NULL. If someone wants to take a
stab at cleaning this up they are welcome to - I don't expect to be able
to for quite a while.
>The others indicate sloppiness in the C code generated by perl's XS
>functionality. There's nothing we can do about them. FWIW, less
>obsolete versions of Perl generate fewer warnings --- the only one of
>these that I see on 5.8.0 and up is
>
>
>
>>SPI.c:158: warning: unused variable `items'
>>
>>
>
>
>
>
The patch also addresses this issue.
cheers
andrew
Index: SPI.xs
===================================================================
RCS file: /home/cvsmirror/pgsql/src/pl/plperl/SPI.xs,v
retrieving revision 1.10
diff -c -r1.10 SPI.xs
*** SPI.xs 20 Nov 2004 19:07:40 -0000 1.10
--- SPI.xs 21 Nov 2004 15:02:15 -0000
***************
*** 94,96 ****
--- 94,100 ----
RETVAL = newRV_noinc((SV*) ret_hash);
OUTPUT:
RETVAL
+
+
+ BOOT:
+ items = 0; /* avoid 'unused variable' warning */
Index: plperl.c
===================================================================
RCS file: /home/cvsmirror/pgsql/src/pl/plperl/plperl.c,v
retrieving revision 1.59
diff -c -r1.59 plperl.c
*** plperl.c 20 Nov 2004 19:07:40 -0000 1.59
--- plperl.c 21 Nov 2004 20:40:50 -0000
***************
*** 963,971 ****
if (prodesc->fn_retistuple && fcinfo->resultinfo) /* set of tuples */
{
/* SRF support */
! HV *ret_hv;
! AV *ret_av;
FuncCallContext *funcctx;
int call_cntr;
int max_calls;
--- 963,988 ----
if (prodesc->fn_retistuple && fcinfo->resultinfo) /* set of tuples */
{
+
+ /*
+ * This branch will be taken when the function call
+ * appears on a context that can return a set of tuples
+ * even if it only actually returns a single tuple
+ * (e.g. select a from foo() where foor returns a singletone
+ * of some composite type with member a). In this case, the
+ * return value will be a hashref. If a rowset is returned
+ * it will be an arrayref whose members will be hashrefs.
+ *
+ * Care is taken in the code only to refer to the appropriate
+ * one of ret_hv and ret_av, only one of which is therefore
+ * valid for any given call.
+ *
+ * XXX This code is in dire need of cleanup.
+ */
+
/* SRF support */
! HV *ret_hv = NULL;
! AV *ret_av = NULL;
FuncCallContext *funcctx;
int call_cntr;
int max_calls;
Andrew Dunstan <andrew@dunslane.net> writes:
> I don't currently have the resources to clean this up properly. The
> attached patch tries to make clear in a comment what the code is doing,
> and also initializes these variables to NULL. If someone wants to take a
> stab at cleaning this up they are welcome to - I don't expect to be able
> to for quite a while.
OK, applied. It compiles warning-free now for me (using Perl 5.8.0)
regards, tom lane
Tom Lane wrote: > Andrew Dunstan <andrew@dunslane.net> writes: > > I don't currently have the resources to clean this up properly. The > > attached patch tries to make clear in a comment what the code is doing, > > and also initializes these variables to NULL. If someone wants to take a > > stab at cleaning this up they are welcome to - I don't expect to be able > > to for quite a while. > > OK, applied. It compiles warning-free now for me (using Perl 5.8.0) FYI, I still see compile warnings. I assume they are just related to me using Perl 5.0.5 and will ignore them: gmake[2]: Leaving directory `/usr/var/local/src/gen/pgsql/CURRENT/pgsql/src/test/regress' gmake[1]: Leaving directory `/usr/var/local/src/gen/pgsql/CURRENT/pgsql/src/test' /usr/libdata/perl5/5.00503/i386-bsdos/CORE/patchlevel.h:41: warning: `local_patches' defined but not used ppport.h:564: warning: `sv_2pv_nolen' defined but not used /usr/libdata/perl5/5.00503/i386-bsdos/CORE/patchlevel.h:41: warning: `local_patches' defined but not used ppport.h:564: warning: `sv_2pv_nolen' defined but not used SPI.c:59: warning: no previous prototype for `XS__elog' SPI.c:78: warning: no previous prototype for `XS__DEBUG' SPI.c:93: warning: no previous prototype for `XS__LOG' SPI.c:108: warning: no previous prototype for `XS__INFO' SPI.c:123: warning: no previous prototype for `XS__NOTICE' SPI.c:138: warning: no previous prototype for `XS__WARNING' SPI.c:153: warning: no previous prototype for `XS__ERROR' SPI.c:168: warning: no previous prototype for `XS__spi_exec_query' SPI.c:197: warning: no previous prototype for `boot_SPI' /usr/libdata/perl5/5.00503/i386-bsdos/CORE/patchlevel.h:41: warning: `local_patches' defined but not used ppport.h:564: warning: `sv_2pv_nolen' defined but not used -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> FYI, I still see compile warnings. I assume they are just related to me
> using Perl 5.0.5 and will ignore them:
> gmake[2]: Leaving directory `/usr/var/local/src/gen/pgsql/CURRENT/pgsql/src/test/regress'
> gmake[1]: Leaving directory `/usr/var/local/src/gen/pgsql/CURRENT/pgsql/src/test'
> /usr/libdata/perl5/5.00503/i386-bsdos/CORE/patchlevel.h:41: warning: `local_patches' defined but not used
> ppport.h:564: warning: `sv_2pv_nolen' defined but not used
> /usr/libdata/perl5/5.00503/i386-bsdos/CORE/patchlevel.h:41: warning: `local_patches' defined but not used
> ppport.h:564: warning: `sv_2pv_nolen' defined but not used
> SPI.c:59: warning: no previous prototype for `XS__elog'
> SPI.c:78: warning: no previous prototype for `XS__DEBUG'
> SPI.c:93: warning: no previous prototype for `XS__LOG'
> SPI.c:108: warning: no previous prototype for `XS__INFO'
> SPI.c:123: warning: no previous prototype for `XS__NOTICE'
> SPI.c:138: warning: no previous prototype for `XS__WARNING'
> SPI.c:153: warning: no previous prototype for `XS__ERROR'
> SPI.c:168: warning: no previous prototype for `XS__spi_exec_query'
> SPI.c:197: warning: no previous prototype for `boot_SPI'
> /usr/libdata/perl5/5.00503/i386-bsdos/CORE/patchlevel.h:41: warning: `local_patches' defined but not used
> ppport.h:564: warning: `sv_2pv_nolen' defined but not used
Yeah, these all look like sloppy code generation by perlxs to me.
I see none of them on 5.8.* Perls.
regards, tom lane