aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-15 10:56:29 +0000
committerrizzo <rizzo@f38db490-d61c-443f-a65b-d21fe96a405b>2008-05-15 10:56:29 +0000
commitb19d55996cb433d6c33aaff4d0789fb3de77b0b6 (patch)
treefd6541cd8a4854ac1626ebbcb1eb20202e358260
parent83a1c36bfe82c28e119e0a8c11079154cb1da5ea (diff)
Use casts or intermediate variables to remove a number
of platform/compiler-dependent warnings when handing struct timeval fields, both reading and printing them. It is a lost battle to handle the different ways struct timeval is handled on the various platforms and compilers, so try to be pragmatic and go through int/long which are universally supported. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@116557 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_waituntil.c4
-rw-r--r--funcs/func_timeout.c7
-rw-r--r--main/features.c3
-rw-r--r--main/manager.c2
-rw-r--r--main/sched.c2
-rw-r--r--main/taskprocessor.c2
-rw-r--r--main/utils.c4
7 files changed, 15 insertions, 9 deletions
diff --git a/apps/app_waituntil.c b/apps/app_waituntil.c
index 1334683ce..98345b141 100644
--- a/apps/app_waituntil.c
+++ b/apps/app_waituntil.c
@@ -48,6 +48,7 @@ static int waituntil_exec(struct ast_channel *chan, void *data)
{
int res;
double fraction;
+ long seconds;
struct timeval future = { 0, };
struct timeval tv = ast_tvnow();
int msec;
@@ -58,12 +59,13 @@ static int waituntil_exec(struct ast_channel *chan, void *data)
return 0;
}
- if (sscanf(data, "%ld%lf", (long *)&future.tv_sec, &fraction) == 0) {
+ if (sscanf(data, "%ld%lf", &seconds, &fraction) == 0) {
ast_log(LOG_WARNING, "WaitUntil called with non-numeric argument\n");
pbx_builtin_setvar_helper(chan, "WAITUNTILSTATUS", "FAILURE");
return 0;
}
+ future.tv_sec = seconds;
future.tv_usec = fraction * 1000000;
if ((msec = ast_tvdiff_ms(future, tv)) < 0) {
diff --git a/funcs/func_timeout.c b/funcs/func_timeout.c
index 2f282b336..77d7c297e 100644
--- a/funcs/func_timeout.c
+++ b/funcs/func_timeout.c
@@ -84,6 +84,7 @@ static int timeout_write(struct ast_channel *chan, const char *cmd, char *data,
const char *value)
{
double x;
+ long sec;
char timestr[64];
struct ast_tm myt;
struct timeval tv;
@@ -99,10 +100,12 @@ static int timeout_write(struct ast_channel *chan, const char *cmd, char *data,
if (!value)
return -1;
- if ((sscanf(value, "%ld%lf", (long *)&tv.tv_sec, &x) == 0) || tv.tv_sec < 0)
+ if ((sscanf(value, "%ld%lf", &sec, &x) == 0) || sec < 0)
tv.tv_sec = 0;
- else
+ else {
+ tv.tv_sec = sec;
tv.tv_usec = x * 1000000;
+ }
switch (*data) {
case 'a':
diff --git a/main/features.c b/main/features.c
index 0b8797fcc..333b5a0f2 100644
--- a/main/features.c
+++ b/main/features.c
@@ -3565,7 +3565,8 @@ static char *handle_parkedcalls(struct ast_cli_entry *e, int cmd, struct ast_cli
AST_LIST_TRAVERSE(&curlot->parkings, cur, list) {
ast_cli(a->fd, "%-10.10s %25s (%-15s %-12s %-4d) %6lds\n"
,cur->parkingexten, cur->chan->name, cur->context, cur->exten
- ,cur->priority, cur->start.tv_sec + (cur->parkingtime/1000) - time(NULL));
+ ,cur->priority,
+ (long)(cur->start.tv_sec + (cur->parkingtime/1000) - time(NULL)) );
numparked++;
numparked += lotparked;
}
diff --git a/main/manager.c b/main/manager.c
index 2df5e8164..9ad8bd8ca 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -3105,7 +3105,7 @@ int __manager_event(int category, const char *event,
now = ast_tvnow();
ast_str_append(&buf, 0,
"Timestamp: %ld.%06lu\r\n",
- now.tv_sec, (unsigned long) now.tv_usec);
+ (long)now.tv_sec, (unsigned long) now.tv_usec);
}
if (manager_debug) {
static int seq;
diff --git a/main/sched.c b/main/sched.c
index 91d86164e..c40375d72 100644
--- a/main/sched.c
+++ b/main/sched.c
@@ -437,7 +437,7 @@ void ast_sched_dump(const struct sched_context *con)
q->id,
q->callback,
q->data,
- delta.tv_sec,
+ (long)delta.tv_sec,
(long int)delta.tv_usec);
}
ast_debug(1, "=============================================================\n");
diff --git a/main/taskprocessor.c b/main/taskprocessor.c
index cf88bb2e7..171a07725 100644
--- a/main/taskprocessor.c
+++ b/main/taskprocessor.c
@@ -220,7 +220,7 @@ static char *cli_tps_ping(struct ast_cli_entry *e, int cmd, struct ast_cli_args
ast_mutex_unlock(&cli_ping_cond_lock);
end = ast_tvnow();
delta = ast_tvsub(end, begin);
- ast_cli(a->fd, "\n\t%24s ping time: %.1ld.%.6ld sec\n\n", name, delta.tv_sec, (long int)delta.tv_usec);
+ ast_cli(a->fd, "\n\t%24s ping time: %.1ld.%.6ld sec\n\n", name, (long)delta.tv_sec, (long int)delta.tv_usec);
ao2_ref(tps, -1);
return CLI_SUCCESS;
}
diff --git a/main/utils.c b/main/utils.c
index a34514b98..92da333c3 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1202,12 +1202,12 @@ static struct timeval tvfix(struct timeval a)
{
if (a.tv_usec >= ONE_MILLION) {
ast_log(LOG_WARNING, "warning too large timestamp %ld.%ld\n",
- a.tv_sec, (long int) a.tv_usec);
+ (long)a.tv_sec, (long int) a.tv_usec);
a.tv_sec += a.tv_usec / ONE_MILLION;
a.tv_usec %= ONE_MILLION;
} else if (a.tv_usec < 0) {
ast_log(LOG_WARNING, "warning negative timestamp %ld.%ld\n",
- a.tv_sec, (long int) a.tv_usec);
+ (long)a.tv_sec, (long int) a.tv_usec);
a.tv_usec = 0;
}
return a;