Andrea Venturoli <ml_at_netfence.it> wrote on
Date: Mon, 09 Dec 2024 16:00:34 UTC :


> I've just upgraded my Poudriere host to 14.2 and I'm rebuilding the 
> packages I use (with 2024Q4 branch).
> tcptrack fails with:
> 
> > c++ -DHAVE_CONFIG_H -I. -I.. -Werror -Wno-deprecated -Wall -O2 -pipe 
> > -Wno-error=unused-but-set-variable -fstack-protector-strong 
> > -fno-strict-aliasing -std=c++14 -MT TextUI.o -MD -MP -MF .deps/TextUI.Tpo 
> > -c -o TextUI.o TextUI.cc
> > TextUI.cc:306:17: error: format specifies type 'int' but the argument has 
> > type 'time_t' (aka 'long') [-Werror,-Wformat]
> > 306 | printw("%ds",ic->getIdleSeconds());
> > | ~~ ^~~~~~~~~~~~~~~~~~~~
> > | %ld
> > TextUI.cc:308:17: error: format specifies type 'int' but the argument has 
> > type 'time_t' (aka 'long') [-Werror,-Wformat]

time_t is platform specific. See later notes.

> > 308 | printw("%dm",ic->getIdleSeconds()/60);
> > | ~~ ^~~~~~~~~~~~~~~~~~~~~~~
> > | %ld
> > TextUI.cc:310:17: error: format specifies type 'int' but the argument has 
> > type 'time_t' (aka 'long') [-Werror,-Wformat]
> > 310 | printw("%dh",ic->getIdleSeconds()/3600);
> > | ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
> > | %ld
> > 3 errors generated.
> 
> 
> I'm attaching full build log.
> 
> I think this is the same as:
> > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=997254
> 
> I could fix this myself (and possibly provide a patch).
> However I'm wondering if this is the right thing to do, given it seems 
> there's a new version around.
> 
> Have you already seen this errors?
> What are you plans with the ports?
> 
> Should I file a bug report?
> Or is this some problem on my side???


From "man arch" about the variable relationship of time_t and
long and the like:

. . .
   Type sizes
     All FreeBSD architectures use some variant of the ELF (see elf(5))
     Application Binary Interface (ABI) for the machine processor.  All
     supported ABIs can be divided into two groups:

     ILP32     int, long, void * types machine representations all have 4-byte
               size.

     LP64      int type machine representation uses 4 bytes, while long and
               void * are 8 bytes.

. . .

     Machine-dependent type sizes:

           Architecture    void *    long double    time_t
           aarch64         8         16             8
           amd64           8         16             8
           armv7           4         8              8
           i386            4         12             4
           powerpc         4         8              8
           powerpcspe      4         8              8
           powerpc64       8         8              8
           powerpc64le     8         8              8
           riscv64         8         16             8
. . .

I'll note that sizeof(long) == sizeof(void*) for both
ILP32 and LP64. So the void* column matched what a
"long column" would be like. So:

time_t is not long on armv7 or on powerpc or on
powerpcspe. time_t only matches the size of int for
i386. (All this could be FreeBSD specific.)

You really do not want the format accessing too few or
too many bytes on any architecture/platform.

A normal way to handle this is to cast the time_t value
to a type that is the same for all architectures and
that would not lose information about the original value.
Also use a format that matches the casted-to type.

So, the issue looks to me to be either an issue for
upstream or an issue for the port maintainer. Upstream
would not be limited to handling FreeBSD's specifics,
making it more complicated for them overall.

===
Mark Millard
marklmi at yahoo.com


Reply via email to