<p>Sebastian Kemper <strong>uploaded patch set #4</strong> to this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/16621">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">time: add support for time64 libcs<br><br>libcs are implementing changes to fix the year 2038 issue on 32 bit<br>platforms (see [1]). musl libc already went ahead and implemented it,<br>starting with musl-1.2.0 (see [2]).<br><br>Running asterisk on a 32 bit box with a time64 libc causes some<br>problems. For instance registering to pjsip doesn't work. The<br>registration completes fine, but the AOR disappears immediately, making<br>the registered clients unreachable.<br><br>Currently time_t is always expected to be (long). This commit changes<br>this and instead always uses "lld" when dealing with time_t and casting<br>the values to be formatted to (long long). The aim is to be future proof<br>and portable. This was suggested on the musl mailing list ([3]).<br><br>When it comes to scanning, no assumptions can be made regarding the type<br>of the time_t destination. It is unknown as it is depending on the<br>platform. So we "read into a known-size integer (either int or long<br>long) and then assign the value to a time_t as a second step" (quote<br>from [4]).<br><br>These changes get rid of the new warnings that appeared with musl-1.2.0 and<br>make the pjsip registration work again. Below an example warning:<br><br>In file included from ../include/asterisk.h:23,<br>                 from res_pjsip/location.c:19:<br>res_pjsip/location.c: In function 'expiration_struct2str':<br>../include/asterisk/astmm.h:270:72: warning: format '%ld' expects argument of type 'long int', but argument 6 has type 'time_t' {aka 'long long int'} [-Wformat=]<br>  270 |         __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__)<br>      |                                                                        ^~~~~<br>res_pjsip/location.c:492:17: note: in expansion of macro 'ast_asprintf'<br>  492 |         return (ast_asprintf(buf, "%ld", contact->expiration_time.tv_sec) < 0) ? -1 : 0;<br>      |                 ^~~~~~~~~~~~<br><br>[1] https://sourceware.org/glibc/wiki/Y2038ProofnessDesign<br>[2] https://musl.libc.org/time64.html<br>[3] https://www.openwall.com/lists/musl/2021/10/27/3<br>[4] https://stackoverflow.com/questions/4171478/how-to-read-data-into-a-time-t-variable-using-scanf<br><br>ASTERISK-29674 #close<br><br>Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net><br>Change-Id: Ic8d61b26033f5c486b917e738c9608b0923a844e<br>---<br>M include/asterisk/time.h<br>M res/res_calendar_caldav.c<br>M res/res_calendar_icalendar.c<br>M res/res_http_media_cache.c<br>M res/res_odbc.c<br>M res/res_pjsip/location.c<br>M res/res_pjsip/pjsip_options.c<br>M res/res_pjsip_history.c<br>M res/res_pjsip_pubsub.c<br>M res/res_pjsip_registrar.c<br>M res/res_stir_shaken.c<br>11 files changed, 34 insertions(+), 19 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/21/16621/4</pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/16621">change 16621</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/16621"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: Ic8d61b26033f5c486b917e738c9608b0923a844e </div>
<div style="display:none"> Gerrit-Change-Number: 16621 </div>
<div style="display:none"> Gerrit-PatchSet: 4 </div>
<div style="display:none"> Gerrit-Owner: Sebastian Kemper <sebastian_ml@gmx.net> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>