[asterisk-bugs] [JIRA] (SS7-63) fails to build on x32: isup.c:5239:60: error: format '%li' expects argument of type 'long int', but argument 6 has type 'long long int'

Sean Bright (JIRA) noreply at issues.asterisk.org
Fri Aug 27 09:33:33 CDT 2021


    [ https://issues.asterisk.org/jira/browse/SS7-63?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=247659#comment-247659 ] 

Sean Bright edited comment on SS7-63 at 8/27/21 9:32 AM:
---------------------------------------------------------

time_t has always been long long int on x32, to avoid the 2038 epoch problem.

One way to resolve this would be something like this:

{noformat}
#if defined __x86_64__ && defined __ILP32__
		buf_used = ss7_snprintf(buf, buf_used, buf_size, "%s(%lli) ", isup_timer2str(x),  ss7->ss7_sched[c->timer[x]].when.tv_sec - time(NULL));
#else
 		buf_used = ss7_snprintf(buf, buf_used, buf_size, "%s(%li) ", isup_timer2str(x),  ss7->ss7_sched[c->timer[x]].when.tv_sec - time(NULL));
#endif
{noformat}


was (Author: greenreaper):
time_t has always been long long int on x32, to avoid the 2038 epoch problem.

One way to resolve this would be something like this:
#if defined __x86_64__ && defined __ILP32__
		buf_used = ss7_snprintf(buf, buf_used, buf_size, "%s(%lli) ", isup_timer2str(x),  ss7->ss7_sched[c->timer[x]].when.tv_sec - time(NULL));
#else
 		buf_used = ss7_snprintf(buf, buf_used, buf_size, "%s(%li) ", isup_timer2str(x),  ss7->ss7_sched[c->timer[x]].when.tv_sec - time(NULL));
#endif

> fails to build on x32: isup.c:5239:60: error: format '%li' expects argument of type 'long int', but argument 6 has type 'long long int'
> ---------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: SS7-63
>                 URL: https://issues.asterisk.org/jira/browse/SS7-63
>             Project: LibSS7
>          Issue Type: Bug
>      Security Level: None
>          Components: General
>         Environment: x32/debian (32 bits userspace on a 64 bits kernel)
>            Reporter: Tzafrir Cohen
>            Assignee: Matthew Fredrickson
>
> {code}
> gcc -g -O2 -fdebug-prefix-map=/<<PKGBUILDDIR>>=. -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -fPIC -O2  -MD -MT isup.o -MF .isup.o.d -MP -c -o isup.o isup.c
> isup.c: In function 'isup_show_calls':
> isup.c:5239:60: error: format '%li' expects argument of type 'long int', but argument 6 has type 'long long int' [-Werror=format=]
>      buf_used = ss7_snprintf(buf, buf_used, buf_size, "%s(%li) ", isup_timer2str(x),  ss7->ss7_sched[c->timer[x]].when.tv_sec - time(NULL));
>                                                             ^
> {code}
> Full log: https://buildd.debian.org/status/fetch.php?pkg=libss7&arch=x32&ver=2.0.0-2&stamp=1477953533
> Other platforms seem to build well:
> https://buildd.debian.org/status/package.php?p=libss7



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list