Warning compiling perl stuff on Snow Leopard

Matts on 2010-01-04T22:13:57

I've searched but can't find any reference to this...

Compiling IO::KQueue on Snow Leopard I get the following warning:

KQueue.xs: In function 'XS_IO__KQueue_kevent':
KQueue.xs:71: warning: format not a string literal and no format arguments


Yet that line is just:

    Newxz(ke, max_events, struct kevent);


Which seems to me pretty standard perl, and no format strings involved (though Newxz expands quite a few macros).


More details...

Matts on 2010-01-04T22:19:13

Clang gives a few more details:

KQueue.xs:71:5: warning: format string is not a string literal (potentially insecure)
    Newxz(ke, max_events, struct kevent);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Perl/5.10.0/darwin-thread- multi-2level/CORE/handy.h:776:28: note: instantiated from:
#define Newxz(v,n,t)    (v = (MEM_WRAP_CHECK_(n,t) MEM_LOG_ALLOC(n,t,(t*)safecalloc((n),sizeof(t)))))
                              ^
/System/Library/Perl/5.10.0/darwin-thread-multi-2level/CORE/handy.h:704:30: note: instantiated from:
#define MEM_WRAP_CHECK_(n,t) MEM_WRAP_CHECK(n,t),
                             ^
/System/Library/Perl/5.10.0/darwin-thread-multi-2level/CORE/handy.h:701:29: note: instantiated from:
#define MEM_WRAP_CHECK(n,t) MEM_WRAP_CHECK_1(n,t,PL_memory_wrap)
                            ^

Re:More details...

Matts on 2010-01-04T22:23:17

Never mind... It's just a buggette in the perl that ships with SL...

MEM_WRAP_CHECK_1 is defined as:

#define MEM_WRAP_CHECK_1(n,t,a) \
    (void)(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/sizeof(t) && (Perl_croak_nocontext(a),0))

Fix is to change it to:

#define MEM_WRAP_CHECK_1(n,t,a) \
    (void)(sizeof(t) > 1 && ((MEM_SIZE)(n)+0.0) > MEM_SIZE_MAX/sizeof(t) && (Perl_croak_nocontext("%s",(a)),0))