From f8dd9bc97d57183b0b03f1b44d2009f3fda50c38 Mon Sep 17 00:00:00 2001
From: Stefan Rueger <stefan.rueger@urclocks.com>
Date: Sat, 20 Aug 2022 14:08:04 +0100
Subject: [PATCH] Correct flash paged write for avrftdi.c

---
 src/avrftdi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/avrftdi.c b/src/avrftdi.c
index 315f23e8..dbeb9b16 100644
--- a/src/avrftdi.c
+++ b/src/avrftdi.c
@@ -1059,12 +1059,11 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
 	/* find a poll byte. We cannot poll a value of 0xff, so look
 	 * for a value != 0xff
 	 */
-	for(poll_index = addr+len-1; poll_index > addr-1; poll_index--)
+	for(poll_index = addr+len-1; (int) poll_index >= (int) addr; poll_index--)
 		if(m->buf[poll_index] != 0xff)
 			break;
 
-	if((poll_index < addr + len) && m->buf[poll_index] != 0xff)
-	{
+	if((int) poll_index >= (int) addr) {
 		buf_size = bufptr - buf;
 
 		if(verbose > TRACE)