]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-smtp: test-smtp-submit: Improved checking of delivered message.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 9 Sep 2017 10:22:47 +0000 (12:22 +0200)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Sat, 9 Sep 2017 10:22:51 +0000 (12:22 +0200)
This addresses a couple of scan-build "dead assignment" warnings.

src/lib-smtp/test-smtp-submit.c

index d3215c909e070bfc4fa5581a1f1dfb38ad80ae4c..01543f6c9e6abf7b171f6cc9a1b117b8bb7a78f7 100644 (file)
@@ -1992,20 +1992,18 @@ test_message_delivery(const char *message, const char *file)
        input = i_stream_create_file(file, (size_t)-1);
        while ((ret=i_stream_read_more(input, &data, &size)) > 0) {
                const unsigned char *mdata;
-               if (input->v_offset >= (uoff_t)msize ||
-                       (input->v_offset + (uoff_t)size) > (uoff_t)msize) {
-                       ret = -1;
+               test_assert(input->v_offset < (uoff_t)msize &&
+                       (input->v_offset + (uoff_t)size) <= (uoff_t)msize);
+               if (test_has_failed())
                        break;
-               }
                mdata = (const unsigned char *)message + input->v_offset;
-               if (memcmp(data, mdata, size) != 0) {
-                       ret = -1;
+               test_assert(memcmp(data, mdata, size) == 0);
+               if (test_has_failed())
                        break;
-               }
                i_stream_skip(input, size);
        }
 
-       test_out_reason("delivery",
+       test_out_reason("delivery", ret < 0 &&
                input->stream_errno == 0 &&
                i_stream_is_eof(input) &&
                input->v_offset == (uoff_t)msize,