]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cache: Remove useless test for nonzero.
authorOlivier Houchard <cognet@ci0.org>
Wed, 1 Nov 2017 12:58:21 +0000 (13:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 1 Nov 2017 14:10:51 +0000 (15:10 +0100)
Don't bother testing if len is nonzero, we know it is, as we're in the
"else" part of a if (!len), and testing it confuses clang into thinking
ret may be left uninitialized.

src/cache.c

index 8019ef1fff94c26ad5148e7343cf31ec59fd3cf2..4263c91557fa19cbdea56d9e3ac62e53e58c7546 100644 (file)
@@ -173,29 +173,27 @@ cache_store_http_forward_data(struct stream *s, struct filter *filter,
        }
        else {
                /* Forward trailers data */
-               if (len) {
-                       if (filter->ctx && st->first_block) {
-                               /* disable buffering if too much data (never greater than a buffer size */
-                               if (len > global.tune.bufsize - global.tune.maxrewrite - st->first_block->len) {
-                                       filter->ctx = NULL; /* disable cache  */
-                                       shctx_lock(shctx);
-                                       shctx_row_dec_hot(shctx, st->first_block);
-                                       shctx_unlock(shctx);
-                                       pool_free2(pool2_cache_st, st);
-                                       ret = 0;
-                               } else {
+               if (filter->ctx && st->first_block) {
+                       /* disable buffering if too much data (never greater than a buffer size */
+                       if (len > global.tune.bufsize - global.tune.maxrewrite - st->first_block->len) {
+                               filter->ctx = NULL; /* disable cache  */
+                               shctx_lock(shctx);
+                               shctx_row_dec_hot(shctx, st->first_block);
+                               shctx_unlock(shctx);
+                               pool_free2(pool2_cache_st, st);
+                               ret = 0;
+                       } else {
 
-                                       int blen;
-                                       blen = shctx_row_data_append(shctx,
-                                                                st->first_block,
-                                                                (unsigned char *)bi_ptr(msg->chn->buf),
-                                                                MIN(bi_contig_data(msg->chn->buf), len));
+                               int blen;
+                               blen = shctx_row_data_append(shctx,
+                                   st->first_block,
+                                   (unsigned char *)bi_ptr(msg->chn->buf),
+                                   MIN(bi_contig_data(msg->chn->buf), len));
 
-                                       ret = MIN(bi_contig_data(msg->chn->buf), len) + blen;
-                               }
-                       } else {
-                               ret = len;
+                               ret = MIN(bi_contig_data(msg->chn->buf), len) + blen;
                        }
+               } else {
+                       ret = len;
                }
        }