Skip to content

Commit

Permalink
Fix unused variable warnings reported by GCC 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Hedberg committed May 14, 2011
1 parent 0e047a1 commit 2076574
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 46 deletions.
7 changes: 3 additions & 4 deletions compat/fakehid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions compat/hidd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 15 additions & 0 deletions cups/hcrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
5 changes: 2 additions & 3 deletions input/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions input/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 1 addition & 7 deletions src/sdp-xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/sdpd-request.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down
13 changes: 8 additions & 5 deletions test/hciemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 5 additions & 3 deletions test/hstest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions test/rctest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions test/scotest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 9 additions & 6 deletions test/test-textfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 11 additions & 5 deletions tools/hciattach.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 0 additions & 2 deletions tools/hcitool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 2076574

Please sign in to comment.