use ngx_min() and ngx_max()

This commit is contained in:
Igor Sysoev 2010-05-14 09:55:33 +00:00
parent 5739072cfe
commit 328df7a5cc
4 changed files with 6 additions and 14 deletions

View File

@ -465,10 +465,7 @@ ngx_output_chain_copy_buf(ngx_output_chain_ctx_t *ctx)
dst = ctx->buf;
size = ngx_buf_size(src);
if (size > dst->end - dst->pos) {
size = dst->end - dst->pos;
}
size = ngx_min(size, dst->end - dst->pos);
sendfile = ctx->sendfile & !ctx->directio;

View File

@ -229,9 +229,7 @@ ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args)
case 'V':
v = va_arg(args, ngx_str_t *);
len = v->len;
len = (buf + len < last) ? len : (size_t) (last - buf);
len = ngx_min(((size_t) (last - buf)), v->len);
buf = ngx_cpymem(buf, v->data, len);
fmt++;
@ -240,9 +238,7 @@ ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args)
case 'v':
vv = va_arg(args, ngx_variable_value_t *);
len = vv->len;
len = (buf + len < last) ? len : (size_t) (last - buf);
len = ngx_min(((size_t) (last - buf)), vv->len);
buf = ngx_cpymem(buf, vv->data, len);
fmt++;
@ -257,8 +253,7 @@ ngx_vslprintf(u_char *buf, u_char *last, const char *fmt, va_list args)
}
} else {
len = (buf + slen < last) ? slen : (size_t) (last - buf);
len = ngx_min(((size_t) (last - buf)), slen);
buf = ngx_cpymem(buf, p, len);
}

View File

@ -533,7 +533,7 @@ ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf,
ms = (ngx_msec_int_t)
((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec));
ms = (ms >= 0) ? ms : 0;
ms = ngx_max(ms, 0);
return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000);
}

View File

@ -3710,7 +3710,7 @@ ngx_http_upstream_response_time_variable(ngx_http_request_t *r,
if (state[i].status) {
ms = (ngx_msec_int_t)
(state[i].response_sec * 1000 + state[i].response_msec);
ms = (ms >= 0) ? ms : 0;
ms = ngx_max(ms, 0);
p = ngx_sprintf(p, "%d.%03d", ms / 1000, ms % 1000);
} else {