diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2011-05-15 01:57:12 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2011-05-15 01:57:12 +0300 |
commit | 2076574365b22a211b569a4dcc9a4df6f924f41c (patch) | |
tree | 8da7f776fcfd18ab7fea33b1eefccbfa36c132d6 | |
parent | 0e047a188b6c287ee9716fa0186c7e5ecc74e759 (diff) |
Fix unused variable warnings reported by GCC 4.6
-rw-r--r-- | compat/fakehid.c | 7 | ||||
-rw-r--r-- | compat/hidd.c | 5 | ||||
-rw-r--r-- | cups/hcrp.c | 15 | ||||
-rw-r--r-- | input/device.c | 5 | ||||
-rw-r--r-- | input/server.c | 5 | ||||
-rw-r--r-- | src/sdp-xml.c | 8 | ||||
-rw-r--r-- | src/sdpd-request.c | 4 | ||||
-rw-r--r-- | test/hciemu.c | 13 | ||||
-rw-r--r-- | test/hstest.c | 8 | ||||
-rw-r--r-- | test/rctest.c | 2 | ||||
-rw-r--r-- | test/scotest.c | 2 | ||||
-rw-r--r-- | test/test-textfile.c | 15 | ||||
-rw-r--r-- | tools/hciattach.c | 16 | ||||
-rw-r--r-- | tools/hcitool.c | 2 |
14 files changed, 61 insertions, 46 deletions
diff --git a/compat/fakehid.c b/compat/fakehid.c index f0d88931c..66161b3f7 100644 --- a/compat/fakehid.c +++ b/compat/fakehid.c @@ -60,20 +60,19 @@ static void sig_term(int sig) __io_canceled = 1; } -static void send_event(int fd, uint16_t type, uint16_t code, int32_t value) +static int send_event(int fd, uint16_t type, uint16_t code, int32_t value) { struct uinput_event event; - int len; if (fd <= fileno(stderr)) - return; + return -EINVAL; memset(&event, 0, sizeof(event)); event.type = type; event.code = code; event.value = value; - len = write(fd, &event, sizeof(event)); + return write(fd, &event, sizeof(event)); } static int uinput_create(char *name, int keyboard, int mouse) diff --git a/compat/hidd.c b/compat/hidd.c index 2dae3a767..64dd455e6 100644 --- a/compat/hidd.c +++ b/compat/hidd.c @@ -237,14 +237,13 @@ static int request_encryption(bdaddr_t *src, bdaddr_t *dst) return err; } -static void enable_sixaxis(int csk) +static int enable_sixaxis(int csk) { const unsigned char buf[] = { 0x53 /*HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE*/, 0xf4, 0x42, 0x03, 0x00, 0x00 }; - int err; - err = write(csk, buf, sizeof(buf)); + return write(csk, buf, sizeof(buf)); } static int create_device(int ctl, int csk, int isk, uint8_t subclass, int nosdp, int nocheck, int bootonly, int encrypt, int timeout) diff --git a/cups/hcrp.c b/cups/hcrp.c index 7aafcdcd6..a93dda07e 100644 --- a/cups/hcrp.c +++ b/cups/hcrp.c @@ -94,8 +94,13 @@ static int hcrp_credit_grant(int sk, uint16_t tid, uint32_t credit) memcpy(buf, &hdr, HCRP_PDU_HDR_SIZE); memcpy(buf + HCRP_PDU_HDR_SIZE, &cp, HCRP_CREDIT_GRANT_CP_SIZE); len = write(sk, buf, HCRP_PDU_HDR_SIZE + HCRP_CREDIT_GRANT_CP_SIZE); + if (len < 0) + return len; len = read(sk, buf, sizeof(buf)); + if (len < 0) + return len; + memcpy(&hdr, buf, HCRP_PDU_HDR_SIZE); memcpy(&rp, buf + HCRP_PDU_HDR_SIZE, HCRP_CREDIT_GRANT_RP_SIZE); @@ -119,8 +124,13 @@ static int hcrp_credit_request(int sk, uint16_t tid, uint32_t *credit) hdr.plen = htons(0); memcpy(buf, &hdr, HCRP_PDU_HDR_SIZE); len = write(sk, buf, HCRP_PDU_HDR_SIZE); + if (len < 0) + return len; len = read(sk, buf, sizeof(buf)); + if (len < 0) + return len; + memcpy(&hdr, buf, HCRP_PDU_HDR_SIZE); memcpy(&rp, buf + HCRP_PDU_HDR_SIZE, HCRP_CREDIT_REQUEST_RP_SIZE); @@ -147,8 +157,13 @@ static int hcrp_get_lpt_status(int sk, uint16_t tid, uint8_t *lpt_status) hdr.plen = htons(0); memcpy(buf, &hdr, HCRP_PDU_HDR_SIZE); len = write(sk, buf, HCRP_PDU_HDR_SIZE); + if (len < 0) + return len; len = read(sk, buf, sizeof(buf)); + if (len < 0) + return len; + memcpy(&hdr, buf, HCRP_PDU_HDR_SIZE); memcpy(&rp, buf + HCRP_PDU_HDR_SIZE, HCRP_GET_LPT_STATUS_RP_SIZE); diff --git a/input/device.c b/input/device.c index 1d9a31367..aa593e069 100644 --- a/input/device.c +++ b/input/device.c @@ -243,17 +243,16 @@ static int decode_key(const char *str) return key; } -static void send_event(int fd, uint16_t type, uint16_t code, int32_t value) +static int send_event(int fd, uint16_t type, uint16_t code, int32_t value) { struct uinput_event event; - int err; memset(&event, 0, sizeof(event)); event.type = type; event.code = code; event.value = value; - err = write(fd, &event, sizeof(event)); + return write(fd, &event, sizeof(event)); } static void send_key(int fd, uint16_t key) diff --git a/input/server.c b/input/server.c index d98018b59..7fd00f237 100644 --- a/input/server.c +++ b/input/server.c @@ -91,8 +91,9 @@ static void connect_event_cb(GIOChannel *chan, GError *err, gpointer data) /* Send unplug virtual cable to unknown devices */ if (ret == -ENOENT && psm == L2CAP_PSM_HIDP_CTRL) { unsigned char unplug = 0x15; - int err, sk = g_io_channel_unix_get_fd(chan); - err = write(sk, &unplug, sizeof(unplug)); + int sk = g_io_channel_unix_get_fd(chan); + if (write(sk, &unplug, sizeof(unplug)) < 0) + error("Unable to send virtual cable unplug"); } g_io_channel_shutdown(chan, TRUE, NULL); diff --git a/src/sdp-xml.c b/src/sdp-xml.c index f82137634..d7b2aefda 100644 --- a/src/sdp-xml.c +++ b/src/sdp-xml.c @@ -47,7 +47,6 @@ static void convert_raw_data_to_xml(sdp_data_t *value, int indent_level, int i, hex; char buf[STRBUFSIZE]; char indent[MAXINDENT]; - char next_indent[MAXINDENT]; if (!value) return; @@ -55,15 +54,10 @@ static void convert_raw_data_to_xml(sdp_data_t *value, int indent_level, if (indent_level >= MAXINDENT) indent_level = MAXINDENT - 2; - for (i = 0; i < indent_level; i++) { + for (i = 0; i < indent_level; i++) indent[i] = '\t'; - next_indent[i] = '\t'; - } indent[i] = '\0'; - next_indent[i] = '\t'; - next_indent[i + 1] = '\0'; - buf[STRBUFSIZE - 1] = '\0'; switch (value->dtd) { diff --git a/src/sdpd-request.c b/src/sdpd-request.c index ddec935c5..9920e9b90 100644 --- a/src/sdpd-request.c +++ b/src/sdpd-request.c @@ -961,7 +961,6 @@ static void process_request(sdp_req_t *req) sdp_pdu_hdr_t *rsphdr; sdp_buf_t rsp; uint8_t *buf = malloc(USHRT_MAX); - int sent = 0; int status = SDP_INVALID_SYNTAX; memset(buf, 0, USHRT_MAX); @@ -1035,7 +1034,8 @@ send_rsp: rsp.data = buf; /* stream the rsp PDU */ - sent = send(req->sock, rsp.data, rsp.data_size, 0); + if (send(req->sock, rsp.data, rsp.data_size, 0) < 0) + error("send: %s (%d)", strerror(errno), errno); SDPDBG("Bytes Sent : %d", sent); diff --git a/test/hciemu.c b/test/hciemu.c index 66f99a929..07bf3bec2 100644 --- a/test/hciemu.c +++ b/test/hciemu.c @@ -203,7 +203,6 @@ static int write_snoop(int fd, int type, int incoming, unsigned char *buf, int l struct timeval tv; uint32_t size = len; uint64_t ts; - int err; if (fd < 0) return -1; @@ -221,8 +220,11 @@ static int write_snoop(int fd, int type, int incoming, unsigned char *buf, int l if (type == HCI_COMMAND_PKT || type == HCI_EVENT_PKT) pkt.flags |= ntohl(0x02); - err = write(fd, &pkt, BTSNOOP_PKT_SIZE); - err = write(fd, buf, size); + if (write(fd, &pkt, BTSNOOP_PKT_SIZE) < 0) + return -errno; + + if (write(fd, buf, size) < 0) + return -errno; return 0; } @@ -861,7 +863,7 @@ static gboolean io_acl_data(GIOChannel *chan, GIOCondition cond, gpointer data) unsigned char buf[HCI_MAX_FRAME_SIZE], *ptr; hci_acl_hdr *ah; uint16_t flags; - int fd, err, len; + int fd, len; if (cond & G_IO_NVAL) { g_io_channel_unref(chan); @@ -898,7 +900,8 @@ static gboolean io_acl_data(GIOChannel *chan, GIOCondition cond, gpointer data) write_snoop(vdev.dd, HCI_ACLDATA_PKT, 1, buf, len); - err = write(vdev.fd, buf, len); + if (write(vdev.fd, buf, len) < 0) + return FALSE; return TRUE; } diff --git a/test/hstest.c b/test/hstest.c index 08f2257df..ac68059ab 100644 --- a/test/hstest.c +++ b/test/hstest.c @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) char *filename; mode_t filemode; - int err, mode = 0; + int mode = 0; int dd, rd, sd, fd; uint16_t sco_handle, sco_mtu, vs; @@ -244,8 +244,10 @@ int main(int argc, char *argv[]) fprintf(stderr, "SCO audio channel connected (handle %d, mtu %d)\n", sco_handle, sco_mtu); - if (mode == RECORD) - err = write(rd, "RING\r\n", 6); + if (mode == RECORD) { + if (write(rd, "RING\r\n", 6) < 0) + return -errno; + } maxfd = (rd > sd) ? rd : sd; diff --git a/test/rctest.c b/test/rctest.c index b3804f50d..9754f5216 100644 --- a/test/rctest.c +++ b/test/rctest.c @@ -417,13 +417,11 @@ static void recv_mode(int sk) struct timeval tv_beg, tv_end, tv_diff; char ts[30]; long total; - uint32_t seq; syslog(LOG_INFO, "Receiving ..."); memset(ts, 0, sizeof(ts)); - seq = 0; while (1) { gettimeofday(&tv_beg,NULL); total = 0; diff --git a/test/scotest.c b/test/scotest.c index 50b622aec..17bd8a6e7 100644 --- a/test/scotest.c +++ b/test/scotest.c @@ -216,11 +216,9 @@ static void recv_mode(int sk) { struct timeval tv_beg,tv_end,tv_diff; long total; - uint32_t seq; syslog(LOG_INFO, "Receiving ..."); - seq = 0; while (1) { gettimeofday(&tv_beg, NULL); total = 0; diff --git a/test/test-textfile.c b/test/test-textfile.c index 970e9e77b..e0a0c5b39 100644 --- a/test/test-textfile.c +++ b/test/test-textfile.c @@ -44,25 +44,28 @@ int main(int argc, char *argv[]) char filename[] = "/tmp/textfile"; char key[18], value[512], *str; unsigned int i, j, size, max = 10; - int fd, err; + int fd; size = getpagesize(); printf("System uses a page size of %d bytes\n\n", size); fd = creat(filename, 0644); - err = ftruncate(fd, 0); + if (ftruncate(fd, 0) < 0) + return -errno; memset(value, 0, sizeof(value)); - for (i = 0; i < (size / sizeof(value)); i++) - err = write(fd, value, sizeof(value)); + for (i = 0; i < (size / sizeof(value)); i++) { + if (write(fd, value, sizeof(value)) < 0) + return -errno; + } close(fd); sprintf(key, "11:11:11:11:11:11"); str = textfile_get(filename, key); - err = truncate(filename, 0); - + if (truncate(filename, 0) < 0) + return -errno; sprintf(key, "00:00:00:00:00:00"); if (textfile_del(filename, key) < 0) diff --git a/tools/hciattach.c b/tools/hciattach.c index e4d5aa184..93bdaace1 100644 --- a/tools/hciattach.c +++ b/tools/hciattach.c @@ -351,12 +351,12 @@ static int bcsp_max_retries = 10; static void bcsp_tshy_sig_alarm(int sig) { unsigned char bcsp_sync_pkt[10] = {0xc0,0x00,0x41,0x00,0xbe,0xda,0xdc,0xed,0xed,0xc0}; - int len; static int retries = 0; if (retries < bcsp_max_retries) { retries++; - len = write(serial_fd, &bcsp_sync_pkt, 10); + if (write(serial_fd, &bcsp_sync_pkt, 10) < 0) + return; alarm(1); return; } @@ -369,12 +369,12 @@ static void bcsp_tshy_sig_alarm(int sig) static void bcsp_tconf_sig_alarm(int sig) { unsigned char bcsp_conf_pkt[10] = {0xc0,0x00,0x41,0x00,0xbe,0xad,0xef,0xac,0xed,0xc0}; - int len; static int retries = 0; if (retries < bcsp_max_retries){ retries++; - len = write(serial_fd, &bcsp_conf_pkt, 10); + if (write(serial_fd, &bcsp_conf_pkt, 10) < 0) + return; alarm(1); return; } @@ -451,7 +451,8 @@ static int bcsp(int fd, struct uart_t *u, struct termios *ti) } if (!memcmp(bcspp, bcspsync, 4)) { - len = write(fd, &bcsp_sync_resp_pkt,10); + if (write(fd, &bcsp_sync_resp_pkt,10) < 0) + return -1; } else if (!memcmp(bcspp, bcspsyncresp, 4)) break; } @@ -500,6 +501,11 @@ static int bcsp(int fd, struct uart_t *u, struct termios *ti) len = write(fd, &bcsp_conf_resp_pkt, 10); else if (!memcmp(bcspp, bcspconfresp, 4)) break; + else + continue; + + if (len < 0) + return -errno; } /* State = garrulous */ diff --git a/tools/hcitool.c b/tools/hcitool.c index a1174497a..ece187cfa 100644 --- a/tools/hcitool.c +++ b/tools/hcitool.c @@ -2351,7 +2351,6 @@ static int print_advertising_devices(int dd, uint8_t filter_type) unsigned char buf[HCI_MAX_EVENT_SIZE], *ptr; struct hci_filter nf, of; socklen_t olen; - hci_event_hdr *hdr; int num, len; olen = sizeof(of); @@ -2382,7 +2381,6 @@ static int print_advertising_devices(int dd, uint8_t filter_type) goto done; } - hdr = (void *) (buf + 1); ptr = buf + (1 + HCI_EVENT_HDR_SIZE); len -= (1 + HCI_EVENT_HDR_SIZE); |