--- Begin Message ---
On Thu, 12 Jan 2023 10:40:24 -0500
Michael Richardson <m...@sandelman.ca> wrote:

> Denis Ovsienko via tcpdump-workers
> <tcpdump-workers@lists.tcpdump.org> wrote:
>     > Thank you for the detailed analysis, Guy.  I did not realize
>     > the support is in the libc space rather than C99 space.  Do you
>     > think it would be appropriate to use [again] %lu instead of %zu
>     > for size_t and %ld instead of %z for ssize_t on systems that
>     > don't have %zu and %z?  
> 
> We could... but...
> It's a significant hassle to maintain this and validate this for
> future patches as well... for a product that basically nobody out
> there uses anymore.

The tests below confirm it works almost as I thought: when %z is not
available, using %l still prints the correct value, even when long is
64-bit and sizeof is 32-bit (with a compile-time warning, of course).
In other words, this is the old behaviour from several years ago:

-------------------------------------------------------------------
int main (void)
{
        int i;

        printf ("sizeof (size_t) == %u\n", sizeof (size_t));
        printf ("sizeof (ssize_t) == %u\n", sizeof (ssize_t));
        printf ("sizeof() as %%u: %u\n", sizeof (i));
        printf ("sizeof() as %%d: %d\n", sizeof (i));
        printf ("sizeof() as %%lu: %lu\n", sizeof (i));
        printf ("sizeof() as %%ld: %ld\n", sizeof (i));
        printf ("sizeof() as %%zu: %zu\n", sizeof (i));
        printf ("sizeof() as %%zd: %zd\n", sizeof (i));
        return 0;
}
-------------------------------------------------------------------
# 32-bit ARM Linux
sizeof (size_t) == 4
sizeof (ssize_t) == 4
sizeof() as %u: 4
sizeof() as %d: 4
sizeof() as %lu: 4
sizeof() as %ld: 4
sizeof() as %zu: 4
sizeof() as %zd: 4
-------------------------------------------------------------------
# 64-bit ARM Linux
sizeof (size_t) == 8
sizeof (ssize_t) == 8
sizeof() as %u: 4
sizeof() as %d: 4
sizeof() as %lu: 4
sizeof() as %ld: 4
sizeof() as %zu: 4
sizeof() as %zd: 4
-------------------------------------------------------------------
# SPARC and x86 Solaris 9
sizeof (size_t) == 4
sizeof (ssize_t) == 4
sizeof() as %u: 4
sizeof() as %d: 4
sizeof() as %lu: 4
sizeof() as %ld: 4
sizeof() as %zu: zu
sizeof() as %zd: zd
-------------------------------------------------------------------

So it would be practicable to restore Solaris 9 support in the trailing
edge department of tcpdump using compile-time-conditional length
modifier.  If anybody volunteers to implement that, it would be wrong
to get in the way, I guess.

>     > Whatever is the eventual solution, in any case from today's
>     > perspective it makes sense to stop masking these test failures.
>     >  
> 
> Agreed.
> Do you mean: Maybe just let the tests fail on Solaris, and document
> that this happens?

As the first step in any case, yes.  And make the build fail early if
the required length modifier is not supported.

-- 
    Denis Ovsienko

--- End Message ---
_______________________________________________
tcpdump-workers mailing list
tcpdump-workers@lists.tcpdump.org
https://lists.sandelman.ca/mailman/listinfo/tcpdump-workers

Reply via email to