Merged revisions 7634 via svnmerge from
authorRussell Bryant <russell@russellbryant.com>
Mon, 26 Dec 2005 18:35:28 +0000 (18:35 +0000)
committerRussell Bryant <russell@russellbryant.com>
Mon, 26 Dec 2005 18:35:28 +0000 (18:35 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7634 | russell | 2005-12-26 13:19:12 -0500 (Mon, 26 Dec 2005) | 2 lines

cast time_t to an int in printf/scanf (issue #5635)

........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7635 65c4cc65-6c06-0410-ace0-fbb531ad65f3

12 files changed:
apps/app_chanspy.c
apps/app_externalivr.c
apps/app_queue.c
apps/app_sms.c
asterisk.c
channels/chan_agent.c
channels/chan_iax2.c
channels/chan_sip.c
cli.c
config.c
pbx/pbx_dundi.c
res/res_monitor.c

index 5460e93..3a27edf 100644 (file)
@@ -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;
index ad27c16..a53a595 100644 (file)
@@ -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);
index c425c66..c1054de 100644 (file)
@@ -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;
                }
@@ -2421,11 +2421,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);
@@ -3435,13 +3435,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 */
index c6feb55..4c15cc1 100644 (file)
@@ -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)
index ce2eacf..54c9405 100644 (file)
@@ -670,8 +670,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));
        }
@@ -1318,7 +1320,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;
@@ -1346,8 +1348,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;
@@ -1403,8 +1405,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;
index 6362487..5177f11 100644 (file)
@@ -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;
        }
index 25ba89f..1251c3c 100644 (file)
@@ -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;
index a04d8e2..5ceaf1e 100644 (file)
@@ -1598,7 +1598,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));
        }
@@ -12058,7 +12058,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));
@@ -12221,7 +12221,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 a06f19f..98a50ae 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -368,7 +368,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) {
@@ -380,7 +380,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)) {
index 447db67..dda916e 100644 (file)
--- 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;
index 1e5f744..86e35a7 100644 (file)
@@ -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)
index d805788..660757b 100644 (file)
@@ -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");