Compile error for FTL after latest pull

Good morning,

I need to compile the FTL binary myself and try to pull for changes every week.
Build failed with the following error:

root@pogo01:~/FTL/cmake# cmake --build . -- -j $(nproc)
[  0%] Building C object src/ntp/CMakeFiles/ntp.dir/server.c.o
Building Pi-hole FTL daemon
   - Branch: development-v6
   - Architecture: armv6l (compiled locally)
   - Version: v5.25.2-2003-g1e419022
   - Tag: v5.25.2
   - Hash: 1e419022
   - Commit date: 2024-06-30 20:26:00 +0200
[  0%] Built target gen_version
[  0%] Building C object src/api/docs/CMakeFiles/api_docs.dir/docs.c.o
[  1%] Building C object src/ntp/CMakeFiles/ntp.dir/client.c.o
In file included from /root/FTL/src/ntp/ntp.h:14,
                 from /root/FTL/src/ntp/client.c:11:
/root/FTL/src/ntp/client.c: In function 'format_NTP_time':
/root/FTL/src/ntp/client.c:96:42: error: format '%lli' expects argument of type 'long long int', but argument 13 has type '__suseconds_t' {aka 'long int'} [-Werror=format=]
   96 |         snprintf(time_str, TIMESTR_SIZE, "%04i-%02i-%02i %02i:%02i:%02i.%06"PRIi64" %s",
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   97 |                  client_tm->tm_year + 1900, client_tm->tm_mon + 1, client_tm->tm_mday,
   98 |                  client_tm->tm_hour, client_tm->tm_min, client_tm->tm_sec, client_time.tv_usec,
      |                                                                            ~~~~~~~~~~~~~~~~~~~
      |                                                                                       |
      |                                                                                       __suseconds_t {aka long int}
/root/FTL/src/FTL.h:163:110: note: in definition of macro 'snprintf'
  163 | #define snprintf(buffer, maxlen, format, ...) FTLsnprintf(__FILE__, __FUNCTION__,  __LINE__, buffer, maxlen, format, ##__VA_ARGS__)
      |                                                                                                              ^~~~~~
cc1: all warnings being treated as errors
gmake[2]: *** [src/ntp/CMakeFiles/ntp.dir/build.make:90: src/ntp/CMakeFiles/ntp.dir/client.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:971: src/ntp/CMakeFiles/ntp.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
[  1%] Built target api_docs
gmake: *** [Makefile:136: all] Error 2
root@pogo01:~/FTL/cmake#

Also, should I "abuse" this forum for this, or are there other ways to report these kinds of errors.
Thanks!

I needed to change the erroneous line to:

        snprintf(time_str, TIMESTR_SIZE, "%04i-%02i-%02i %02i:%02i:%02i.%06ld %s",
                 client_tm->tm_year + 1900, client_tm->tm_mon + 1, client_tm->tm_mday,
                 client_tm->tm_hour, client_tm->tm_min, client_tm->tm_sec, client_time.tv_usec,
                 client_tm->tm_zone);
        time_str[TIMESTR_SIZE - 1] = '\0';

Not sure if this is correct though.

You can either comment here or directly on the GitHub repository as an issue ticket. The letter might be seen sooner, and can be referenced in the fix, but posting here should work equally well.

I will prepare a fix for this after work, it works in the way we have it both on 32 and 64 bit architectures x86 and ARM so what is your target architecture?

I guess the solution will rather be to ensure the microseconds are casted tolong long int as this change will be compatible with all architectures we support.

Are there any other error messages after you fix this left?

This code:

        snprintf(time_str, TIMESTR_SIZE, "%04i-%02i-%02i %02i:%02i:%02i.%06ld %s",
                 client_tm->tm_year + 1900, client_tm->tm_mon + 1, client_tm->tm_mday,
                 client_tm->tm_hour, client_tm->tm_min, client_tm->tm_sec, client_time.tv_usec,
                 client_tm->tm_zone);
        time_str[TIMESTR_SIZE - 1] = '\0';

Compiles and seems to work. I am running latest commits from development-v6 branch

Target architecture is:

root@pogo01:~/FTL# uname -a
Linux pogo01 5.15.158-oxnas-tld-2 #2 SMP PREEMPT Sun May 12 18:45:05 PDT 2024 armv6l GNU/Linux

I created branch tweak/pogo2 with a slightly different attempt to fix it. Could you check if this branch compiles correctly for you?

Hmmm, did you push this?

root@pogo01:~/FTL# git checkout tweak/pogo2
error: pathspec 'tweak/pogo2' did not match any file(s) known to git
root@pogo01:~/FTL#

Sorry, a typo made me push tweak/pogo without the 2. Should be there now

root@pogo01:~/FTL/cmake# cmake --build . -- -j $(nproc)
[  0%] Building C object src/ntp/CMakeFiles/ntp.dir/server.c.o
Building Pi-hole FTL daemon
   - Branch: tweak/pogo2
   - Architecture: armv6l (compiled locally)
   - Version: v5.25.2-2004-g1abf1584
   - Tag: v5.25.2
   - Hash: 1abf1584
   - Commit date: 2024-07-01 16:24:58 +0200
[  0%] Built target gen_version
[  0%] Building C object src/api/docs/CMakeFiles/api_docs.dir/docs.c.o
[  1%] Building C object src/ntp/CMakeFiles/ntp.dir/client.c.o
[  1%] Building C object src/ntp/CMakeFiles/ntp.dir/rtc.c.o
[  1%] Built target ntp
[  1%] Building C object src/webserver/CMakeFiles/webserver.dir/http-common.c.o
[  2%] Building C object src/webserver/CMakeFiles/webserver.dir/lua_web.c.o
[  2%] Building C object src/webserver/CMakeFiles/webserver.dir/webserver.c.o
[  3%] Building C object src/webserver/CMakeFiles/webserver.dir/x509.c.o

Yes, it compiles ... thanks :pray:

1 Like