summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2019-12-07 20:50:42 -0500
committerGlenn Strauss <gstrauss@gluelogic.com>2020-07-08 19:54:28 -0400
commit0ff60d82188c1a0ec60cfa0522f4d50fd0ea1736 (patch)
tree53c62d391a77b8800cd2c53d16bd42abe6e0ba2e /src
parent03b4c993d206221b02cda31e9d25cf2b4bc0813e (diff)
downloadlighttpd-git-0ff60d82188c1a0ec60cfa0522f4d50fd0ea1736.tar.gz
[multiple] rename r to rc rv rd wr to be different
variable rename
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c12
-rw-r--r--src/connections.c38
-rw-r--r--src/fdevent_libev.c10
-rw-r--r--src/gw_backend.c14
-rw-r--r--src/log.c38
-rw-r--r--src/mod_cgi.c76
-rw-r--r--src/mod_compress.c7
-rw-r--r--src/mod_openssl.c39
-rw-r--r--src/network_write.c86
-rw-r--r--src/request.c6
-rw-r--r--src/response.c34
-rw-r--r--src/sock_addr.c20
12 files changed, 183 insertions, 197 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 1e65dd5f..b3f5040f 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -281,28 +281,28 @@ void buffer_copy_int(buffer *b, intmax_t val) {
}
void buffer_append_strftime(buffer *b, const char *format, const struct tm *tm) {
- size_t r;
+ size_t rv;
char* buf;
force_assert(NULL != b);
force_assert(NULL != format);
force_assert(NULL != tm);
buf = buffer_string_prepare_append(b, 255);
- r = strftime(buf, buffer_string_space(b), format, tm);
+ rv = strftime(buf, buffer_string_space(b), format, tm);
/* 0 (in some apis buffer_string_space(b)) signals the string may have
* been too small; but the format could also just have lead to an empty
* string
*/
- if (0 == r || r >= buffer_string_space(b)) {
+ if (0 == rv || rv >= buffer_string_space(b)) {
/* give it a second try with a larger string */
buf = buffer_string_prepare_append(b, 4095);
- r = strftime(buf, buffer_string_space(b), format, tm);
+ rv = strftime(buf, buffer_string_space(b), format, tm);
}
- if (r >= buffer_string_space(b)) r = 0;
+ if (rv >= buffer_string_space(b)) rv = 0;
- buffer_commit(b, r);
+ buffer_commit(b, rv);
}
diff --git a/src/connections.c b/src/connections.c
index 530000d1..b842c434 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -498,8 +498,8 @@ static void connection_handle_write_state(connection *con) {
}
if (con->mode != DIRECT && !con->file_finished) {
- int r = plugins_call_handle_subrequest(con);
- switch(r) {
+ int rc = plugins_call_handle_subrequest(con);
+ switch(rc) {
case HANDLER_WAIT_FOR_EVENT:
case HANDLER_FINISHED:
case HANDLER_GO_ON:
@@ -511,7 +511,7 @@ static void connection_handle_write_state(connection *con) {
default:
log_error(con->conf.errh, __FILE__, __LINE__,
"unexpected subrequest handler ret-value: %d %d",
- con->fd, r);
+ con->fd, rc);
/* fall through */
case HANDLER_ERROR:
connection_set_state(con, CON_STATE_ERROR);
@@ -1135,8 +1135,8 @@ connection *connection_accepted(server *srv, server_socket *srv_socket, sock_add
static int connection_handle_request(connection *con) {
- int r = http_response_prepare(con);
- switch (r) {
+ int rc = http_response_prepare(con);
+ switch (rc) {
case HANDLER_WAIT_FOR_EVENT:
if (!con->file_finished && (!con->file_started || 0 == con->conf.stream_response_body)) {
break; /* come back here */
@@ -1234,7 +1234,7 @@ static int connection_handle_request(connection *con) {
connection_set_state(con, CON_STATE_ERROR);
break;
default:
- log_error(con->conf.errh, __FILE__, __LINE__, "unknown ret-value: %d %d", con->fd, r);
+ log_error(con->conf.errh, __FILE__, __LINE__, "unknown ret-value: %d %d", con->fd, rc);
break;
}
@@ -1244,7 +1244,7 @@ static int connection_handle_request(connection *con) {
int connection_state_machine(connection *con) {
connection_state_t ostate;
- int r;
+ int rc;
const int log_state_handling = con->srv->srvconf.log_state_handling;
if (log_state_handling) {
@@ -1326,10 +1326,10 @@ int connection_state_machine(connection *con) {
"state at exit: %d %s", con->fd, connection_get_state(con->state));
}
- r = 0;
+ rc = 0;
switch(con->state) {
case CON_STATE_READ:
- r = FDEVENT_IN | FDEVENT_RDHUP;
+ rc = FDEVENT_IN | FDEVENT_RDHUP;
break;
case CON_STATE_WRITE:
/* request write-fdevent only if we really need it
@@ -1339,16 +1339,16 @@ int connection_state_machine(connection *con) {
if (!chunkqueue_is_empty(con->write_queue) &&
(con->is_writable == 0) &&
(con->traffic_limit_reached == 0)) {
- r |= FDEVENT_OUT;
+ rc |= FDEVENT_OUT;
}
/* fall through */
case CON_STATE_READ_POST:
if (con->conf.stream_request_body & FDEVENT_STREAM_REQUEST_POLLIN) {
- r |= FDEVENT_IN | FDEVENT_RDHUP;
+ rc |= FDEVENT_IN | FDEVENT_RDHUP;
}
break;
case CON_STATE_CLOSE:
- r = FDEVENT_IN;
+ rc = FDEVENT_IN;
break;
default:
break;
@@ -1357,24 +1357,24 @@ int connection_state_machine(connection *con) {
const int events = fdevent_fdnode_interest(con->fdn);
if (con->is_readable < 0) {
con->is_readable = 0;
- r |= FDEVENT_IN;
+ rc |= FDEVENT_IN;
}
if (con->is_writable < 0) {
con->is_writable = 0;
- r |= FDEVENT_OUT;
+ rc |= FDEVENT_OUT;
}
if (events & FDEVENT_RDHUP) {
- r |= FDEVENT_RDHUP;
+ rc |= FDEVENT_RDHUP;
}
- if (r != events) {
+ if (rc != events) {
/* update timestamps when enabling interest in events */
- if ((r & FDEVENT_IN) && !(events & FDEVENT_IN)) {
+ if ((rc & FDEVENT_IN) && !(events & FDEVENT_IN)) {
con->read_idle_ts = log_epoch_secs;
}
- if ((r & FDEVENT_OUT) && !(events & FDEVENT_OUT)) {
+ if ((rc & FDEVENT_OUT) && !(events & FDEVENT_OUT)) {
con->write_request_ts = log_epoch_secs;
}
- fdevent_fdnode_event_set(con->srv->ev, con->fdn, r);
+ fdevent_fdnode_event_set(con->srv->ev, con->fdn, rc);
}
}
diff --git a/src/fdevent_libev.c b/src/fdevent_libev.c
index 6d9155b4..f8199f3d 100644
--- a/src/fdevent_libev.c
+++ b/src/fdevent_libev.c
@@ -13,15 +13,15 @@
static void io_watcher_cb(struct ev_loop *loop, ev_io *w, int revents) {
fdevents *ev = w->data;
fdnode *fdn = ev->fdarray[w->fd];
- int r = 0;
+ int rv = 0;
UNUSED(loop);
- if (revents & EV_READ) r |= FDEVENT_IN;
- if (revents & EV_WRITE) r |= FDEVENT_OUT;
- if (revents & EV_ERROR) r |= FDEVENT_ERR;
+ if (revents & EV_READ) rv |= FDEVENT_IN;
+ if (revents & EV_WRITE) rv |= FDEVENT_OUT;
+ if (revents & EV_ERROR) rv |= FDEVENT_ERR;
if (0 == ((uintptr_t)fdn & 0x3)) {
- (*fdn->handler)(ev->srv, fdn->ctx, r);
+ (*fdn->handler)(ev->srv, fdn->ctx, rv);
}
}
diff --git a/src/gw_backend.c b/src/gw_backend.c
index 67d40bef..3f63ca2c 100644
--- a/src/gw_backend.c
+++ b/src/gw_backend.c
@@ -2043,31 +2043,31 @@ handler_t gw_handle_subrequest(connection *con, void *p_d) {
if (0 != hctx->wb->bytes_in) return HANDLER_WAIT_FOR_EVENT;
}
else {
- handler_t r = connection_handle_read_post_state(con);
+ handler_t rc = connection_handle_read_post_state(con);
chunkqueue *req_cq = con->request_content_queue;
#if 0 /*(not reached since we send 411 Length Required below)*/
if (hctx->wb_reqlen < -1 && con->request.content_length >= 0) {
/* (completed receiving Transfer-Encoding: chunked) */
hctx->wb_reqlen= -hctx->wb_reqlen + con->request.content_length;
if (hctx->stdin_append) {
- handler_t rc = hctx->stdin_append(hctx);
- if (HANDLER_GO_ON != rc) return rc;
+ handler_t rca = hctx->stdin_append(hctx);
+ if (HANDLER_GO_ON != rca) return rca;
}
}
#endif
if ((0 != hctx->wb->bytes_in || -1 == hctx->wb_reqlen)
&& !chunkqueue_is_empty(req_cq)) {
if (hctx->stdin_append) {
- handler_t rc = hctx->stdin_append(hctx);
- if (HANDLER_GO_ON != rc) return rc;
+ handler_t rca = hctx->stdin_append(hctx);
+ if (HANDLER_GO_ON != rca) return rca;
}
else
chunkqueue_append_chunkqueue(hctx->wb, req_cq);
if (fdevent_fdnode_interest(hctx->fdn) & FDEVENT_OUT) {
- return (r == HANDLER_GO_ON) ? HANDLER_WAIT_FOR_EVENT : r;
+ return (rc == HANDLER_GO_ON) ? HANDLER_WAIT_FOR_EVENT : rc;
}
}
- if (r != HANDLER_GO_ON) return r;
+ if (rc != HANDLER_GO_ON) return rc;
/* XXX: create configurable flag */
diff --git a/src/log.c b/src/log.c
index eb6d717d..489c08ff 100644
--- a/src/log.c
+++ b/src/log.c
@@ -44,33 +44,19 @@ int log_clock_gettime_realtime (struct timespec *ts) {
}
/* retry write on EINTR or when not all data was written */
-ssize_t write_all(int fd, const void* buf, size_t count) {
- ssize_t written = 0;
-
- while (count > 0) {
- ssize_t r = write(fd, buf, count);
- if (r < 0) {
- switch (errno) {
- case EINTR:
- /* try again */
- break;
- default:
- /* fail - repeating probably won't help */
- return -1;
- }
- } else if (0 == r) {
- /* really shouldn't happen... */
- errno = EIO;
- return -1;
- } else {
- force_assert(r <= (ssize_t) count);
- written += r;
- buf = r + (char const*) buf;
- count -= r;
- }
- }
+ssize_t write_all(int fd, const void * const buf, size_t count) {
+ ssize_t written = 0;
+
+ for (ssize_t wr; count > 0; count -= wr, written += wr) {
+ wr = write(fd, (const char *)buf + written, count);
+ if (wr > 0) continue;
+
+ if (wr < 0 && errno == EINTR) { wr = 0; continue; } /* try again */
+ if (0 == wr) errno = EIO; /* really shouldn't happen... */
+ return -1; /* fail - repeating probably won't help */
+ }
- return written;
+ return written;
}
static int log_buffer_prepare(const log_error_st *errh, const char *filename, unsigned int line, buffer *b) {
diff --git a/src/mod_cgi.c b/src/mod_cgi.c
index 223972e2..750be2f3 100644
--- a/src/mod_cgi.c
+++ b/src/mod_cgi.c
@@ -135,8 +135,8 @@ INIT_FUNC(mod_cgi_init) {
FREE_FUNC(mod_cgi_free) {
plugin_data *p = p_d;
- buffer_pid_t *r = &(p->cgi_pid);
- if (r->ptr) free(r->ptr);
+ buffer_pid_t *bp = &(p->cgi_pid);
+ if (bp->ptr) free(bp->ptr);
free(p->env.ptr);
free(p->env.offsets);
free(p->env.eptr);
@@ -259,24 +259,24 @@ SETDEFAULTS_FUNC(mod_cgi_set_defaults) {
static void cgi_pid_add(plugin_data *p, pid_t pid, void *ctx) {
- buffer_pid_t *r = &(p->cgi_pid);
+ buffer_pid_t *bp = &(p->cgi_pid);
- if (r->used == r->size) {
- r->size += 16;
- r->ptr = realloc(r->ptr, sizeof(*r->ptr) * r->size);
- force_assert(r->ptr);
- }
+ if (bp->used == bp->size) {
+ bp->size += 16;
+ bp->ptr = realloc(bp->ptr, sizeof(*bp->ptr) * bp->size);
+ force_assert(bp->ptr);
+ }
- r->ptr[r->used].pid = pid;
- r->ptr[r->used].ctx = ctx;
- ++r->used;
+ bp->ptr[bp->used].pid = pid;
+ bp->ptr[bp->used].ctx = ctx;
+ ++bp->used;
}
static void cgi_pid_kill(plugin_data *p, pid_t pid) {
- buffer_pid_t *r = &(p->cgi_pid);
- for (size_t i = 0; i < r->used; ++i) {
- if (r->ptr[i].pid == pid) {
- r->ptr[i].ctx = NULL;
+ buffer_pid_t *bp = &(p->cgi_pid);
+ for (size_t i = 0; i < bp->used; ++i) {
+ if (bp->ptr[i].pid == pid) {
+ bp->ptr[i].ctx = NULL;
kill(pid, SIGTERM);
return;
}
@@ -284,12 +284,12 @@ static void cgi_pid_kill(plugin_data *p, pid_t pid) {
}
static void cgi_pid_del(plugin_data *p, size_t i) {
- buffer_pid_t *r = &(p->cgi_pid);
+ buffer_pid_t *bp = &(p->cgi_pid);
- if (i != r->used - 1) {
- r->ptr[i] = r->ptr[r->used - 1];
- }
- r->used--;
+ if (i != bp->used - 1)
+ bp->ptr[i] = bp->ptr[bp->used - 1];
+
+ --bp->used;
}
@@ -544,7 +544,7 @@ static off_t mmap_align_offset(off_t start) {
static ssize_t cgi_write_file_chunk_mmap(connection *con, int fd, chunkqueue *cq) {
chunk* const c = cq->first;
off_t offset, toSend, file_end;
- ssize_t r;
+ ssize_t wr;
size_t mmap_offset, mmap_avail;
char *data = NULL;
@@ -614,11 +614,11 @@ static ssize_t cgi_write_file_chunk_mmap(connection *con, int fd, chunkqueue *cq
data = c->file.mmap.start + mmap_offset;
}
- r = write(fd, data, toSend);
+ wr = write(fd, data, toSend);
if (MAP_FAILED == c->file.mmap.start) free(data);
- if (r < 0) {
+ if (wr < 0) {
switch (errno) {
case EAGAIN:
case EINTR:
@@ -633,8 +633,8 @@ static ssize_t cgi_write_file_chunk_mmap(connection *con, int fd, chunkqueue *cq
}
}
- chunkqueue_mark_written(cq, r);
- return r;
+ chunkqueue_mark_written(cq, wr);
+ return wr;
}
static int cgi_write_request(handler_ctx *hctx, int fd) {
@@ -648,41 +648,41 @@ static int cgi_write_request(handler_ctx *hctx, int fd) {
*/
for (c = cq->first; c; c = cq->first) {
- ssize_t r = -1;
+ ssize_t wr = -1;
switch(c->type) {
case FILE_CHUNK:
- r = cgi_write_file_chunk_mmap(con, fd, cq);
+ wr = cgi_write_file_chunk_mmap(con, fd, cq);
break;
case MEM_CHUNK:
- if ((r = write(fd, c->mem->ptr + c->offset, buffer_string_length(c->mem) - c->offset)) < 0) {
+ if ((wr = write(fd, c->mem->ptr + c->offset, buffer_string_length(c->mem) - c->offset)) < 0) {
switch(errno) {
case EAGAIN:
case EINTR:
/* ignore and try again */
- r = 0;
+ wr = 0;
break;
case EPIPE:
case ECONNRESET:
/* connection closed */
- r = -2;
+ wr = -2;
break;
default:
/* fatal error */
log_perror(con->conf.errh, __FILE__, __LINE__, "write() failed");
- r = -1;
+ wr = -1;
break;
}
- } else if (r > 0) {
- chunkqueue_mark_written(cq, r);
+ } else if (wr > 0) {
+ chunkqueue_mark_written(cq, wr);
}
break;
}
- if (0 == r) break; /*(might block)*/
+ if (0 == wr) break; /*(might block)*/
- switch (r) {
+ switch (wr) {
case -1:
/* fatal error */
return -1;
@@ -954,13 +954,13 @@ SUBREQUEST_FUNC(mod_cgi_handle_subrequest) {
con->conf.stream_request_body &= ~FDEVENT_STREAM_REQUEST_POLLIN;
if (-1 != hctx->fd) return HANDLER_WAIT_FOR_EVENT;
} else {
- handler_t r = connection_handle_read_post_state(con);
+ handler_t rc = connection_handle_read_post_state(con);
if (!chunkqueue_is_empty(cq)) {
if (fdevent_fdnode_interest(hctx->fdntocgi) & FDEVENT_OUT) {
- return (r == HANDLER_GO_ON) ? HANDLER_WAIT_FOR_EVENT : r;
+ return (rc == HANDLER_GO_ON) ? HANDLER_WAIT_FOR_EVENT : rc;
}
}
- if (r != HANDLER_GO_ON) return r;
+ if (rc != HANDLER_GO_ON) return rc;
/* CGI environment requires that Content-Length be set.
* Send 411 Length Required if Content-Length missing.
diff --git a/src/mod_compress.c b/src/mod_compress.c
index 53887706..78b24ffa 100644
--- a/src/mod_compress.c
+++ b/src/mod_compress.c
@@ -481,7 +481,6 @@ static int deflate_file_to_file(connection *con, plugin_data *p, int ifd, buffer
#endif
void *start;
stat_cache_entry *sce_ofn;
- ssize_t r;
/* overflow */
if ((off_t)(sce->st.st_size * 1.1) < sce->st.st_size) return -1;
@@ -622,12 +621,12 @@ static int deflate_file_to_file(connection *con, plugin_data *p, int ifd, buffer
}
if (ret == 0) {
- r = write(ofd, CONST_BUF_LEN(p->b));
- if (-1 == r) {
+ ssize_t wr = write(ofd, CONST_BUF_LEN(p->b));
+ if (-1 == wr) {
log_perror(con->conf.errh, __FILE__, __LINE__,
"writing cachefile %s failed", p->ofn->ptr);
ret = -1;
- } else if ((size_t)r != buffer_string_length(p->b)) {
+ } else if ((size_t)wr != buffer_string_length(p->b)) {
log_error(con->conf.errh, __FILE__, __LINE__,
"writing cachefile %s failed: not enough bytes written",
p->ofn->ptr);
diff --git a/src/mod_openssl.c b/src/mod_openssl.c
index 493a8a72..861491ed 100644
--- a/src/mod_openssl.c
+++ b/src/mod_openssl.c
@@ -1789,7 +1789,7 @@ connection_write_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
while (max_bytes > 0 && NULL != cq->first) {
const char *data;
size_t data_len;
- int r;
+ int wr;
if (0 != load_next_chunk(con,cq,max_bytes,&data,&data_len)) return -1;
@@ -1803,7 +1803,7 @@ connection_write_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
*/
ERR_clear_error();
- r = SSL_write(ssl, data, data_len);
+ wr = SSL_write(ssl, data, data_len);
if (hctx->renegotiations > 1
&& hctx->conf.ssl_disable_client_renegotiation) {
@@ -1812,11 +1812,11 @@ connection_write_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
return -1;
}
- if (r <= 0) {
+ if (wr <= 0) {
int ssl_r;
unsigned long err;
- switch ((ssl_r = SSL_get_error(ssl, r))) {
+ switch ((ssl_r = SSL_get_error(ssl, wr))) {
case SSL_ERROR_WANT_READ:
con->is_readable = -1;
return 0; /* try again later */
@@ -1828,9 +1828,9 @@ connection_write_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
if (0 != (err = ERR_get_error())) {
do {
log_error(con->conf.errh, __FILE__, __LINE__,
- "SSL: %d %d %s",ssl_r,r,ERR_error_string(err,NULL));
+ "SSL: %d %d %s",ssl_r,wr,ERR_error_string(err,NULL));
} while((err = ERR_get_error()));
- } else if (r == -1) {
+ } else if (wr == -1) {
/* no, but we have errno */
switch(errno) {
case EPIPE:
@@ -1838,36 +1838,36 @@ connection_write_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
return -2;
default:
log_perror(con->conf.errh, __FILE__, __LINE__,
- "SSL: %d %d", ssl_r, r);
+ "SSL: %d %d", ssl_r, wr);
break;
}
} else {
/* neither error-queue nor errno ? */
log_perror(con->conf.errh, __FILE__, __LINE__,
- "SSL (error): %d %d", ssl_r, r);
+ "SSL (error): %d %d", ssl_r, wr);
}
break;
case SSL_ERROR_ZERO_RETURN:
/* clean shutdown on the remote side */
- if (r == 0) return -2;
+ if (wr == 0) return -2;
/* fall through */
default:
while((err = ERR_get_error())) {
log_error(con->conf.errh, __FILE__, __LINE__,
- "SSL: %d %d %s", ssl_r, r, ERR_error_string(err, NULL));
+ "SSL: %d %d %s", ssl_r, wr, ERR_error_string(err, NULL));
}
break;
}
return -1;
}
- chunkqueue_mark_written(cq, r);
- max_bytes -= r;
+ chunkqueue_mark_written(cq, wr);
+ max_bytes -= wr;
- if ((size_t) r < data_len) break; /* try again later */
+ if ((size_t) wr < data_len) break; /* try again later */
}
return 0;
@@ -1878,7 +1878,7 @@ static int
connection_read_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
{
handler_ctx *hctx = con->plugin_ctx[plugin_data_singleton->id];
- int r, ssl_err, len;
+ int len;
char *mem = NULL;
size_t mem_len = 0;
@@ -1929,7 +1929,8 @@ connection_read_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
if (len < 0) {
int oerrno = errno;
- switch ((r = SSL_get_error(hctx->ssl, len))) {
+ int rc, ssl_err;
+ switch ((rc = SSL_get_error(hctx->ssl, len))) {
case SSL_ERROR_WANT_WRITE:
con->is_writable = -1;
/* fall through */
@@ -1959,7 +1960,7 @@ connection_read_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
while((ssl_err = ERR_get_error())) {
/* get all errors from the error-queue */
log_error(con->conf.errh, __FILE__, __LINE__,
- "SSL: %d %s", r, ERR_error_string(ssl_err, NULL));
+ "SSL: %d %s", rc, ERR_error_string(ssl_err, NULL));
}
switch(oerrno) {
@@ -1973,7 +1974,7 @@ connection_read_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
break;
log_error(con->conf.errh, __FILE__, __LINE__,
- "SSL: %d %d %d %s", len, r, oerrno, strerror(oerrno));
+ "SSL: %d %d %d %s", len, rc, oerrno, strerror(oerrno));
break;
}
@@ -1981,7 +1982,7 @@ connection_read_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
case SSL_ERROR_ZERO_RETURN:
/* clean shutdown on the remote side */
- if (r == 0) {
+ if (rc == 0) {
/* FIXME: later */
}
@@ -2006,7 +2007,7 @@ connection_read_cq_ssl (connection *con, chunkqueue *cq, off_t max_bytes)
}
/* get all errors from the error-queue */
log_error(con->conf.errh, __FILE__, __LINE__,
- "SSL: %d %s", r, ERR_error_string(ssl_err, NULL));
+ "SSL: %d %s", rc, ERR_error_string(ssl_err, NULL));
}
break;
}
diff --git a/src/network_write.c b/src/network_write.c
index 577ef172..cee19582 100644
--- a/src/network_write.c
+++ b/src/network_write.c
@@ -217,7 +217,7 @@ static void sigbus_handler(int sig) {
static int network_write_file_chunk_mmap(int fd, chunkqueue *cq, off_t *p_max_bytes, log_error_st *errh) {
chunk* const c = cq->first;
off_t offset, toSend, file_end;
- ssize_t r;
+ ssize_t wr;
size_t mmap_offset, mmap_avail;
const char *data;
@@ -309,7 +309,7 @@ static int network_write_file_chunk_mmap(int fd, chunkqueue *cq, off_t *p_max_by
signal(SIGBUS, sigbus_handler);
sigbus_jmp_valid = 1;
- r = network_write_data_len(fd, data, toSend);
+ wr = network_write_data_len(fd, data, toSend);
sigbus_jmp_valid = 0;
} else {
sigbus_jmp_valid = 0;
@@ -322,10 +322,10 @@ static int network_write_file_chunk_mmap(int fd, chunkqueue *cq, off_t *p_max_by
return -1;
}
- if (r >= 0) {
- *p_max_bytes -= r;
- chunkqueue_mark_written(cq, r);
- return (r > 0 && r == toSend) ? 0 : -3;
+ if (wr >= 0) {
+ *p_max_bytes -= wr;
+ chunkqueue_mark_written(cq, wr);
+ return (wr > 0 && wr == toSend) ? 0 : -3;
} else {
return network_write_error(fd, errh);
}
@@ -371,7 +371,7 @@ static int network_writev_mem_chunks(int fd, chunkqueue *cq, off_t *p_max_bytes,
size_t num_chunks = 0;
off_t max_bytes = *p_max_bytes;
off_t toSend = 0;
- ssize_t r;
+ ssize_t wr;
for (const chunk *c = cq->first;
NULL != c && MEM_CHUNK == c->type
@@ -395,9 +395,9 @@ static int network_writev_mem_chunks(int fd, chunkqueue *cq, off_t *p_max_bytes,
return 0;
}
- r = writev(fd, chunks, num_chunks);
+ wr = writev(fd, chunks, num_chunks);
- if (r < 0) switch (errno) {
+ if (wr < 0) switch (errno) {
case EAGAIN:
case EINTR:
break;
@@ -409,12 +409,12 @@ static int network_writev_mem_chunks(int fd, chunkqueue *cq, off_t *p_max_bytes,
return -1;
}
- if (r >= 0) {
- *p_max_bytes -= r;
- chunkqueue_mark_written(cq, r);
+ if (wr >= 0) {
+ *p_max_bytes -= wr;
+ chunkqueue_mark_written(cq, wr);
}
- return (r > 0 && r == toSend) ? 0 : -3;
+ return (wr > 0 && wr == toSend) ? 0 : -3;
}
#endif /* NETWORK_WRITE_USE_WRITEV */
@@ -436,7 +436,7 @@ static int network_writev_mem_chunks(int fd, chunkqueue *cq, off_t *p_max_bytes,
static int network_write_file_chunk_sendfile(int fd, chunkqueue *cq, off_t *p_max_bytes, log_error_st *errh) {
chunk * const c = cq->first;
- ssize_t r;
+ ssize_t wr;
off_t offset;
off_t toSend;
off_t written = 0;
@@ -459,18 +459,18 @@ static int network_write_file_chunk_sendfile(int fd, chunkqueue *cq, off_t *p_ma
#if defined(NETWORK_WRITE_USE_LINUX_SENDFILE)
- r = sendfile(fd, c->file.fd, &offset, toSend);
- if (r > 0) written = (off_t)r;
+ wr = sendfile(fd, c->file.fd, &offset, toSend);
+ if (wr > 0) written = (off_t)wr;
#elif defined(NETWORK_WRITE_USE_DARWIN_SENDFILE)
written = toSend;
- r = sendfile(c->file.fd, fd, offset, &written, NULL, 0);
+ wr = sendfile(c->file.fd, fd, offset, &written, NULL, 0);
/* (for EAGAIN/EINTR written still contains the sent bytes) */
#elif defined(NETWORK_WRITE_USE_FREEBSD_SENDFILE)
- r = sendfile(c->file.fd, fd, offset, toSend, NULL, &written, 0);
+ wr = sendfile(c->file.fd, fd, offset, toSend, NULL, &written, 0);
/* (for EAGAIN/EINTR written still contains the sent bytes) */
#elif defined(NETWORK_WRITE_USE_SOLARIS_SENDFILEV)
@@ -482,17 +482,17 @@ static int network_write_file_chunk_sendfile(int fd, chunkqueue *cq, off_t *p_ma
fvec.sfv_len = toSend;
/* Solaris sendfilev() */
- r = sendfilev(fd, &fvec, 1, (size_t *)&written);
+ wr = sendfilev(fd, &fvec, 1, (size_t *)&written);
/* (for EAGAIN/EINTR written still contains the sent bytes) */
}
#else
- r = -1;
+ wr = -1;
errno = ENOSYS;
#endif
- if (-1 == r) {
+ if (-1 == wr) {
switch(errno) {
case EAGAIN:
case EINTR:
@@ -531,7 +531,7 @@ static int network_write_file_chunk_sendfile(int fd, chunkqueue *cq, off_t *p_ma
*p_max_bytes -= written;
}
- return (r >= 0 && written == toSend) ? 0 : -3;
+ return (wr >= 0 && written == toSend) ? 0 : -3;
}
#endif
@@ -547,23 +547,23 @@ static int network_write_file_chunk_sendfile(int fd, chunkqueue *cq, off_t *p_ma
static int network_write_chunkqueue_write(int fd, chunkqueue *cq, off_t max_bytes, log_error_st *errh) {
while (max_bytes > 0 && NULL != cq->first) {
- int r = -1;
+ int rc = -1;
switch (cq->first->type) {
case MEM_CHUNK:
- r = network_write_mem_chunk(fd, cq, &max_bytes, errh);
+ rc = network_write_mem_chunk(fd, cq, &max_bytes, errh);
break;
case FILE_CHUNK:
#ifdef NETWORK_WRITE_USE_MMAP
- r = network_write_file_chunk_mmap(fd, cq, &max_bytes, errh);
+ rc = network_write_file_chunk_mmap(fd, cq, &max_bytes, errh);
#else
- r = network_write_file_chunk_no_mmap(fd, cq, &max_bytes, errh);
+ rc = network_write_file_chunk_no_mmap(fd, cq, &max_bytes, errh);
#endif
break;
}
- if (-3 == r) return 0;
- if (0 != r) return r;
+ if (-3 == rc) return 0;
+ if (0 != rc) return rc;
}
return 0;
@@ -572,27 +572,27 @@ static int network_write_chunkqueue_write(int fd, chunkqueue *cq, off_t max_byte
#if defined(NETWORK_WRITE_USE_WRITEV)
static int network_write_chunkqueue_writev(int fd, chunkqueue *cq, off_t max_bytes, log_error_st *errh) {
while (max_bytes > 0 && NULL != cq->first) {
- int r = -1;
+ int rc = -1;
switch (cq->first->type) {
case MEM_CHUNK:
#if defined(NETWORK_WRITE_USE_WRITEV)
- r = network_writev_mem_chunks(fd, cq, &max_bytes, errh);
+ rc = network_writev_mem_chunks(fd, cq, &max_bytes, errh);
#else
- r = network_write_mem_chunk(fd, cq, &max_bytes, errh);
+ rc = network_write_mem_chunk(fd, cq, &max_bytes, errh);
#endif
break;
case FILE_CHUNK:
#ifdef NETWORK_WRITE_USE_MMAP
- r = network_write_file_chunk_mmap(fd, cq, &max_bytes, errh);
+ rc = network_write_file_chunk_mmap(fd, cq, &max_bytes, errh);
#else
- r = network_write_file_chunk_no_mmap(fd, cq, &max_bytes, errh);
+ rc = network_write_file_chunk_no_mmap(fd, cq, &max_bytes, errh);
#endif
break;
}
- if (-3 == r) return 0;
- if (0 != r) return r;
+ if (-3 == rc) return 0;
+ if (0 != rc) return rc;
}
return 0;
@@ -602,29 +602,29 @@ static int network_write_chunkqueue_writev(int fd, chunkqueue *cq, off_t max_byt
#if defined(NETWORK_WRITE_USE_SENDFILE)
static int network_write_chunkqueue_sendfile(int fd, chunkqueue *cq, off_t max_bytes, log_error_st *errh) {
while (max_bytes > 0 && NULL != cq->first) {
- int r = -1;
+ int rc = -1;
switch (cq->first->type) {
case MEM_CHUNK:
#if defined(NETWORK_WRITE_USE_WRITEV)
- r = network_writev_mem_chunks(fd, cq, &max_bytes, errh);
+ rc = network_writev_mem_chunks(fd, cq, &max_bytes, errh);
#else
- r = network_write_mem_chunk(fd, cq, &max_bytes, errh);
+ rc = network_write_mem_chunk(fd, cq, &max_bytes, errh);
#endif
break;
case FILE_CHUNK:
#if defined(NETWORK_WRITE_USE_SENDFILE)
- r = network_write_file_chunk_sendfile(fd, cq, &max_bytes, errh);
+ rc = network_write_file_chunk_sendfile(fd, cq, &max_bytes, errh);
#elif defined(NETWORK_WRITE_USE_MMAP)
- r = network_write_file_chunk_mmap(fd, cq, &max_bytes, errh);
+ rc = network_write_file_chunk_mmap(fd, cq, &max_bytes, errh);
#else
- r = network_write_file_chunk_no_mmap(fd, cq, &max_bytes, errh);
+ rc = network_write_file_chunk_no_mmap(fd, cq, &max_bytes, errh);
#endif
break;
}
- if (-3 == r) return 0;
- if (0 != r) return r;
+ if (-3 == rc) return 0;
+ if (0 != rc) return rc;
}
return 0;
diff --git a/src/request.c b/src/request.c
index b27e26f0..e35694a6 100644
--- a/src/request.c
+++ b/src/request.c
@@ -436,9 +436,9 @@ static int http_request_parse_single_header(connection * const con, const enum h
if (!(con->request.htags & HTTP_HEADER_CONTENT_LENGTH)) {
/*(trailing whitespace was removed from vlen)*/
char *err;
- off_t r = strtoll(v, &err, 10);
- if (r >= 0 && err == v+vlen) {
- con->request.content_length = r;
+ off_t clen = strtoll(v, &err, 10);
+ if (clen >= 0 && err == v+vlen) {
+ con->request.content_length = clen;
}
else {
return http_request_header_line_invalid(con, 400, "invalid Content-Length header -> 400");
diff --git a/src/response.c b/src/response.c
index 3071d4c6..771c490d 100644
--- a/src/response.c
+++ b/src/response.c
@@ -284,7 +284,7 @@ static handler_t http_response_physical_path_check(connection *con) {
}
handler_t http_response_prepare(connection *con) {
- handler_t r;
+ handler_t rc;
/* looks like someone has already done a decision */
if (con->mode == DIRECT &&
@@ -494,8 +494,8 @@ handler_t http_response_prepare(connection *con) {
*
*/
- r = plugins_call_handle_uri_raw(con);
- if (HANDLER_GO_ON != r) return r;
+ rc = plugins_call_handle_uri_raw(con);
+ if (HANDLER_GO_ON != rc) return rc;
/**
*
@@ -505,8 +505,8 @@ handler_t http_response_prepare(connection *con) {
*
*/
- r = plugins_call_handle_uri_clean(con);
- if (HANDLER_GO_ON != r) return r;
+ rc = plugins_call_handle_uri_clean(con);
+ if (HANDLER_GO_ON != rc) return rc;
if (con->request.http_method == HTTP_METHOD_OPTIONS &&
con->uri.path->ptr[0] == '*' && con->uri.path->ptr[1] == '\0') {
@@ -603,8 +603,8 @@ handler_t http_response_prepare(connection *con) {
/* the docroot plugin should set the doc_root and might also set the physical.path
* for us (all vhost-plugins are supposed to set the doc_root)
* */
- r = plugins_call_handle_docroot(con);
- if (HANDLER_GO_ON != r) return r;
+ rc = plugins_call_handle_docroot(con);
+ if (HANDLER_GO_ON != rc) return rc;
/* MacOS X and Windows can't distiguish between upper and lower-case
*
@@ -647,8 +647,8 @@ handler_t http_response_prepare(connection *con) {
* is filled in above to avoid repeating work next time
* http_response_prepare() is called while processing request) */
} else {
- r = plugins_call_handle_physical(con);
- if (HANDLER_GO_ON != r) return r;
+ rc = plugins_call_handle_physical(con);
+ if (HANDLER_GO_ON != rc) return rc;
if (con->conf.log_request_handling) {
log_error(con->conf.errh, __FILE__, __LINE__,
@@ -679,8 +679,8 @@ handler_t http_response_prepare(connection *con) {
"Path : %s", con->physical.path->ptr);
}
- r = http_response_physical_path_check(con);
- if (HANDLER_GO_ON != r) return r;
+ rc = http_response_physical_path_check(con);
+ if (HANDLER_GO_ON != rc) return rc;
if (con->conf.log_request_handling) {
log_error(con->conf.errh, __FILE__, __LINE__,
@@ -694,13 +694,13 @@ handler_t http_response_prepare(connection *con) {
}
/* call the handlers */
- r = plugins_call_handle_subrequest_start(con);
- if (HANDLER_GO_ON != r) {
+ rc = plugins_call_handle_subrequest_start(con);
+ if (HANDLER_GO_ON != rc) {
if (con->conf.log_request_handling) {
log_error(con->conf.errh, __FILE__, __LINE__,
"-- subrequest finished");
}
- return r;
+ return rc;
}
/* if we are still here, no one wanted the file, status 403 is ok I think */
@@ -711,7 +711,7 @@ handler_t http_response_prepare(connection *con) {
}
- r = plugins_call_handle_subrequest(con);
- if (HANDLER_GO_ON == r) r = HANDLER_FINISHED; /* request was not handled, looks like we are done */
- return r;
+ rc = plugins_call_handle_subrequest(con);
+ if (HANDLER_GO_ON == rc) rc = HANDLER_FINISHED; /* request was not handled, looks like we are done */
+ return rc;
}
diff --git a/src/sock_addr.c b/src/sock_addr.c
index dc8f8075..7a513c82 100644
--- a/src/sock_addr.c
+++ b/src/sock_addr.c
@@ -395,15 +395,15 @@ int sock_addr_from_str_hints(sock_addr *saddr, socklen_t *len, const char *str,
#ifdef HAVE_IPV6
else {
struct addrinfo hints, *res;
- int r;
+ int rc;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
- if (0 != (r = getaddrinfo(str, NULL, &hints, &res))) {
+ if (0 != (rc = getaddrinfo(str, NULL, &hints, &res))) {
log_error(errh, __FILE__, __LINE__,
- "getaddrinfo failed: %s '%s'", gai_strerror(r), str);
+ "getaddrinfo failed: %s '%s'", gai_strerror(rc), str);
return 0;
}
@@ -434,7 +434,7 @@ int sock_addr_from_str_hints(sock_addr *saddr, socklen_t *len, const char *str,
}
else {
struct addrinfo hints, *res;
- int r;
+ int rc;
memset(&hints, 0, sizeof(hints));
@@ -442,11 +442,11 @@ int sock_addr_from_str_hints(sock_addr *saddr, socklen_t *len, const char *str,
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
- if (0 != (r = getaddrinfo(str, NULL, &hints, &res))) {
+ if (0 != (rc = getaddrinfo(str, NULL, &hints, &res))) {
hints.ai_family = AF_INET;
if (
#ifdef EAI_ADDRFAMILY
- EAI_ADDRFAMILY == r &&
+ EAI_ADDRFAMILY == rc &&
#endif
0 == getaddrinfo(str, NULL, &hints, &res)) {
memcpy(saddr, res->ai_addr, res->ai_addrlen);
@@ -459,7 +459,7 @@ int sock_addr_from_str_hints(sock_addr *saddr, socklen_t *len, const char *str,
}
log_error(errh, __FILE__, __LINE__,
- "getaddrinfo failed: %s '%s'", gai_strerror(r), str);
+ "getaddrinfo failed: %s '%s'", gai_strerror(rc), str);
return 0;
}
@@ -484,15 +484,15 @@ int sock_addr_from_str_hints(sock_addr *saddr, socklen_t *len, const char *str,
#ifdef HAVE_INET_PTON
/*(reuse HAVE_INET_PTON for presence of getaddrinfo())*/
struct addrinfo hints, *res;
- int r;
+ int rc;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
- if (0 != (r = getaddrinfo(str, NULL, &hints, &res))) {
+ if (0 != (rc = getaddrinfo(str, NULL, &hints, &res))) {
log_error(errh, __FILE__, __LINE__,
- "getaddrinfo failed: %s '%s'", gai_strerror(r), str);
+ "getaddrinfo failed: %s '%s'", gai_strerror(rc), str);
return 0;
}