[PATCH] Fix /bin/sh compilation with CFLAGS += -DDEBUG > 1

Garrett Cooper yanegomi at gmail.com
Wed Oct 13 08:11:11 UTC 2010


On Tue, Oct 12, 2010 at 11:56 AM, John Baldwin <jhb at freebsd.org> wrote:
> On Tuesday, October 12, 2010 2:31:36 pm Garrett Cooper wrote:
>> On Tue, Oct 12, 2010 at 5:30 AM, John Baldwin <jhb at freebsd.org> wrote:
>> > You should use %z to print size_t's, but even better is to just use %t
>> > to print a ptrdiff_t (which is the type that holds the difference of two
>> > pointers).
>>
>>     Ok. The overall temperature of using PRI* from POSIX seems like
>> it's undesirable; is it just POSIX cruft that FreeBSD conforms to in
>> theory only and doesn't really use in practice, or is there an example
>> of real practical application where it's used in the sourcebase?
>
> PRI* are ugly.  FreeBSD provides it so that we are compliant and so that
> portable code can use it, but we do not use it in our source tree because
> it is unreadable.

    Ok, I'll keep that in mind.

>> > The various changes in jobs.c should use '%td' as well rather than (int)
>> > casts.
>>
>>     Ok. Tested build and runtime on amd64 and tested build-only with i386.
>
> Hmm, jobs.c shouldn't need any of the (ptrdiff_t) casts as the expression
> being printed is already a ptrdiff_t.  See this non-debug code in jobs.c
> for example:

    Good catch. Here's another patch minus the ptrdiff_t casts (again,
builds just fine on i386, and runs perfectly fine on amd64). As you
can probably tell, I haven't used the ptrdiff_t typedef before :).
Thanks!
-Garrett
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-bin-sh-DEBUG-functionality.diff
Type: application/octet-stream
Size: 3218 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20101013/cd8d90e5/fix-bin-sh-DEBUG-functionality.obj


More information about the freebsd-hackers mailing list