From 779cfd85fd90d1f9182deade08d5fe3f2f3a1530 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 20 Dec 2011 17:37:28 +0100 Subject: [PATCH 1/1] Rename write_nonblock() to xwrite(). This function is not only useful for non-blocking file descriptors, so the name was misleading. Rename it to xwrite() for the lack of a better name. --- crypt.c | 2 +- dccp_send.c | 2 +- fd.c | 10 +++++----- fd.h | 2 +- gcrypt.c | 2 +- grab_client.c | 2 +- http_send.c | 2 +- interactive.c | 2 +- oss_write.c | 2 +- send_common.c | 2 +- stdout.c | 2 +- udp_send.c | 2 +- 12 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crypt.c b/crypt.c index 85ec091d..f33f769f 100644 --- a/crypt.c +++ b/crypt.c @@ -298,7 +298,7 @@ int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf, memcpy(remainder, buf + l1, len - l1); RC4(&scc->send->key, len - l1, remainder, tmp + l1); } - ret = write_nonblock(scc->fd, (char *)tmp, len); + ret = xwrite(scc->fd, (char *)tmp, len); free(tmp); return ret; } diff --git a/dccp_send.c b/dccp_send.c index fa2a163c..cfbc4de7 100644 --- a/dccp_send.c +++ b/dccp_send.c @@ -104,7 +104,7 @@ static int dccp_init_fec(struct sender_client *sc) static void dccp_send_fec(struct sender_client *sc, char *buf, size_t len) { - int ret = write_nonblock(sc->fd, buf, len); + int ret = xwrite(sc->fd, buf, len); if (ret < 0) dccp_shutdown_client(sc); diff --git a/fd.c b/fd.c index 01c7ed8e..a73325ba 100644 --- a/fd.c +++ b/fd.c @@ -37,7 +37,7 @@ * len indicates that some bytes have been written but the next write would * block. */ -int write_nonblock(int fd, const char *buf, size_t len) +int xwrite(int fd, const char *buf, size_t len) { size_t written = 0; @@ -73,14 +73,14 @@ int write_nonblock(int fd, const char *buf, size_t len) * \param buf The buffer to be sent. * \param len The length of \a buf. * - * This is like \ref write_nonblock() but returns \p -E_SHORT_WRITE if not + * This is like \ref xwrite() but returns \p -E_SHORT_WRITE if not * all data could be written. * * \return Number of bytes written on success, negative error code else. */ int write_all(int fd, const char *buf, size_t len) { - int ret = write_nonblock(fd, buf, len); + int ret = xwrite(fd, buf, len); if (ret < 0) return ret; @@ -120,7 +120,7 @@ __printf_2_3 int write_va_buffer(int fd, const char *fmt, ...) * If \a rfds is not \p NULL and the (non-blocking) file descriptor \a fd is * not set in \a rfds, this function returns early without doing anything. * Otherwise The function tries to read up to \a sz bytes from \a fd. As for - * write_nonblock(), EAGAIN is not considered an error condition. However, EOF + * xwrite(), EAGAIN is not considered an error condition. However, EOF * is. * * \return Zero or a negative error code. If the underlying call to readv(2) @@ -133,7 +133,7 @@ __printf_2_3 int write_va_buffer(int fd, const char *fmt, ...) * have been read before the error occurred. In this case \a num_bytes is * positive. * - * \sa \ref write_nonblock(), read(2), readv(2). + * \sa \ref xwrite(), read(2), readv(2). */ int readv_nonblock(int fd, struct iovec *iov, int iovcnt, fd_set *rfds, size_t *num_bytes) diff --git a/fd.h b/fd.h index ed4c85a5..b8356edd 100644 --- a/fd.h +++ b/fd.h @@ -29,7 +29,7 @@ int readv_nonblock(int fd, struct iovec *iov, int iovcnt, fd_set *rfds, size_t *num_bytes); int read_nonblock(int fd, void *buf, size_t sz, fd_set *rfds, size_t *num_bytes); int read_pattern(int fd, const char *pattern, size_t bufsize, fd_set *rfds); -int write_nonblock(int fd, const char *buf, size_t len); +int xwrite(int fd, const char *buf, size_t len); int for_each_file_in_dir(const char *dirname, int (*func)(const char *, void *), void *private_data); /** diff --git a/gcrypt.c b/gcrypt.c index 1ce4587f..d11e94c7 100644 --- a/gcrypt.c +++ b/gcrypt.c @@ -951,7 +951,7 @@ int sc_send_bin_buffer(struct stream_cipher_context *scc, char *buf, gret = gcry_cipher_encrypt(scc->send->handle, tmp, size, (unsigned char *)buf, size); assert(gret == 0); - ret = write_nonblock(scc->fd, (char *)tmp, size); + ret = xwrite(scc->fd, (char *)tmp, size); free(tmp); return ret; } diff --git a/grab_client.c b/grab_client.c index 5b0688fc..729c8193 100644 --- a/grab_client.c +++ b/grab_client.c @@ -76,7 +76,7 @@ static int gc_write(struct grab_client *gc, char *buf, size_t len) if (gc->mode == GM_SLOPPY) return len; } - ret = write_nonblock(gc->fd, buf, len); + ret = xwrite(gc->fd, buf, len); if (ret < 0) goto err; if (ret > 0) diff --git a/http_send.c b/http_send.c index c26572f0..eddc0295 100644 --- a/http_send.c +++ b/http_send.c @@ -125,7 +125,7 @@ static void http_send_chunk(struct sender_client *sc, struct sender_status *ss, ret = queue_chunk_or_shutdown(sc, ss, buf, len); goto out; } - ret = write_nonblock(sc->fd, buf, len); + ret = xwrite(sc->fd, buf, len); if (ret < 0) { shutdown_client(sc, ss); goto out; diff --git a/interactive.c b/interactive.c index e17a7a10..6a29bffa 100644 --- a/interactive.c +++ b/interactive.c @@ -292,7 +292,7 @@ static void i9e_post_select(struct sched *s, struct task *t) sz = btr_next_buffer(btrn, &buf); if (sz == 0) goto out; - ret = write_nonblock(ici->fds[1], buf, sz); + ret = xwrite(ici->fds[1], buf, sz); if (ret < 0) goto rm_btrn; btr_consume(btrn, ret); diff --git a/oss_write.c b/oss_write.c index 85357f93..f075ce50 100644 --- a/oss_write.c +++ b/oss_write.c @@ -189,7 +189,7 @@ static void oss_post_select(__a_unused struct sched *s, ret = 0; if (!FD_ISSET(powd->fd, &s->wfds)) goto out; - ret = write_nonblock(powd->fd, data, frames * powd->bytes_per_frame); + ret = xwrite(powd->fd, data, frames * powd->bytes_per_frame); if (ret < 0) goto out; btr_consume(btrn, ret); diff --git a/send_common.c b/send_common.c index 71e0852a..354c9ed5 100644 --- a/send_common.c +++ b/send_common.c @@ -113,7 +113,7 @@ int send_queued_chunks(int fd, struct chunk_queue *cq) int ret; cq_get(qc, &buf, &len); - ret = write_nonblock(fd, buf, len); + ret = xwrite(fd, buf, len); if (ret < 0) return ret; cq_update(cq, ret); diff --git a/stdout.c b/stdout.c index 0f0c0e53..abe7abc9 100644 --- a/stdout.c +++ b/stdout.c @@ -68,7 +68,7 @@ static void stdout_post_select(struct sched *s, struct task *t) sz = btr_next_buffer(btrn, &buf); if (sz == 0) break; - ret = write_nonblock(STDOUT_FILENO, buf, sz); + ret = xwrite(STDOUT_FILENO, buf, sz); if (ret <= 0) break; btr_consume(btrn, ret); diff --git a/udp_send.c b/udp_send.c index 1155bcb4..3e3950f9 100644 --- a/udp_send.c +++ b/udp_send.c @@ -288,7 +288,7 @@ static void udp_send_fec(struct sender_client *sc, char *buf, size_t len) ret = udp_check_socket_state(sc); if (ret < 0) goto fail; - ret = write_nonblock(sc->fd, buf, len); + ret = xwrite(sc->fd, buf, len); if (ret == -ERRNO_TO_PARA_ERROR(ECONNREFUSED)) { /* * Happens if meanwhile an ICMP Destination / Port Unreachable -- 2.30.2