From bace4364e8a7d0ac261e407732b9354d2f017045 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 6 Sep 2009 14:29:47 -0700 Subject: http: cleanup and avoid potential signedness warning Just pass the http_parser struct pointer when checking for invalid headers in the trailer. The compiler should be smart enough to inline and not relookup the flags. This avoids having to worry about the flags being signed or not (they should never be) and also makes it easier to maintain if we move away from using bitfields. --- ext/unicorn_http/unicorn_http.rl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ext') diff --git a/ext/unicorn_http/unicorn_http.rl b/ext/unicorn_http/unicorn_http.rl index 7a0c02d..063b326 100644 --- a/ext/unicorn_http/unicorn_http.rl +++ b/ext/unicorn_http/unicorn_http.rl @@ -88,9 +88,9 @@ http_version(struct http_parser *hp, VALUE req, const char *ptr, size_t len) rb_hash_aset(req, g_http_version, v); } -static void invalid_if_trailer(int flags) +static inline void hp_invalid_if_trailer(struct http_parser *hp) { - if (flags & UH_FL_INTRAILER) + if (hp->flags & UH_FL_INTRAILER) rb_raise(eHttpParserError, "invalid Trailer"); } @@ -143,14 +143,14 @@ static void write_value(VALUE req, struct http_parser *hp, if (hp->len.content < 0) rb_raise(eHttpParserError, "invalid Content-Length"); hp->flags |= UH_FL_HASBODY; - invalid_if_trailer(hp->flags); + hp_invalid_if_trailer(hp); } else if (f == g_http_transfer_encoding) { if (STR_CSTR_CASE_EQ(v, "chunked")) hp->flags |= UH_FL_CHUNKED | UH_FL_HASBODY; - invalid_if_trailer(hp->flags); + hp_invalid_if_trailer(hp); } else if (f == g_http_trailer) { hp->flags |= UH_FL_HASTRAILER; - invalid_if_trailer(hp->flags); + hp_invalid_if_trailer(hp); } e = rb_hash_aref(req, f); -- cgit v1.2.3-24-ge0c7