aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-26 18:19:12 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-12-26 18:19:12 +0000
commitc5acba479d47d47b0809d2627f22762e77a7669f (patch)
tree1a9f3f52b9d9fdc502c341ca74ba1231bc98d753
parent678447e2d0fca85d2879bb94a68fda191f26f2dc (diff)
cast time_t to an int in printf/scanf (issue #5635)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.2@7634 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--apps/app_chanspy.c2
-rw-r--r--apps/app_externalivr.c4
-rw-r--r--apps/app_queue.c16
-rw-r--r--apps/app_sms.c8
-rw-r--r--asterisk.c14
-rw-r--r--channels/chan_agent.c4
-rw-r--r--channels/chan_iax2.c16
-rw-r--r--channels/chan_sip.c6
-rw-r--r--cli.c4
-rw-r--r--config.c2
-rw-r--r--pbx/pbx_dundi.c6
-rw-r--r--res/res_monitor.c4
12 files changed, 44 insertions, 42 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 58a6787d0..25a195096 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -439,7 +439,7 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
if (recbase) {
char filename[512];
- snprintf(filename,sizeof(filename),"%s/%s.%ld.raw",ast_config_AST_MONITOR_DIR, recbase, time(NULL));
+ snprintf(filename,sizeof(filename),"%s/%s.%d.raw",ast_config_AST_MONITOR_DIR, recbase, (int)time(NULL));
if ((fd = open(filename, O_CREAT | O_WRONLY, O_TRUNC)) <= 0) {
ast_log(LOG_WARNING, "Cannot open %s for recording\n", filename);
fd = 0;
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index ad27c1659..a53a59532 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -94,9 +94,9 @@ static void send_child_event(FILE *handle, const char event, const char *data,
char tmp[256];
if (!data) {
- snprintf(tmp, sizeof(tmp), "%c,%10ld", event, time(NULL));
+ snprintf(tmp, sizeof(tmp), "%c,%10d", event, (int)time(NULL));
} else {
- snprintf(tmp, sizeof(tmp), "%c,%10ld,%s", event, time(NULL), data);
+ snprintf(tmp, sizeof(tmp), "%c,%10d,%s", event, (int)time(NULL), data);
}
fprintf(handle, "%s\n", tmp);
diff --git a/apps/app_queue.c b/apps/app_queue.c
index a6c7e3446..f34e6a0b2 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -484,11 +484,11 @@ static void *changethread(void *data)
"Membership: %s\r\n"
"Penalty: %d\r\n"
"CallsTaken: %d\r\n"
- "LastCall: %ld\r\n"
+ "LastCall: %d\r\n"
"Status: %d\r\n"
"Paused: %d\r\n",
q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
- cur->penalty, cur->calls, cur->lastcall, cur->status, cur->paused);
+ cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
}
}
}
@@ -1262,11 +1262,11 @@ static int update_status(struct ast_call_queue *q, struct member *member, int st
"Membership: %s\r\n"
"Penalty: %d\r\n"
"CallsTaken: %d\r\n"
- "LastCall: %ld\r\n"
+ "LastCall: %d\r\n"
"Status: %d\r\n"
"Paused: %d\r\n",
q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
- cur->penalty, cur->calls, cur->lastcall, cur->status, cur->paused);
+ cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
}
break;
}
@@ -2422,11 +2422,11 @@ static int add_to_queue(char *queuename, char *interface, int penalty, int pause
"Membership: %s\r\n"
"Penalty: %d\r\n"
"CallsTaken: %d\r\n"
- "LastCall: %ld\r\n"
+ "LastCall: %d\r\n"
"Status: %d\r\n"
"Paused: %d\r\n",
q->name, new_member->interface, new_member->dynamic ? "dynamic" : "static",
- new_member->penalty, new_member->calls, new_member->lastcall, new_member->status, new_member->paused);
+ new_member->penalty, new_member->calls, (int)new_member->lastcall, new_member->status, new_member->paused);
if (dump)
dump_queue_members(q);
@@ -3436,13 +3436,13 @@ static int manager_queues_status( struct mansession *s, struct message *m )
"Membership: %s\r\n"
"Penalty: %d\r\n"
"CallsTaken: %d\r\n"
- "LastCall: %ld\r\n"
+ "LastCall: %d\r\n"
"Status: %d\r\n"
"Paused: %d\r\n"
"%s"
"\r\n",
q->name, mem->interface, mem->dynamic ? "dynamic" : "static",
- mem->penalty, mem->calls, mem->lastcall, mem->status, mem->paused, idText);
+ mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, idText);
}
}
/* List Queue Entries */
diff --git a/apps/app_sms.c b/apps/app_sms.c
index c6feb5560..4c15cc185 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -694,7 +694,7 @@ static void sms_readfile (sms_t * h, char *fn)
}
while (fgets (line, sizeof (line), s))
{ /* process line in file */
- char *p;
+ unsigned char *p;
for (p = line; *p && *p != '\n' && *p != '\r'; p++);
*p = 0; /* strip eoln */
p = line;
@@ -1379,8 +1379,8 @@ static int sms_exec (struct ast_channel *chan, void *data)
ast_copy_string (h.cli, chan->cid.cid_num, sizeof (h.cli));
{
- char *d = data,
- *p,
+ unsigned char *p;
+ unsigned char *d = data,
answer = 0;
if (!*d || *d == '|') {
ast_log (LOG_ERROR, "Requires queue name\n");
@@ -1449,7 +1449,7 @@ static int sms_exec (struct ast_channel *chan, void *data)
d = p;
h.udl = 0;
while (*p && h.udl < SMSLEN)
- h.ud[h.udl++] = utf8decode((unsigned char **)&p);
+ h.ud[h.udl++] = utf8decode(&p);
if (is7bit (h.dcs) && packsms7 (0, h.udhl, h.udh, h.udl, h.ud) < 0)
ast_log (LOG_WARNING, "Invalid 7 bit GSM data\n");
if (is8bit (h.dcs) && packsms8 (0, h.udhl, h.udh, h.udl, h.ud) < 0)
diff --git a/asterisk.c b/asterisk.c
index 9acbc56c1..a382b78e4 100644
--- a/asterisk.c
+++ b/asterisk.c
@@ -685,8 +685,10 @@ static int ast_makesocket(void)
ast_log(LOG_WARNING, "Unable to change ownership of %s: %s\n", ast_config_AST_SOCKET, strerror(errno));
if (!ast_strlen_zero(ast_config_AST_CTL_PERMISSIONS)) {
+ int p1;
mode_t p;
- sscanf(ast_config_AST_CTL_PERMISSIONS, "%o", (int *) &p);
+ sscanf(ast_config_AST_CTL_PERMISSIONS, "%o", &p1);
+ p = p1;
if ((chmod(ast_config_AST_SOCKET, p)) < 0)
ast_log(LOG_WARNING, "Unable to change file permissions of %s: %s\n", ast_config_AST_SOCKET, strerror(errno));
}
@@ -1332,7 +1334,7 @@ static char *cli_prompt(EditLine *el)
if (*t == '%') {
char hostname[MAXHOSTNAMELEN]="";
int i;
- struct timeval tv;
+ time_t ts;
struct tm tm;
#ifdef linux
FILE *LOADAVG;
@@ -1360,8 +1362,8 @@ static char *cli_prompt(EditLine *el)
break;
case 'd': /* date */
memset(&tm, 0, sizeof(struct tm));
- tv = ast_tvnow();
- if (localtime_r(&(tv.tv_sec), &tm)) {
+ time(&ts);
+ if (localtime_r(&ts, &tm)) {
strftime(p, sizeof(prompt) - strlen(prompt), "%Y-%m-%d", &tm);
}
break;
@@ -1417,8 +1419,8 @@ static char *cli_prompt(EditLine *el)
#endif
case 't': /* time */
memset(&tm, 0, sizeof(struct tm));
- tv = ast_tvnow();
- if (localtime_r(&(tv.tv_sec), &tm)) {
+ time(&ts);
+ if (localtime_r(&ts, &tm)) {
strftime(p, sizeof(prompt) - strlen(prompt), "%H:%M:%S", &tm);
}
break;
diff --git a/channels/chan_agent.c b/channels/chan_agent.c
index 57e5f9a71..2a416f32e 100644
--- a/channels/chan_agent.c
+++ b/channels/chan_agent.c
@@ -1445,11 +1445,11 @@ static int action_agents(struct mansession *s, struct message *m)
"Name: %s\r\n"
"Status: %s\r\n"
"LoggedInChan: %s\r\n"
- "LoggedInTime: %ld\r\n"
+ "LoggedInTime: %d\r\n"
"TalkingTo: %s\r\n"
"%s"
"\r\n",
- p->agent, username, status, loginChan, p->loginstart, talkingtoChan, idText);
+ p->agent, username, status, loginChan, (int)p->loginstart, talkingtoChan, idText);
ast_mutex_unlock(&p->lock);
p = p->next;
}
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index 567d9c426..f5a06f232 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -2599,7 +2599,7 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
break;
}
} else if (!strcasecmp(tmp->name, "regseconds")) {
- if (sscanf(tmp->value, "%li", &regseconds) != 1)
+ if (sscanf(tmp->value, "%i", (int *)&regseconds) != 1)
regseconds = 0;
} else if (!strcasecmp(tmp->name, "ipaddr")) {
inet_aton(tmp->value, &(peer->addr.sin_addr));
@@ -2638,13 +2638,13 @@ static struct iax2_peer *realtime_peer(const char *peername, struct sockaddr_in
if ((nowtime - regseconds) > IAX_DEFAULT_REG_EXPIRE) {
memset(&peer->addr, 0, sizeof(peer->addr));
if (option_debug)
- ast_log(LOG_DEBUG, "realtime_peer: Bah, '%s' is expired (%ld/%ld/%ld)!\n",
- peername, nowtime - regseconds, regseconds, nowtime);
+ ast_log(LOG_DEBUG, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
+ peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
else {
if (option_debug)
- ast_log(LOG_DEBUG, "realtime_peer: Registration for '%s' still active (%ld/%ld/%ld)!\n",
- peername, nowtime - regseconds, regseconds, nowtime);
+ ast_log(LOG_DEBUG, "realtime_peer: Registration for '%s' still active (%d/%d/%d)!\n",
+ peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
}
@@ -2700,7 +2700,7 @@ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin)
time_t nowtime;
time(&nowtime);
- snprintf(regseconds, sizeof(regseconds), "%ld", nowtime);
+ snprintf(regseconds, sizeof(regseconds), "%d", (int)nowtime);
ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin->sin_addr);
snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port));
ast_update_realtime("iaxpeers", "name", peername, "ipaddr", ipaddr, "port", port, "regseconds", regseconds, NULL);
@@ -4285,7 +4285,7 @@ static int iax2_show_firmware(int fd, int argc, char *argv[])
#if !defined(__FreeBSD__)
#define FORMAT "%-15.15s %-15d %-15d\n"
#else /* __FreeBSD__ */
-#define FORMAT "%-15.15s %-15d %-15ld\n"
+#define FORMAT "%-15.15s %-15d %-15d\n" /* XXX 2.95 ? */
#endif /* __FreeBSD__ */
struct iax_firmware *cur;
if ((argc != 3) && (argc != 4))
@@ -4296,7 +4296,7 @@ static int iax2_show_firmware(int fd, int argc, char *argv[])
for (cur = waresl.wares;cur;cur = cur->next) {
if ((argc == 3) || (!strcasecmp(argv[3], (char *)cur->fwh->devname)))
ast_cli(fd, FORMAT, cur->fwh->devname, ntohs(cur->fwh->version),
- ntohl(cur->fwh->datalen));
+ (int)ntohl(cur->fwh->datalen));
}
ast_mutex_unlock(&waresl.lock);
return RESULT_SUCCESS;
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index f1d549b57..10745916e 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1594,7 +1594,7 @@ static void realtime_update_peer(const char *peername, struct sockaddr_in *sin,
time_t nowtime;
time(&nowtime);
nowtime += expirey;
- snprintf(regseconds, sizeof(regseconds), "%ld", nowtime); /* Expiration time */
+ snprintf(regseconds, sizeof(regseconds), "%d", (int)nowtime); /* Expiration time */
ast_inet_ntoa(ipaddr, sizeof(ipaddr), sin->sin_addr);
snprintf(port, sizeof(port), "%d", ntohs(sin->sin_port));
}
@@ -12069,7 +12069,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
}
if (realtime && !strcasecmp(v->name, "regseconds")) {
- if (sscanf(v->value, "%li", &regseconds) != 1)
+ if (sscanf(v->value, "%i", (int *)&regseconds) != 1)
regseconds = 0;
} else if (realtime && !strcasecmp(v->name, "ipaddr") && !ast_strlen_zero(v->value) ) {
inet_aton(v->value, &(peer->addr.sin_addr));
@@ -12232,7 +12232,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
destroy_association(peer);
memset(&peer->addr, 0, sizeof(peer->addr));
if (option_debug)
- ast_log(LOG_DEBUG, "Bah, we're expired (%ld/%ld/%ld)!\n", nowtime - regseconds, regseconds, nowtime);
+ ast_log(LOG_DEBUG, "Bah, we're expired (%d/%d/%d)!\n", (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
}
}
ast_copy_flags(peer, &peerflags, mask.flags);
diff --git a/cli.c b/cli.c
index a0e80bea6..4a0f95e54 100644
--- a/cli.c
+++ b/cli.c
@@ -360,7 +360,7 @@ static int handle_showuptime(int fd, int argc, char *argv[])
if (ast_startuptime) {
tmptime = curtime - ast_startuptime;
if (printsec) {
- ast_cli(fd, "System uptime: %lu\n",tmptime);
+ ast_cli(fd, "System uptime: %lu\n",(u_long)tmptime);
} else {
timestr = format_uptimestr(tmptime);
if (timestr) {
@@ -372,7 +372,7 @@ static int handle_showuptime(int fd, int argc, char *argv[])
if (ast_lastreloadtime) {
tmptime = curtime - ast_lastreloadtime;
if (printsec) {
- ast_cli(fd, "Last reload: %lu\n", tmptime);
+ ast_cli(fd, "Last reload: %lu\n", (u_long) tmptime);
} else {
timestr = format_uptimestr(tmptime);
if ((timestr) && (!printsec)) {
diff --git a/config.c b/config.c
index 16c154742..1fe14a40c 100644
--- a/config.c
+++ b/config.c
@@ -470,7 +470,7 @@ static int process_text_line(struct ast_config *cfg, struct ast_category **cat,
/* #exec </path/to/executable>
We create a tmp file, then we #include it, then we delete it. */
if (do_exec) {
- snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%ld.%ld", time(NULL), (long)pthread_self());
+ snprintf(exec_file, sizeof(exec_file), "/var/tmp/exec.%d.%ld", (int)time(NULL), (long)pthread_self());
snprintf(cmd, sizeof(cmd), "%s > %s 2>&1", cur, exec_file);
ast_safe_system(cmd);
cur = exec_file;
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 15b15845b..b978d28a6 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -1149,7 +1149,7 @@ static int cache_lookup_internal(time_t now, struct dundi_request *req, char *ke
/* Build request string */
if (!ast_db_get("dundi/cache", key, data, sizeof(data))) {
ptr = data;
- if (sscanf(ptr, "%ld|%n", &timeout, &length) == 1) {
+ if (sscanf(ptr, "%d|%n", (int *)&timeout, &length) == 1) {
expiration = timeout - now;
if (expiration > 0) {
ast_log(LOG_DEBUG, "Found cache expiring in %d seconds!\n", (int)(timeout - now));
@@ -2032,7 +2032,7 @@ static void save_secret(const char *newkey, const char *oldkey)
snprintf(tmp, sizeof(tmp), "%s", newkey);
rotatetime = time(NULL) + DUNDI_SECRET_TIME;
ast_db_put(secretpath, "secret", tmp);
- snprintf(tmp, sizeof(tmp), "%ld", rotatetime);
+ snprintf(tmp, sizeof(tmp), "%d", (int)rotatetime);
ast_db_put(secretpath, "secretexpiry", tmp);
}
@@ -2044,7 +2044,7 @@ static void load_password(void)
time_t expired;
ast_db_get(secretpath, "secretexpiry", tmp, sizeof(tmp));
- if (sscanf(tmp, "%ld", &expired) == 1) {
+ if (sscanf(tmp, "%d", (int *)&expired) == 1) {
ast_db_get(secretpath, "secret", tmp, sizeof(tmp));
current = strchr(tmp, ';');
if (!current)
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 35366bdf0..08f6b5174 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -150,8 +150,8 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
while((p = strchr(channel_name, '/'))) {
*p = '-';
}
- snprintf(monitor->filename_base, FILENAME_MAX, "%s/%ld-%s",
- ast_config_AST_MONITOR_DIR, time(NULL),channel_name);
+ snprintf(monitor->filename_base, FILENAME_MAX, "%s/%d-%s",
+ ast_config_AST_MONITOR_DIR, (int)time(NULL),channel_name);
monitor->filename_changed = 1;
} else {
ast_log(LOG_ERROR,"Failed to allocate Memory\n");