Fix build warnings related to printf/scanf of tv_usec.

The type of tv_usec is suseconds_t. On Linux, this is usually a long int, but
the specification is actually pretty lax on what it might actually be. And,
sadly, there's no printf/scanf width specifier for suseconds_t. So it could
bit an int or a long, but there's not a great way to tell which it is.

This patch fixes scanf by reading into a long temporary variable that's then
stored into the tv_usec. It fixes printf by casting the tv_usec to a long
first.

This patch also adds some missing width specifiers for some debug statements,
which would cause ".000001" to be displayed at ".1".


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392076 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David M. Lee
2013-06-17 18:58:56 +00:00
parent 291711f85f
commit 4aa47d6893
2 changed files with 12 additions and 7 deletions

View File

@@ -1119,14 +1119,15 @@ static void cdr_object_finalize(struct cdr_object *cdr)
}
}
ast_debug(1, "Finalized CDR for %s - start %ld.%ld answer %ld.%ld end %ld.%ld dispo %s\n",
/* tv_usec is suseconds_t, which could be int or long */
ast_debug(1, "Finalized CDR for %s - start %ld.%06ld answer %ld.%06ld end %ld.%06ld dispo %s\n",
cdr->party_a.snapshot->name,
cdr->start.tv_sec,
cdr->start.tv_usec,
(long)cdr->start.tv_usec,
cdr->answer.tv_sec,
cdr->answer.tv_usec,
(long)cdr->answer.tv_usec,
cdr->end.tv_sec,
cdr->end.tv_usec,
(long)cdr->end.tv_usec,
ast_cdr_disp2str(cdr->disposition));
}
@@ -1151,9 +1152,10 @@ static void cdr_object_check_party_a_answer(struct cdr_object *cdr) {
if (cdr->party_a.snapshot->state == AST_STATE_UP && ast_tvzero(cdr->answer)) {
cdr->answer = ast_tvnow();
CDR_DEBUG(mod_cfg, "%p - Set answered time to %ld.%ld\n", cdr,
/* tv_usec is suseconds_t, which could be int or long */
CDR_DEBUG(mod_cfg, "%p - Set answered time to %ld.%06ld\n", cdr,
cdr->answer.tv_sec,
cdr->answer.tv_usec);
(long)cdr->answer.tv_usec);
}
}