summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dpmcgee@gmail.com>2015-04-07 11:47:59 -0500
committerDan McGee <dpmcgee@gmail.com>2015-04-07 11:47:59 -0500
commit347ae48021e32cba1bac8459cb36f88626268883 (patch)
tree87cec169455e57db07e3d6b5cdf2f30095267552
parent4bc588efc4a92dcf0e76d87bc730699270d6f178 (diff)
downloadonkyocontrol-master.tar.gz
onkyocontrol-master.zip
Fix up a handful of integer conversion warningsHEADmaster
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
-rw-r--r--onkyo.c12
-rw-r--r--onkyo.h1
-rw-r--r--receiver.c18
-rw-r--r--util.c2
4 files changed, 19 insertions, 14 deletions
diff --git a/onkyo.c b/onkyo.c
index 8e8916b..fb88145 100644
--- a/onkyo.c
+++ b/onkyo.c
@@ -406,7 +406,7 @@ static int open_serial_device(const char *path)
/* canonical input mode- end read at a line descriptor */
newtio.c_lflag = ICANON;
/* add the Onkyo-used EOF char to allow canonical read */
- newtio.c_cc[VEOL] = END_RECV[strlen(END_RECV) - 1];
+ newtio.c_cc[VEOL] = (cc_t)END_RECV[strlen(END_RECV) - 1];
/* clean the line and activate the settings */
ret = tcflush(rcvr->fd, TCIOFLUSH);
@@ -659,7 +659,7 @@ static int process_input(struct conn *c)
const char * const end_pos = &(c->recv_buf[BUF_SIZE]);
int ret = 0;
- int count;
+ ssize_t count;
/*
* Picture time! Let's get overly verbose since we don't do this
@@ -687,6 +687,7 @@ static int process_input(struct conn *c)
while(count > 0) {
if(*c->recv_buf_pos == '\n') {
int processret = 0;
+ size_t remaining;
struct receiver *r;
/* We have a newline. This means we should have a full command
* and can attempt to interpret it. */
@@ -705,10 +706,11 @@ static int process_input(struct conn *c)
}
/* now move our remaining buffer to the start of our buffer */
c->recv_buf_pos++;
- memmove(c->recv_buf, c->recv_buf_pos, count - 1);
+ remaining = (size_t)count - 1;
+ memmove(c->recv_buf, c->recv_buf_pos, remaining);
c->recv_buf_pos = c->recv_buf;
- memset(&(c->recv_buf_pos[count - 1]), 0,
- end_pos - &(c->recv_buf_pos[count - 1]));
+ memset(&(c->recv_buf_pos[remaining]), 0,
+ end_pos - &(c->recv_buf_pos[remaining]));
if(ret == -2)
break;
}
diff --git a/onkyo.h b/onkyo.h
index f88a901..ababbbe 100644
--- a/onkyo.h
+++ b/onkyo.h
@@ -41,6 +41,7 @@ enum power {
MAIN_POWER = (1 << 0),
ZONE2_POWER = (1 << 1),
ZONE3_POWER = (1 << 2),
+ POWER_ON = -1,
};
/** Keep track of two paired file descriptors */
diff --git a/receiver.c b/receiver.c
index c7d8f02..495e1a0 100644
--- a/receiver.c
+++ b/receiver.c
@@ -127,7 +127,7 @@ int rcvr_send_command(struct receiver *rcvr)
* @param status the status string returned by the receiver
* @return the read size on success, -1 on failure
*/
-static int rcvr_handle_status(int serialfd, char **status)
+static ssize_t rcvr_handle_status(int serialfd, char **status)
{
ssize_t retval;
char buf[BUF_SIZE];
@@ -141,9 +141,10 @@ static int rcvr_handle_status(int serialfd, char **status)
buf[retval] = '\0';
/* return the status message if asked for */
if(status) {
- *status = malloc((retval + 1) * sizeof(char));
+ size_t alloc_size = (size_t)retval + 1;
+ *status = malloc(alloc_size * sizeof(char));
if(*status)
- memcpy(*status, buf, retval + 1);
+ memcpy(*status, buf, alloc_size);
}
return retval;
}
@@ -369,7 +370,7 @@ static void update_power_status(struct receiver *rcvr, int zone, int value);
* @param status the receiver status message to make human readable
* @return 0 on normal status, -1 on parse errors
*/
-static int parse_status(struct receiver *rcvr, int size, char *status)
+static int parse_status(struct receiver *rcvr, size_t size, char *status)
{
unsigned long hashval;
char buf[BUF_SIZE];
@@ -553,17 +554,18 @@ static void update_power_status(struct receiver *rcvr, int zone, int value)
*/
int process_incoming_message(struct receiver *rcvr, int logfd)
{
- int size, ret;
+ int ret;
+ ssize_t size;
char *status = NULL;
/* get the output from the receiver */
size = rcvr_handle_status(rcvr->fd, &status);
- if(size != -1) {
+ if(size >= 0) {
/* log the message if we have a logfd */
if(logfd > 0)
- xwrite(logfd, status, size + 1);
+ xwrite(logfd, status, (size_t)size + 1);
/* parse the return and output a status message */
- ret = parse_status(rcvr, size, status);
+ ret = parse_status(rcvr, (size_t)size, status);
if(!ret)
rcvr->msgs_received++;
} else {
diff --git a/util.c b/util.c
index 9a7dcdb..d92efac 100644
--- a/util.c
+++ b/util.c
@@ -82,7 +82,7 @@ unsigned long hash_sdbm(const char *str)
if(!str)
return hash;
while((c = *str++))
- hash = c + hash * 65599;
+ hash = (unsigned int)c + hash * 65599;
return hash;
}