aboutsummaryrefslogtreecommitdiffstats
path: root/main/asterisk.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-02 23:56:13 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-11-02 23:56:13 +0000
commitee246d0e0519c6aa7cb0aea17ea92c9a5c2dc16f (patch)
tree80dccc06626175232f48f4c2cde5b9f5ba602632 /main/asterisk.c
parent11aedae560fa003f20ee8d7a02b7aa2fc17ae13a (diff)
import gcc 4.3.2 warning fixes from trunk, with a few changes specific to this branch
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@153710 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r--main/asterisk.c53
1 files changed, 37 insertions, 16 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index 652bacf10..2e3478a5e 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1223,8 +1223,11 @@ static void hup_handler(int num)
if (restartnow)
execvp(_argv[0], _argv);
sig_flags.need_reload = 1;
- if (sig_alert_pipe[1] != -1)
- write(sig_alert_pipe[1], &a, sizeof(a));
+ if (sig_alert_pipe[1] != -1) {
+ if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {
+ fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));
+ }
+ }
signal(num, hup_handler);
}
@@ -1439,8 +1442,11 @@ static void __quit_handler(int num)
{
int a = 0;
sig_flags.need_quit = 1;
- if (sig_alert_pipe[1] != -1)
- write(sig_alert_pipe[1], &a, sizeof(a));
+ if (sig_alert_pipe[1] != -1) {
+ if (write(sig_alert_pipe[1], &a, sizeof(a)) < 0) {
+ fprintf(stderr, "hup_handler: write() failed: %s\n", strerror(errno));
+ }
+ }
/* There is no need to restore the signal handler here, since the app
* is going to exit */
}
@@ -1819,7 +1825,7 @@ static char *show_warranty(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return NULL;
}
- ast_cli(a->fd, warranty_lines);
+ ast_cli(a->fd, "%s", warranty_lines);
return CLI_SUCCESS;
}
@@ -1856,7 +1862,7 @@ static char *show_license(struct ast_cli_entry *e, int cmd, struct ast_cli_args
return NULL;
}
- ast_cli(a->fd, license_lines);
+ ast_cli(a->fd, "%s", license_lines);
return CLI_SUCCESS;
}
@@ -1976,9 +1982,12 @@ static int ast_el_read_char(EditLine *editline, char *cp)
}
/* Write over the CLI prompt */
- if (!ast_opt_exec && !lastpos)
- write(STDOUT_FILENO, "\r", 1);
- write(STDOUT_FILENO, buf, res);
+ if (!ast_opt_exec && !lastpos) {
+ if (write(STDOUT_FILENO, "\r", 1) < 0) {
+ }
+ }
+ if (write(STDOUT_FILENO, buf, res) < 0) {
+ }
if ((res < EL_BUF_SIZE - 1) && ((buf[res-1] == '\n') || (buf[res-2] == '\n'))) {
*cp = CC_REFRESH;
return(1);
@@ -2405,7 +2414,9 @@ static int ast_el_read_history(char *filename)
return ret;
while (!feof(f)) {
- fgets(buf, sizeof(buf), f);
+ if (!fgets(buf, sizeof(buf), f)) {
+ continue;
+ }
if (!strcmp(buf, "_HiStOrY_V2_\n"))
continue;
if (ast_all_zeros(buf))
@@ -2418,7 +2429,7 @@ static int ast_el_read_history(char *filename)
return ret;
}
-static void ast_remotecontrol(char * data)
+static void ast_remotecontrol(char *data)
{
char buf[80];
int res;
@@ -2432,12 +2443,17 @@ static void ast_remotecontrol(char * data)
char *ebuf;
int num = 0;
- read(ast_consock, buf, sizeof(buf));
+ if (read(ast_consock, buf, sizeof(buf)) < 0) {
+ ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno));
+ return;
+ }
if (data) {
char prefix[] = "cli quit after ";
char *tmp = alloca(strlen(data) + strlen(prefix) + 1);
sprintf(tmp, "%s%s", prefix, data);
- write(ast_consock, tmp, strlen(tmp) + 1);
+ if (write(ast_consock, tmp, strlen(tmp) + 1) < 0) {
+ ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno));
+ }
}
stringp = buf;
hostname = strsep(&stringp, "/");
@@ -2497,7 +2513,9 @@ static void ast_remotecontrol(char * data)
/* Skip verbose lines */
if (*curline != 127) {
not_written = 0;
- write(STDOUT_FILENO, curline, nextline - curline);
+ if (write(STDOUT_FILENO, curline, nextline - curline) < 0) {
+ ast_log(LOG_WARNING, "write() failed: %s\n", strerror(errno));
+ }
}
curline = nextline;
} while (!ast_strlen_zero(curline));
@@ -2822,7 +2840,8 @@ static void *monitor_sig_flags(void *unused)
sig_flags.need_quit = 0;
quit_handler(0, 0, 1, 0);
}
- read(sig_alert_pipe[0], &a, sizeof(a));
+ if (read(sig_alert_pipe[0], &a, sizeof(a)) != sizeof(a)) {
+ }
}
return NULL;
@@ -3251,7 +3270,9 @@ int main(int argc, char *argv[])
#if HAVE_WORKING_FORK
if (ast_opt_always_fork || !ast_opt_no_fork) {
#ifndef HAVE_SBIN_LAUNCHD
- daemon(1, 0);
+ if (daemon(1, 0) < 0) {
+ ast_log(LOG_ERROR, "daemon() failed: %s\n", strerror(errno));
+ }
ast_mainpid = getpid();
/* Blindly re-write pid file since we are forking */
unlink(ast_config_AST_PID);