]> 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)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 17 Aug 2016 15:23:26 +0000 (18:23 +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 784c7370b4789764da753e9e837637d2d967eaa2..5a39d1e6a3ad23e2c7c6cb10a3ebaf5681cbd9b4 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];