summaryrefslogtreecommitdiff
path: root/funcs
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 /funcs
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 'funcs')
-rw-r--r--funcs/func_cdr.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c
index 0f900feda..492716dcf 100644
--- a/funcs/func_cdr.c
+++ b/funcs/func_cdr.c
@@ -248,11 +248,14 @@ static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse,
|| !strcasecmp("answer", args.variable)) {
struct timeval fmt_time;
struct ast_tm tm;
- if (sscanf(tempbuf, "%ld.%ld", &fmt_time.tv_sec, &fmt_time.tv_usec) != 2) {
+ /* tv_usec is suseconds_t, which could be int or long */
+ long int tv_usec;
+ if (sscanf(tempbuf, "%ld.%ld", &fmt_time.tv_sec, &tv_usec) != 2) {
ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n",
args.variable, tempbuf, ast_channel_name(chan));
return 0;
}
+ fmt_time.tv_usec = tv_usec;
ast_localtime(&fmt_time, &tm, NULL);
ast_strftime(tempbuf, sizeof(*tempbuf), "%Y-%m-%d %T", &tm);
} else if (!strcasecmp("disposition", args.variable)) {