summaryrefslogtreecommitdiff
path: root/cras/src/common/cras_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'cras/src/common/cras_util.c')
-rw-r--r--cras/src/common/cras_util.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/cras/src/common/cras_util.c b/cras/src/common/cras_util.c
index 28570bf9..bcc513ed 100644
--- a/cras/src/common/cras_util.c
+++ b/cras/src/common/cras_util.c
@@ -30,7 +30,7 @@ int cras_set_rt_scheduling(int rt_lim)
if (setrlimit(RLIMIT_RTPRIO, &rl) < 0) {
syslog(LOG_WARNING, "setrlimit %u failed: %d\n",
- (unsigned)rt_lim, errno);
+ (unsigned) rt_lim, errno);
return -EACCES;
}
return 0;
@@ -48,8 +48,7 @@ int cras_set_thread_priority(int priority)
if (err)
syslog(LOG_WARNING,
"Failed to set thread sched params to priority %d"
- ", rc: %d\n",
- priority, err);
+ ", rc: %d\n", priority, err);
return err;
}
@@ -65,8 +64,8 @@ int cras_set_nice_level(int nice)
*/
rc = setpriority(PRIO_PROCESS, syscall(__NR_gettid), nice);
if (rc)
- syslog(LOG_WARNING, "Failed to set nice to %d, rc: %d", nice,
- rc);
+ syslog(LOG_WARNING, "Failed to set nice to %d, rc: %d",
+ nice, rc);
return rc;
}
@@ -98,7 +97,7 @@ int cras_make_fd_blocking(int fd)
int cras_send_with_fds(int sockfd, const void *buf, size_t len, int *fd,
unsigned int num_fds)
{
- struct msghdr msg = { 0 };
+ struct msghdr msg = {0};
struct iovec iov;
struct cmsghdr *cmsg;
char *control;
@@ -122,8 +121,6 @@ int cras_send_with_fds(int sockfd, const void *buf, size_t len, int *fd,
memcpy(CMSG_DATA(cmsg), fd, sizeof(*fd) * num_fds);
rc = sendmsg(sockfd, &msg, 0);
- if (rc == -1)
- rc = -errno;
free(control);
return rc;
}
@@ -131,7 +128,7 @@ int cras_send_with_fds(int sockfd, const void *buf, size_t len, int *fd,
int cras_recv_with_fds(int sockfd, void *buf, size_t len, int *fd,
unsigned int *num_fds)
{
- struct msghdr msg = { 0 };
+ struct msghdr msg = {0};
struct iovec iov;
struct cmsghdr *cmsg;
char *control;
@@ -159,17 +156,15 @@ int cras_recv_with_fds(int sockfd, void *buf, size_t len, int *fd,
for (cmsg = CMSG_FIRSTHDR(&msg); cmsg != NULL;
cmsg = CMSG_NXTHDR(&msg, cmsg)) {
- if (cmsg->cmsg_level == SOL_SOCKET &&
- cmsg->cmsg_type == SCM_RIGHTS) {
+ if (cmsg->cmsg_level == SOL_SOCKET
+ && cmsg->cmsg_type == SCM_RIGHTS) {
size_t fd_size = cmsg->cmsg_len - sizeof(*cmsg);
*num_fds = MIN(*num_fds, fd_size / sizeof(*fd));
memcpy(fd, CMSG_DATA(cmsg), *num_fds * sizeof(*fd));
- goto exit;
+ break;
}
}
- // If we reach here, we did not find any file descriptors.
- *num_fds = 0;
exit:
free(control);
return rc;
@@ -204,7 +199,8 @@ int cras_poll(struct pollfd *fds, nfds_t nfds, struct timespec *timeout,
rc = ppoll(fds, nfds, timeout, sigmask);
if (rc == 0 && timeout) {
rc = -ETIMEDOUT;
- } else if (rc < 0) {
+ }
+ else if (rc < 0) {
rc = -errno;
}
@@ -233,12 +229,12 @@ int wait_for_dev_input_access()
unsigned i = 0;
while (i < max_iterations) {
- int readable;
- struct timeval timeout;
- const char *const pathname = "/dev/input/event0";
+ int readable;
+ struct timeval timeout;
+ const char * const pathname = "/dev/input/event0";
- timeout.tv_sec = 0;
- timeout.tv_usec = 500000; /* 1/2 second. */
+ timeout.tv_sec = 0;
+ timeout.tv_usec = 500000; /* 1/2 second. */
readable = access(pathname, R_OK);
/* If the file could be opened, then the udev rule has been