From 1297098eae5ee4a22c1139497c97ef21eac83cba Mon Sep 17 00:00:00 2001
From: Marius Greuel <greuelm@mgtek.com>
Date: Sun, 9 Jan 2022 11:50:35 +0100
Subject: [PATCH] When the specified part has a matching signature, print the
 specified part instead of one from the parts list

---
 src/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/main.c b/src/main.c
index 6fd432ec..1bc1d90f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1218,12 +1218,19 @@ int main(int argc, char * argv [])
         if (sig->buf[i] != 0x00)
           zz = 0;
       }
+
+      bool signature_matches =
+          sig->size == 3 &&
+          sig->buf[0] == p->signature[0] &&
+          sig->buf[1] == p->signature[1] &&
+          sig->buf[2] == p->signature[2];
+
       if (quell_progress < 2) {
         AVRPART * part;
 
         part = locate_part_by_signature(part_list, sig->buf, sig->size);
         if (part) {
-          avrdude_message(MSG_INFO, " (probably %s)", part->id);
+          avrdude_message(MSG_INFO, " (probably %s)", signature_matches ? p->id : part->id);
         }
       }
       if (ff || zz) {
@@ -1252,10 +1259,7 @@ int main(int argc, char * argv [])
         }
       }
 
-      if (sig->size != 3 ||
-          sig->buf[0] != p->signature[0] ||
-          sig->buf[1] != p->signature[1] ||
-          sig->buf[2] != p->signature[2]) {
+      if (!signature_matches) {
         avrdude_message(MSG_INFO, "%s: Expected signature for %s is %02X %02X %02X\n",
                         progname, p->desc,
                         p->signature[0], p->signature[1], p->signature[2]);