Package: ekg2 / 1:0.4~pre+20120506.1-8

Metadata

Package Version Patches format
ekg2 1:0.4~pre+20120506.1-8 3.0 (quilt)

Patch series

view the series file
Patch File delta Description
fix varargs handling | (download)

ekg/sources.c | 13 11 + 2 - 0 !
1 file changed, 11 insertions(+), 2 deletions(-)

 fix varargs handling to build on armhf
 NULL is not a valid va_list value, and armhf for example fails to build with
 it. Pass an empty list in that case.
gtestutils segfault | (download)

plugins/check/check.c | 7 4 + 3 - 0 !
1 file changed, 4 insertions(+), 3 deletions(-)

 [patch] fix check_ekg2 segfault.

There are a few interesting things here.

1) When I first saw "char **argv = { NULL }" I thought this initializes
argv as a pointer to a one-element array holding a null pointer. I
suspect this was also the intent of the author of this code.

Turns out it's wrong. It actually initializes argv to be just a null
pointer, and is exactly equivalent to "char **argv = NULL". The curly
braces only make sense if the type is an array, and are just ignored
otherwise.

So the first thing was to change argv from char** to char*[] to be able
to use an array initializer.

2) Since char*[] decays into a char** on assignment, one might think
that taking argv (which now is a char*[]) and prepending it with & will
make it decay to a char ***, or at least create a type equivalent to
that. But it doesn't. "&argv" is of type "char * (*)[]" which is
(according to http://www.unixwiz.net/techtips/reading-cdecl.html) a
pointer to an array of pointers to char and (surprise surprise!) causes
both a warning and a crash if I try to pass it as a char*** argument.
It's still a bit of a mystery to me, but looking in GDB it looks like
dereferencing it in g_test_init results in a junk pointer.

3) And finally, recent glib requires the leading element of argv to be
non-null, and crashes otherwise.