diff options
author | Dan McGee <dpmcgee@gmail.com> | 2011-11-20 22:38:26 -0600 |
---|---|---|
committer | Dan McGee <dpmcgee@gmail.com> | 2011-11-20 22:38:26 -0600 |
commit | f631768da6c242f58e92e0464f95489d00de11f8 (patch) | |
tree | 75600f9d72fca85264e9d0d6fceb31f31235d724 | |
parent | dbe3ef3e635662e9df45b799773ce61468baea64 (diff) | |
download | onkyocontrol-f631768da6c242f58e92e0464f95489d00de11f8.tar.gz onkyocontrol-f631768da6c242f58e92e0464f95489d00de11f8.zip |
Remove parenthesis around return values
Signed-off-by: Dan McGee <dpmcgee@gmail.com>
-rw-r--r-- | command.c | 68 | ||||
-rw-r--r-- | onkyo.c | 30 | ||||
-rw-r--r-- | receiver.c | 8 | ||||
-rw-r--r-- | util.c | 18 |
4 files changed, 62 insertions, 62 deletions
@@ -78,7 +78,7 @@ static int cmd_attempt(struct receiver *rcvr, struct cmdqueue *q; if(!cmd || !arg) - return(-1); + return -1; fullcmd = malloc(strlen(cmd->prefix) + strlen(arg) + 1); sprintf(fullcmd, "%s%s", cmd->prefix, arg); @@ -99,7 +99,7 @@ static int cmd_attempt(struct receiver *rcvr, /* command already in our queue, skip second copy */ free(q); free(fullcmd); - return(0); + return 0; } if(!ptr->next) break; @@ -107,7 +107,7 @@ static int cmd_attempt(struct receiver *rcvr, } ptr->next = q; } - return(0); + return 0; } static int cmd_attempt_raw(struct receiver *rcvr, @@ -135,7 +135,7 @@ static int handle_standard(struct receiver *rcvr, return cmd_attempt(rcvr, cmd, "UP"); else if(strcmp(arg, "down") == 0) return cmd_attempt(rcvr, cmd, "DOWN"); - return(-2); + return -2; } static int handle_boolean(struct receiver *rcvr, @@ -156,7 +156,7 @@ static int handle_boolean(struct receiver *rcvr, } /* unrecognized command */ - return(-1); + return -1; } static int handle_ranged(struct receiver *rcvr, @@ -170,17 +170,17 @@ static int handle_ranged(struct receiver *rcvr, ret = handle_standard(rcvr, cmd, arg); if(ret != -2) - return (ret); + return ret; /* otherwise we probably have a number */ level = strtol(arg, &test, 10); if(*test != '\0') { /* parse error, not a number */ - return(-1); + return -1; } if(level < lower || level > upper) { /* range error */ - return(-1); + return -1; } level += offset; /* create our command */ @@ -224,17 +224,17 @@ static int handle_swlevel(struct receiver *rcvr, ret = handle_standard(rcvr, cmd, arg); if(ret != -2) - return (ret); + return ret; /* otherwise we probably have a number */ level = strtol(arg, &test, 10); if(*test != '\0') { /* parse error, not a number */ - return(-1); + return -1; } if(level < -15 || level > 12) { /* range error */ - return(-1); + return -1; } /* create our command */ if(level == 0) { @@ -287,7 +287,7 @@ static int handle_input(struct receiver *rcvr, ret = handle_standard(rcvr, cmd, arg); if(ret != -2) - return (ret); + return ret; /* allow lower or upper names */ strtoupper(arg); @@ -310,7 +310,7 @@ static int handle_input(struct receiver *rcvr, ret = cmd_attempt(rcvr, cmd, "80"); } - return(ret); + return ret; } static struct code_map modes[] = { @@ -355,7 +355,7 @@ static int handle_mode(struct receiver *rcvr, ret = handle_standard(rcvr, cmd, arg); if(ret != -2) - return (ret); + return ret; /* allow lower or upper names */ strtoupper(arg); @@ -369,7 +369,7 @@ static int handle_mode(struct receiver *rcvr, } } - return(ret); + return ret; } static int handle_tune(struct receiver *rcvr, @@ -381,7 +381,7 @@ static int handle_tune(struct receiver *rcvr, ret = handle_standard(rcvr, cmd, arg); if(ret != -2) - return (ret); + return ret; /* Otherwise we should have a frequency. It can be one of two formats: * FM: (1)00.0 (possible hundreds spot, with decimal point) @@ -396,14 +396,14 @@ static int handle_tune(struct receiver *rcvr, frac_freq = strtol(test + 1, &test, 10); if(errno != 0) { /* parse error, not a number */ - return(-1); + return -1; } /* allowed range: 87.5 to 107.9 inclusive */ if(frac_freq < 0 || frac_freq > 9 || (freq <= 87 && frac_freq < 5) || freq >= 108) { /* range error */ - return(-1); + return -1; } /* we want to print something like "TUN09790" */ freq = freq * 100 + frac_freq * 10; @@ -415,11 +415,11 @@ static int handle_tune(struct receiver *rcvr, freq = strtol(arg, &test, 10); if(errno != 0) { /* parse error, not a number */ - return(-1); + return -1; } if(freq < 530 || freq > 1710) { /* range error */ - return(-1); + return -1; } /* we want to print something like "TUN00780" */ sprintf(cmdstr, "%05ld", freq); @@ -443,11 +443,11 @@ static int handle_sleep(struct receiver *rcvr, mins = strtol(arg, &test, 10); if(*test != '\0') { /* parse error, not a number */ - return(-1); + return -1; } if(mins < 0 || mins > 90) { /* range error */ - return(-1); + return -1; } /* create our command */ sprintf(cmdstr, "%02lX", (unsigned long)mins); @@ -486,7 +486,7 @@ static int handle_fakesleep(struct receiver *rcvr, zone = cmd->prefix[0]; if(zone != '2' && zone != '3') - return(-1); + return -1; if(!arg || strcmp(arg, "status") == 0) { /* do nothing with the arg, we'll end up writing a message */ @@ -502,11 +502,11 @@ static int handle_fakesleep(struct receiver *rcvr, long mins = strtol(arg, &test, 10); if(*test != '\0') { /* parse error, not a number */ - return(-1); + return -1; } if(mins < 0) { /* range error */ - return(-1); + return -1; } if(zone == '2') { rcvr->zone2_sleep = now; @@ -525,12 +525,12 @@ static int handle_memory(struct receiver *rcvr, const struct command *cmd, char *arg) { if(!arg) - return(-1); + return -1; if(strcmp(arg, "lock") == 0) return cmd_attempt(rcvr, cmd, "LOCK"); else if(strcmp(arg, "unlock") == 0) return cmd_attempt(rcvr, cmd, "UNLK"); - return(-1); + return -1; } @@ -561,10 +561,10 @@ static int handle_status(struct receiver *rcvr, ret += cmd_attempt_raw(rcvr, "SL3", "QSTN"); ret += cmd_attempt_raw(rcvr, "TU3", "QSTN"); } else { - return(-1); + return -1; } - return(ret < 0 ? -2 : 0); + return ret < 0 ? -2 : 0; } static int handle_raw(struct receiver *rcvr, @@ -672,7 +672,7 @@ int process_command(struct receiver *rcvr, const char *str) struct command *cmd; if(!str) - return(-1); + return -1; cmdstr = strdup(str); /* start by killing trailing whitespace of any sort */ @@ -693,13 +693,13 @@ int process_command(struct receiver *rcvr, const char *str) /* we found the handler, call it and return the result */ int ret = cmd->handler(rcvr, cmd, argstr); free(cmdstr); - return(ret); + return ret; } } /* we didn't find a handler, must be an invalid command */ free(cmdstr); - return(-1); + return -1; } @@ -712,8 +712,8 @@ int process_command(struct receiver *rcvr, const char *str) int is_power_command(const char *cmd) { if(strstr(cmd, "PWR") != NULL || strstr(cmd, "ZPW") != NULL || strstr(cmd, "PW3") != NULL) - return(1); - return(0); + return 1; + return 0; } /* vim: set ts=4 sw=4 noet: */ @@ -95,7 +95,7 @@ static int open_connection(int fd) /* attempt an initial status message write */ if(xwrite(fd, startup_msg, strlen(startup_msg)) == -1) { xclose(fd); - return(-2); + return -2; } /* add it to our linked list, ensuring we don't have too many already */ @@ -110,7 +110,7 @@ static int open_connection(int fd) fprintf(stderr, "max connections (%d) reached!\n", MAX_CONNECTIONS); xwrite(fd, max_conns, strlen(max_conns)); xclose(fd); - return(-1); + return -1; } if(!ptr) { @@ -131,7 +131,7 @@ static int open_connection(int fd) connections = ptr; } - return(0); + return 0; } /** @@ -433,12 +433,12 @@ static int open_serial_device(const char *path) ptr->next = rcvr; } - return(rcvr->fd); + return rcvr->fd; cleanup: perror(path); free(rcvr); - return(-1); + return -1; } /** @@ -474,7 +474,7 @@ static int listen_and_add(int fd) listeners = ptr; } } - return(fd); + return fd; } /** @@ -511,7 +511,7 @@ static int open_net_listener(const char * restrict host, ret = getaddrinfo(host, service, &hints, &result); if(ret != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(ret)); - return(-1); + return -1; } /* we get a list of results back, try to bind to each until one works */ @@ -543,7 +543,7 @@ static int open_net_listener(const char * restrict host, /* make sure we free the result of our addr query */ freeaddrinfo(result); - return(listen_and_add(fd)); + return listen_and_add(fd); } /** @@ -559,14 +559,14 @@ static int open_socket_listener(const char *path) if(strlen(path) > sizeof(addr.sun_path) - 1) { fprintf(stderr, "socket path too long\n"); - return(-1); + return -1; } /* attempt to open the socket */ fd = socket(AF_UNIX, SOCK_STREAM, 0); if(fd == -1) { perror("socket()"); - return(-1); + return -1; } /* attempt to bind to the socket */ @@ -575,10 +575,10 @@ static int open_socket_listener(const char *path) strncpy(addr.sun_path, path, sizeof(addr.sun_path) - 1); if(bind(fd, (struct sockaddr*)&addr, sizeof(struct sockaddr_un)) != 0) { perror("bind()"); - return(-1); + return -1; } - return(listen_and_add(fd)); + return listen_and_add(fd); } /** @@ -606,12 +606,12 @@ static int can_send_command(struct timeval * restrict last, if(diff.tv_sec > wait.tv_sec || (diff.tv_sec == wait.tv_sec && diff.tv_usec > wait.tv_usec)) { /* it has been long enough, note that timeoutval is untouched */ - return(1); + return 1; } /* it hasn't been long enough, set the timeout as necessary */ timeval_diff(&wait, &diff, timeoutval); - return(0); + return 0; } /** @@ -696,7 +696,7 @@ static int process_input(struct conn *c) count--; } - return(ret); + return ret; } /** @@ -107,7 +107,7 @@ int rcvr_send_command(struct receiver *rcvr) if(retval < 0 || ((size_t)retval) != cmdsize) { fprintf(stderr, "send_command, write returned %zd\n", retval); printf("%s", rcvr_err); - return(-1); + return -1; } rcvr->cmds_sent++; } @@ -141,11 +141,11 @@ static int rcvr_handle_status(int serialfd, char **status) if(*status) memcpy(*status, buf, retval + 1); } - return(retval); + return retval; } fprintf(stderr, "handle_status, read value was empty\n"); - return(-1); + return -1; } /** @@ -517,7 +517,7 @@ static int parse_status(struct receiver *rcvr, int size, char *status) */ enum power initial_power_status(void) { - return(POWER_OFF); + return POWER_OFF; } /** @@ -34,7 +34,7 @@ int xopen(const char *path, int oflag) fd = open(path, oflag); if ((fd < 0) && errno == EINTR) continue; - return(fd); + return fd; } } @@ -45,7 +45,7 @@ int xclose(int fd) nr = close(fd); if((nr < 0) && errno == EINTR) continue; - return(nr); + return nr; } } @@ -56,7 +56,7 @@ ssize_t xread(int fd, void *buf, size_t len) nr = read(fd, buf, len); if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) continue; - return(nr); + return nr; } } @@ -67,7 +67,7 @@ ssize_t xwrite(int fd, const void *buf, size_t len) nr = write(fd, buf, len); if ((nr < 0) && (errno == EAGAIN || errno == EINTR)) continue; - return(nr); + return nr; } } @@ -86,7 +86,7 @@ unsigned long hash_sdbm(const char *str) while((c = *str++)) hash = c + (hash << 6) + (hash << 16) - hash; - return(hash); + return hash; } void timeval_diff(struct timeval * restrict a, @@ -106,14 +106,14 @@ struct timeval timeval_min(struct timeval *restrict a, struct timeval * restrict b) { if(a->tv_sec == 0 && a->tv_usec == 0) { - return(*b); + return *b; } if(a->tv_sec < b->tv_sec) { - return(*a); + return *a; } else if(a->tv_sec > b->tv_sec) { - return(*b); + return *b; } /* getting here means seconds are equal */ - return(a->tv_usec < b->tv_usec ? *a : *b); + return a->tv_usec < b->tv_usec ? *a : *b; } /* vim: set ts=4 sw=4 noet: */ |