This is an automated email from Gerrit.

"Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to 
Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8685

-- gerrit

commit 98fed3e3483a4e6b74c0af36e6b7de5f117d6385
Author: Antonio Borneo <borneo.anto...@gmail.com>
Date:   Tue Dec 31 17:01:41 2024 +0100

    transport: store the transports sorted by alphabetic name order
    
    While this operation has no real interest so far, it will be used
    later to avoid listing twice protocols with the same name.
    
    Change-Id: I59f3634830f94dc992d28863cf29d5d869726918
    Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com>

diff --git a/src/transport/transport.c b/src/transport/transport.c
index 013bf0b27a..833242bef5 100644
--- a/src/transport/transport.c
+++ b/src/transport/transport.c
@@ -55,7 +55,7 @@ static const char * const transport_name[] = {
        [TRANSPORT_SWIM]           = "swim",
 };
 
-/** List of transports registered in OpenOCD. */
+/** List of transports registered in OpenOCD, alphabetically sorted per name. 
*/
 static LIST_HEAD(transport_list);
 
 /**
@@ -178,8 +178,14 @@ int transport_register(struct transport *new_transport)
                LOG_ERROR("invalid transport %s",
                                  transport_name[new_transport->id]);
 
-       /* splice this into the list */
-       list_add(&new_transport->lh, &transport_list);
+       /* splice this into the list, sorted in alphabetic order */
+       list_for_each_entry(t, &transport_list, lh) {
+               if (strcmp(transport_name[t->id],
+                                  transport_name[new_transport->id]) >= 0)
+                       break;
+       }
+       list_add_tail(&new_transport->lh, &t->lh);
+
        LOG_DEBUG("register '%s' (ID %d)",
                          transport_name[new_transport->id], new_transport->id);
 

-- 

Reply via email to