From 68c6ffd7fce336548d4113fe4f071c572d138a89 Mon Sep 17 00:00:00 2001
From: Stefan Rueger <stefan.rueger@urclocks.com>
Date: Thu, 24 Nov 2022 12:14:54 +0000
Subject: [PATCH] Silence compiler warnings, change comments, remove typos

---
 src/avrcache.c   | 9 ++++++---
 src/libavrdude.h | 2 +-
 src/update.c     | 3 +--
 src/urclock.c    | 4 ++--
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/avrcache.c b/src/avrcache.c
index cca15483..638ac46f 100644
--- a/src/avrcache.c
+++ b/src/avrcache.c
@@ -135,6 +135,9 @@ int avr_has_paged_access(const PROGRAMMER *pgm, const AVRMEM *mem) {
  *   - Part memory buffer mem is unaffected by this (though temporarily changed)
  *   - Uses read_byte() if memory page size is one, otherwise paged_load()
  *   - Fall back to bytewise read if paged_load() returned an error
+ *   - On failure returns a negative value, on success a non-negative value, which is either
+ *       + The number of bytes read by pgm->paged_load() if that succeeded
+ *       + LIBAVRDUDE_SUCCESS (0) if the fallback of bytewise read succeeded
  */
 int avr_read_page_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, int addr, unsigned char *buf) {
   if(!avr_has_paged_access(pgm, mem) || addr < 0 || addr >= mem->size)
@@ -643,8 +646,8 @@ int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
 // Erase the chip and set the cache accordingly
 int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p) {
   CacheDesc_t mems[2] = {
-    { avr_locate_mem(p, "flash"), pgm->cp_flash, 1 },
-    { avr_locate_mem(p, "eeprom"), pgm->cp_eeprom, 0 },
+    { avr_locate_mem(p, "flash"), pgm->cp_flash, 1, -1, 0 },
+    { avr_locate_mem(p, "eeprom"), pgm->cp_eeprom, 0, -1, 0 },
   };
   int rc;
 
@@ -740,7 +743,7 @@ int avr_page_erase_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
 
 
 // Free cache(s) discarding any pending writes
-int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p) {
+int avr_reset_cache(const PROGRAMMER *pgm, const AVRPART *p_unused) {
   AVR_Cache *mems[2] = { pgm->cp_flash, pgm->cp_eeprom, };
 
   for(size_t i = 0; i < sizeof mems/sizeof*mems; i++) {
diff --git a/src/libavrdude.h b/src/libavrdude.h
index 83556af3..f21bbc9e 100644
--- a/src/libavrdude.h
+++ b/src/libavrdude.h
@@ -922,7 +922,7 @@ int avr_write_page_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
 
 int avr_is_and(const unsigned char *s1, const unsigned char *s2, const unsigned char *s3, size_t n);
 
-// byte-wise cached read/write API
+// Bytewise cached read/write API
 int avr_read_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char *value);
 int avr_write_byte_cached(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem, unsigned long addr, unsigned char data);
 int avr_chip_erase_cached(const PROGRAMMER *pgm, const AVRPART *p);
diff --git a/src/update.c b/src/update.c
index 0a7166cd..0afcd9ea 100644
--- a/src/update.c
+++ b/src/update.c
@@ -560,8 +560,7 @@ int do_op(const PROGRAMMER *pgm, const AVRPART *p, UPDATE *upd, enum updateflags
     pmsg_info("%d byte%s of %s%s written\n", fs.nbytes,
       update_plural(fs.nbytes), mem->desc, alias_mem_desc);
 
-    // Fall through for (default) auto verify, ie, unless -V was specified
-    if (!(flags & UF_VERIFY))
+    if (!(flags & UF_VERIFY))   // Fall through for auto verify unless -V was specified
       break;
 
   case DEVICE_VERIFY:
diff --git a/src/urclock.c b/src/urclock.c
index 7bfb2d7f..c15cc665 100644
--- a/src/urclock.c
+++ b/src/urclock.c
@@ -2260,14 +2260,14 @@ static int urclock_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVR
 int urclock_write_byte(const PROGRAMMER *pgm_uu, const AVRPART *p_uu, const AVRMEM *mem,
   unsigned long addr_uu, unsigned char data_uu) {
 
-  pmsg_error("bootloader does not implement byte-wise write to %s \n", mem->desc);
+  pmsg_error("bootloader does not implement bytewise write to %s \n", mem->desc);
   return -1;
 }
 
 int urclock_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
   unsigned long addr, unsigned char *value) {
 
-  // Byte-wise read only valid for flash and eeprom
+  // Bytewise read only valid for flash and eeprom
   int mchr = avr_mem_is_flash_type(mem)? 'F': 'E';
   if(mchr == 'E' && !avr_mem_is_eeprom_type(mem)) {
     if(!strcmp(mem->desc, "signature") && pgm->read_sig_bytes) {