Skip to content
Browse files

Fix unused variable warnings reported by GCC 4.6

  • Loading branch information...
1 parent 0e047a1 commit 2076574365b22a211b569a4dcc9a4df6f924f41c @jhedberg jhedberg committed May 15, 2011
Showing with 61 additions and 46 deletions.
  1. +3 −4 compat/fakehid.c
  2. +2 −3 compat/hidd.c
  3. +15 −0 cups/hcrp.c
  4. +2 −3 input/device.c
  5. +3 −2 input/server.c
  6. +1 −7 src/sdp-xml.c
  7. +2 −2 src/sdpd-request.c
  8. +8 −5 test/hciemu.c
  9. +5 −3 test/hstest.c
  10. +0 −2 test/rctest.c
  11. +0 −2 test/scotest.c
  12. +9 −6 test/test-textfile.c
  13. +11 −5 tools/hciattach.c
  14. +0 −2 tools/hcitool.c
View
7 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)
View
5 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)
View
15 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);
View
5 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)
View
5 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);
View
8 src/sdp-xml.c
@@ -47,23 +47,17 @@ 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;
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) {
View
4 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 @@ static void process_request(sdp_req_t *req)
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);
View
13 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;
}
View
8 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;
View
2 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;
View
2 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;
View
15 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)
View
16 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 */
View
2 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);

0 comments on commit 2076574

Please sign in to comment.
Something went wrong with that request. Please try again.