[ccan] Testing ccanlint on Cygwin (gcc 4.3.4-3)

Adam Kennedy adamkennedybackup at gmail.com
Fri Mar 11 17:30:00 EST 2011


Making your own alternative versions for stuff is usually bad, that
way lies boost and turning into "layer".

You don't want to be a layer, you want to be a set of small standalone
libraries, some of which just happen to depend on others.

Adam K

On 11 March 2011 11:20, Rusty Russell <rusty at rustcorp.com.au> wrote:
> On Tue, 8 Mar 2011 15:27:03 +1100, Sam Watkins <sam at nipl.net> wrote:
>> >  * ctype.h functions (islower, toupper, etc.) result in array
>> > subscript warnings, treated as errors, when passed chars.  What else
>> > would you pass them?
>>
>> > Weird.  But such warnigns are not fatal, so I don't think we should be
>> > working around them in CCAN in general.
>>
>> It becomes fatal when you pass them signed chars having values less than -1.
>> A plain 'char' may be signed or unsigned depending on the architecture.
>>
>> You must not pass a plain char directly to islower() and friends.  The
>> functions take int arguments, having the value of an _unsigned_ char, or EOF
>> (typically -1).
>
> Yech... somehow I had managed to avoid this ugly truth until now.
>
> So I did a rough audit of code sitting on my box to see who gets this right.
>
> 1) The glibc versions handle down to -128 ("for broken old programs").
> 2) popt: gets it wrong. (config file parsing).
> 3) iniparser: gets it wrong. (strlwc and strupc implementations).
> 4) samba: gets it right in five places!  Wrong everywhere else (many places).
>
> So, everyone is buggy, and that's not going to change.  Hence the glibc
> behaviour is the way forward.
>
> Meanwhile, we have four options:
>
> (1) Create ccan wrappers which warn (using __builtin_compatible_p).
> (2) Create ccan wrappers which fix (using an extra test, maybe getting
>    tricky with __builtin_compatible_p to optimize)
> (3) Create ccan replacements, eg. cisupper etc.
> (4) Fix our own code then stick our heads back in the sand.
>
> Thoughts?
> Rusty.
>
> PS.  Our places to fix:
> ccan/talloc_link/_info:66: *                    *upstr = toupper(*upstr);
> ccan/failtest/failtest.c:366:                   if (tolower(*failpath) != info_to_arg[call->type])
> ccan/failtest/failtest.c:369:                   call->fail = isupper(*(failpath++));
> ccan/tdb/tools/replay_trace.c:173:      c = toupper(c);
> ccan/antithread/_info:45: *                             else if (toupper(r[i]) < 'N')
> ccan/ciniparser/ciniparser.c:73:                l[i] = tolower(s[i]);
> tools/doc_extract-core.c:115:           lowertype[i] = tolower(type[i]);
> tools/ccanlint/tests/headers_idempotent.c:31:                   name[i] = toupper(name[i]);
> tools/ccanlint/tests/examples_compile.c:154:    for (p = end; isalnum(*p) || *p == '_'; p--) {
> tools/ccanlint/tests/examples_compile.c:191:            if (!line[0] || isspace(line[0]) || strstarts(line, "//"))
> tools/ccanlint/tests/examples_compile.c:231:                && ispunct(line[len+strspn(line+len, " ")])) {
> tools/ccanlint/tests/examples_run.c:49:         if (toupper(input[0]) != toupper(fmt[0]))
> tools/ccanlint/ccanlint.c:74:           && toupper(reply[0]) == 'Y';
> _______________________________________________
> ccan mailing list
> ccan at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/ccan
>


More information about the ccan mailing list