aboutsummaryrefslogtreecommitdiffstats
path: root/asterisk.c
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 /asterisk.c
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
Diffstat (limited to 'asterisk.c')
-rw-r--r--asterisk.c14
1 files changed, 8 insertions, 6 deletions
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;