From ac9d70ac1281183d741ef1ecd8101a5eb5ee93fb Mon Sep 17 00:00:00 2001 From: russell Date: Mon, 26 Dec 2005 18:35:28 +0000 Subject: Merged revisions 7634 via svnmerge from 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: http://svn.digium.com/svn/asterisk/trunk@7635 f38db490-d61c-443f-a65b-d21fe96a405b --- asterisk.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'asterisk.c') diff --git a/asterisk.c b/asterisk.c index ce2eacfae..54c9405fb 100644 --- a/asterisk.c +++ b/asterisk.c @@ -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; -- cgit v1.2.3