[asterisk-commits] rizzo: trunk r116557 - in /trunk: apps/ funcs/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 15 05:56:29 CDT 2008
Author: rizzo
Date: Thu May 15 05:56:29 2008
New Revision: 116557
URL: http://svn.digium.com/view/asterisk?view=rev&rev=116557
Log:
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.
Modified:
trunk/apps/app_waituntil.c
trunk/funcs/func_timeout.c
trunk/main/features.c
trunk/main/manager.c
trunk/main/sched.c
trunk/main/taskprocessor.c
trunk/main/utils.c
Modified: trunk/apps/app_waituntil.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_waituntil.c?view=diff&rev=116557&r1=116556&r2=116557
==============================================================================
--- trunk/apps/app_waituntil.c (original)
+++ trunk/apps/app_waituntil.c Thu May 15 05:56:29 2008
@@ -48,6 +48,7 @@
{
int res;
double fraction;
+ long seconds;
struct timeval future = { 0, };
struct timeval tv = ast_tvnow();
int msec;
@@ -58,12 +59,13 @@
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) {
Modified: trunk/funcs/func_timeout.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_timeout.c?view=diff&rev=116557&r1=116556&r2=116557
==============================================================================
--- trunk/funcs/func_timeout.c (original)
+++ trunk/funcs/func_timeout.c Thu May 15 05:56:29 2008
@@ -84,6 +84,7 @@
const char *value)
{
double x;
+ long sec;
char timestr[64];
struct ast_tm myt;
struct timeval tv;
@@ -99,10 +100,12 @@
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':
Modified: trunk/main/features.c
URL: http://svn.digium.com/view/asterisk/trunk/main/features.c?view=diff&rev=116557&r1=116556&r2=116557
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Thu May 15 05:56:29 2008
@@ -3565,7 +3565,8 @@
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;
}
Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=116557&r1=116556&r2=116557
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Thu May 15 05:56:29 2008
@@ -3105,7 +3105,7 @@
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;
Modified: trunk/main/sched.c
URL: http://svn.digium.com/view/asterisk/trunk/main/sched.c?view=diff&rev=116557&r1=116556&r2=116557
==============================================================================
--- trunk/main/sched.c (original)
+++ trunk/main/sched.c Thu May 15 05:56:29 2008
@@ -437,7 +437,7 @@
q->id,
q->callback,
q->data,
- delta.tv_sec,
+ (long)delta.tv_sec,
(long int)delta.tv_usec);
}
ast_debug(1, "=============================================================\n");
Modified: trunk/main/taskprocessor.c
URL: http://svn.digium.com/view/asterisk/trunk/main/taskprocessor.c?view=diff&rev=116557&r1=116556&r2=116557
==============================================================================
--- trunk/main/taskprocessor.c (original)
+++ trunk/main/taskprocessor.c Thu May 15 05:56:29 2008
@@ -220,7 +220,7 @@
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;
}
Modified: trunk/main/utils.c
URL: http://svn.digium.com/view/asterisk/trunk/main/utils.c?view=diff&rev=116557&r1=116556&r2=116557
==============================================================================
--- trunk/main/utils.c (original)
+++ trunk/main/utils.c Thu May 15 05:56:29 2008
@@ -1202,12 +1202,12 @@
{
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;
More information about the asterisk-commits
mailing list