]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-index: Do not do pointless memmove
authorAki Tuomi <aki.tuomi@dovecot.fi>
Tue, 16 Aug 2016 10:44:27 +0000 (13:44 +0300)
committerGitLab <gitlab@git.dovecot.net>
Tue, 16 Aug 2016 19:12:11 +0000 (22:12 +0300)
Makes static analysers happier, since moving the data
when days is 0 or days is 8 is effectively non-op.

src/lib-index/mail-index-transaction-update.c

index 5b151ebca6aee30dd81b408295528fea15943862..38678f446b6741846ecbc3ddb3a6ec97833d3ffe 100644 (file)
@@ -146,8 +146,9 @@ void mail_index_update_day_headers(struct mail_index_transaction *t)
 
        /* @UNSAFE: move days forward and fill the missing days with old
           day_first_uid[0]. */
-       memmove(hdr.day_first_uid + days, hdr.day_first_uid,
-               (max_days - days) * sizeof(hdr.day_first_uid[0]));
+       if (days > 1 && days < max_days)
+               memmove(hdr.day_first_uid + days, hdr.day_first_uid,
+                       (max_days - days) * sizeof(hdr.day_first_uid[0]));
        for (i = 1; i < days; i++)
                hdr.day_first_uid[i] = hdr.day_first_uid[0];