Permalink
Browse files

Fixed compilation warnings with recent compilers

  • Loading branch information...
1 parent b52ae21 commit b9bed33bfc3bc0a1eed1cb350f3600f9541b22cd @vihai committed Nov 11, 2008
Showing with 49 additions and 40 deletions.
  1. +3 −1 app_pipe/app_pipe.c
  2. +3 −1 chan_vgsm/comm.c
  3. +27 −32 chan_vgsm/me.c
  4. +4 −2 chan_visdn/chan_visdn.c
  5. +6 −2 chan_visdn/intf.c
  6. +3 −1 libkstreamer/conn.c
  7. +3 −1 vgsmctl/fw_upgrade.c
View
@@ -208,7 +208,9 @@ static int handler_exec(struct ast_channel *chan, void *data)
break;
}
- write(wfd, f->data, f->datalen);
+ int res = write(wfd, f->data, f->datalen);
+ if (res < 0)
+ ;
char buf[1024];
int nread = read(efd, buf, sizeof(buf));
View
@@ -1239,7 +1239,9 @@ static int vgsm_comm_receive_message(
memcpy(msg, &msgh, sizeof(*msg));
- read(comm->cmd_pipe_read, &msg->data, msg->len);
+ int res = read(comm->cmd_pipe_read, &msg->data, msg->len);
+ if (res < 0)
+ ;
} else
msg = &msgh;
View
@@ -1267,14 +1267,13 @@ struct vgsm_me *vgsm_me_get_by_name(const char *name)
return me;
}
-void vgsm_me_set_status(
+void vgsm_me_set_status_va(
struct vgsm_me *me,
enum vgsm_me_status status,
longtime_t timeout,
- const char *fmt, ...)
+ const char *fmt,
+ va_list ap)
{
- va_list ap;
-
ast_mutex_lock(&me->lock);
if (me->status_reason) {
@@ -1283,9 +1282,9 @@ void vgsm_me_set_status(
}
if (fmt) {
- va_start(ap, fmt);
- vasprintf(&me->status_reason, fmt, ap);
- va_end(ap);
+ int res = vasprintf(&me->status_reason, fmt, ap);
+ if (res < 0)
+ me->status_reason = NULL;
}
if (timeout >= 0)
@@ -1330,20 +1329,29 @@ void vgsm_me_set_status(
ast_mutex_unlock(&me->lock);
}
+void vgsm_me_set_status(
+ struct vgsm_me *me,
+ enum vgsm_me_status status,
+ longtime_t timeout,
+ const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vgsm_me_set_status_va(me, status, timeout, fmt, ap);
+ va_end(ap);
+}
+
void vgsm_me_failed_text(struct vgsm_me *me,
const char *fmt,
...)
{
va_list ap;
- char tmpstr[512];
va_start(ap, fmt);
- vsnprintf(tmpstr, sizeof(tmpstr), fmt, ap);
- va_end(ap);
-
- vgsm_me_set_status(me,
+ vgsm_me_set_status_va(me,
VGSM_ME_STATUS_FAILED, FAILED_RETRY_TIME,
- tmpstr);
+ fmt, ap);
+ va_end(ap);
}
void vgsm_me_failed(struct vgsm_me *me, int err)
@@ -3952,16 +3960,12 @@ static int vgsm_me_open(
me->me_fd = open(mc->device_filename, O_RDWR | O_NOCTTY | O_NDELAY);
if (me->me_fd < 0) {
- char tmpstr[64];
- snprintf(tmpstr, sizeof(tmpstr),
+ vgsm_me_set_status(me,
+ VGSM_ME_STATUS_CLOSED, FAILED_RETRY_TIME,
"Error opening device: open(%s): %s",
mc->device_filename,
strerror(errno));
- vgsm_me_set_status(me,
- VGSM_ME_STATUS_CLOSED, FAILED_RETRY_TIME,
- tmpstr);
-
err = -errno;
goto err_me_open;
}
@@ -3985,14 +3989,9 @@ static int vgsm_me_open(
}
if (tcflush(me->me_fd, TCIOFLUSH) < 0) {
- char tmpstr[64];
- snprintf(tmpstr, sizeof(tmpstr),
- "Error flushing device: %s",
- strerror(errno));
-
vgsm_me_set_status(me,
VGSM_ME_STATUS_CLOSED, FAILED_RETRY_TIME,
- tmpstr);
+ "Error flushing device: %s", strerror(errno));
err = -errno;
goto err_me_flush;
@@ -4049,16 +4048,12 @@ static int vgsm_me_open(
newtio.c_cc[VEOL2] = 0;
if (tcsetattr(me->me_fd, TCSANOW, &newtio) < 0) {
- char tmpstr[64];
- snprintf(tmpstr, sizeof(tmpstr),
+ vgsm_me_set_status(me,
+ VGSM_ME_STATUS_CLOSED, FAILED_RETRY_TIME,
"Error setting tty's attributes: tcsetattr(%s): %s",
mc->device_filename,
strerror(errno));
- vgsm_me_set_status(me,
- VGSM_ME_STATUS_CLOSED, FAILED_RETRY_TIME,
- tmpstr);
-
err = -errno;
goto err_tcsetattr;
}
@@ -7136,7 +7131,7 @@ static int vgsm_me_cli_rawcommand_func(int fd, int argc, char *argv[])
}
struct vgsm_req *req;
- req = vgsm_req_make_wait(&me->comm, 5 * SEC, command);
+ req = vgsm_req_make_wait(&me->comm, 5 * SEC, "%s", command);
if (vgsm_req_status(req) != VGSM_RESP_OK) {
ast_cli(fd, "Error: %s (%d)\n",
vgsm_me_error_to_text(vgsm_req_status(req)),
View
@@ -2650,7 +2650,8 @@ static void visdn_ccb_q931_receive(void)
struct q931_ccb_message, node);
char buf[1];
- read(visdn.ccb_q931_queue_pipe_read, buf, 1);
+ int res = read(visdn.ccb_q931_queue_pipe_read, buf, 1);
+ if (res < 0);
list_del_init(&msg->node);
ast_mutex_unlock(&visdn.ccb_q931_queue_lock);
@@ -4795,7 +4796,8 @@ static void visdn_q931_ccb_receive(void)
struct q931_ccb_message, node);
char buf[1];
- read(visdn.q931_ccb_queue_pipe_read, buf, 1);
+ int res = read(visdn.q931_ccb_queue_pipe_read, buf, 1);
+ if (res < 0);
list_del_init(&msg->node);
ast_mutex_unlock(&visdn.q931_ccb_queue_lock);
View
@@ -471,8 +471,11 @@ static void visdn_intf_set_status(
free(intf->status_reason);
va_start(ap, fmt);
- vasprintf(&intf->status_reason, fmt, ap);
+ int res = vasprintf(&intf->status_reason, fmt, ap);
va_end(ap);
+
+ if (res < 0)
+ intf->status_reason = NULL;
}
if (visdn.q931_thread != AST_PTHREADT_NULL)
@@ -599,7 +602,8 @@ int visdn_intf_initialize(struct visdn_intf *intf)
"/sys/class/net/%s/visdn_connected_port/",
intf->name);
- if (realpath(path, intf->remote_port) < 0) {
+ char *res = realpath(path, intf->remote_port);
+ if (!res) {
visdn_intf_set_status(intf,
VISDN_INTF_STATUS_FAILED,
FAILED_RETRY_TIME,
View
@@ -926,7 +926,9 @@ static int ks_conn_receive_message(struct ks_conn *conn)
memcpy(msg, &msgh, sizeof(*msg));
- read(conn->cmd_read, &msg->data, msg->len);
+ int res = read(conn->cmd_read, &msg->data, msg->len);
+ if (res < 0)
+ ;
} else
msg = &msgh;
View
@@ -294,7 +294,9 @@ static int do_fw_upgrade(
while(TRUE) {
printf("Are you sure? (Y/n): ");
char answer[8];
- fgets(answer, sizeof(answer), stdin);
+ char *res = fgets(answer, sizeof(answer), stdin);
+ if (!res)
+ return 1;
if (answer[0] != 'Y' && answer[0] != 'y')
return 1;

0 comments on commit b9bed33

Please sign in to comment.