Coding style change

This commit is contained in:
Nils O. Selåsdal
2012-12-05 18:53:58 +01:00
parent d9c8b2b48a
commit 16e1ac52ec
32 changed files with 236 additions and 234 deletions
+11 -11
View File
@@ -26,15 +26,15 @@ void in_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
size_t left = BUFLEN - copy_ctx->w_idx;
ssize_t rc;
left /= 2;
if(left == 0)
if (left == 0)
left++;
rc = read(fd->fd, &copy_ctx->buffer[copy_ctx->w_idx], left);
if(rc <= 0) {
if(rc == -1 && errno == EAGAIN) {
if (rc <= 0) {
if (rc == -1 && errno == EAGAIN) {
return;
} else if(rc == -1) {
} else if (rc == -1) {
perror("read");
}
iomux_unregister_fd(mux, fd);
@@ -43,13 +43,13 @@ void in_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
copy_ctx->w_idx += rc;
if(!copy_ctx->out_running) {
if (!copy_ctx->out_running) {
copy_ctx->out.what = MUX_EV_WRITE;
iomux_register_fd(mux, &copy_ctx->out);
copy_ctx->out_running = 1;
}
if(copy_ctx->w_idx == BUFLEN) {
if (copy_ctx->w_idx == BUFLEN) {
iomux_unregister_fd(mux, fd);
}
}
@@ -61,8 +61,8 @@ void out_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
size_t len = copy_ctx->w_idx - copy_ctx->r_idx;
rc = write(1, &copy_ctx->buffer[copy_ctx->r_idx], len);
if(rc <= 0) {
if(rc == -1 && errno == EAGAIN) {
if (rc <= 0) {
if (rc == -1 && errno == EAGAIN) {
return;
} else {
perror("write");
@@ -72,10 +72,10 @@ void out_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
copy_ctx->out_running = 0;
} else {
copy_ctx->r_idx += rc;
if(copy_ctx->r_idx == copy_ctx->w_idx) {
if (copy_ctx->r_idx == copy_ctx->w_idx) {
iomux_unregister_fd(mux, fd);
copy_ctx->out_running = 0;
if(copy_ctx->w_idx == BUFLEN) {
if (copy_ctx->w_idx == BUFLEN) {
copy_ctx->w_idx = 0;
copy_ctx->r_idx = 0;
iomux_register_fd(mux, &copy_ctx->in);
@@ -88,7 +88,7 @@ void out_cb(struct IOMux *mux, struct IOMuxFD *fd, unsigned int event)
int set_nonblocking(int fd)
{
int flags = fcntl(fd,F_GETFL,NULL);
if(flags < 0 ) {
if (flags < 0 ) {
return flags;
}
return fcntl(fd,F_SETFL,flags | O_NONBLOCK);