summaryrefslogtreecommitdiff
path: root/main/cdr.c
diff options
context:
space:
mode:
authorDavid M. Lee <dlee@digium.com>2013-06-17 18:58:56 +0000
committerDavid M. Lee <dlee@digium.com>2013-06-17 18:58:56 +0000
commit4aa47d68930a3ff4e750a6044f51524a76185899 (patch)
tree6b98b07b6aa1276446ffd81f40683f95756e307d /main/cdr.c
parent291711f85fcf9eb616959d68155d7483f81dac3f (diff)
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
Diffstat (limited to 'main/cdr.c')
-rw-r--r--main/cdr.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/main/cdr.c b/main/cdr.c
index b73f9cec2..2ec684837 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -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);
}
}