Closed televator closed 6 months ago
Thank you for digging into this. It was just a quick win.
I don't think this would fix the underlying problem. It looks wrong to me to fix it by an explicit cast. (As this needs to be done everywhere) The source is the wrong PRIuTIME. Explicitly setting this to ull on ARM (32 bit only?) would mitigate that.
Thanks @SciLor. I digged a bit more into this, trying this on different architectures (amd64, armv6) with multiple derivatives (debian, raspberry pi os, alpine), couldn't reproduce any of this on godbolt (with different archs and compiler versions). The problem seems to be just to alpine on arm (64, 32bit not known). You might have seen other problematic combinations in your build pipelines before silencing the warning, but for now I assume this is limited my setup. That explains why cyclone common PRIuTIME is good enough.
There does not seem to be a nice solution. Docs show the recommendation is not to use the time_t value directly, but not viable alternative for a unix timestamp is given. I totally agree that the cast - despite being the safe and small hack - is considered too ugly.
This should be addressed with the latest build.
TeddyCloud time stays 0 when not forwarding requests to the Boxine cloud.
Setup: TeddyCloud running on Raspberry Pi Zero W (arm6l) within a container, latest alpine version.
I debugged the issue and the problem is on formatting the time_t
osSprintf(response, "%" PRIuTIME, time(NULL));
The
PRIuTIME
that comes from cyclone common describestime_t
as%lu
, so asunsigned long
. On ARM, however,time_t
is anunsigned long long
. I noticed that @SciLor explicitly silenced the warning for this, but I missing the whole picture. There are multiple stackoverflow threads on this topic on how to get the proper printf-symbol, the most helpful being this.I suggest to cast the calls to
time(NULL)
tounsigned long long
, so make themosSprintf(response, "%llu", (unsigned long long)time(NULL));
. I can open a PR with this, if you agree.