changeset 20654:afabdcf82622

lib-index: Do not do pointless memmove Makes static analysers happier, since moving the data when days is 0 or days is 8 is effectively non-op.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Tue, 16 Aug 2016 13:44:27 +0300
parents a90a7cb50997
children d53cb89c7ca8
files src/lib-index/mail-index-transaction-update.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction-update.c	Tue Aug 16 13:31:48 2016 +0300
+++ b/src/lib-index/mail-index-transaction-update.c	Tue Aug 16 13:44:27 2016 +0300
@@ -146,8 +146,9 @@
 
 	/* @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];