diff options
author | Burt P <pburt0@gmail.com> | 2018-05-11 21:00:59 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2018-05-27 15:12:47 -0700 |
commit | 2416abc367513f0277b66556b3c499e7bc9cf01e (patch) | |
tree | 7b3497f5a5720ced9e53e665575257b103001ed8 /hardinfo/vendor.c | |
parent | 1064148713b2e6984e0e5d2926ce2853a6aa96d2 (diff) |
vendor.c: fix vendor sort
Fix a really stupid sort function I wrote for 60b9f3360930296c0f3e8b04672b8bf7468bedcb.
Now actually does what that commit claims to do.
I think I must have just sketched it out and then forgot to go back and correct it. It's
weird that it happened to fix the one result I was testing for.
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'hardinfo/vendor.c')
-rw-r--r-- | hardinfo/vendor.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/hardinfo/vendor.c b/hardinfo/vendor.c index 86705e10..f73781c3 100644 --- a/hardinfo/vendor.c +++ b/hardinfo/vendor.c @@ -121,11 +121,12 @@ static GSList *vendor_list = NULL; /* sort the vendor list by length of match_string, * LONGEST first */ gint vendor_sort (gconstpointer a, gconstpointer b) { + const Vendor *ap = a, *bp = b; int la = 0, lb = 0; - if (a) la = strlen(a); - if (b) lb = strlen(b); - if (a == b) return 0; - if (a > b) return -1; + if (ap && ap->match_string) la = strlen(ap->match_string); + if (bp && bp->match_string) lb = strlen(bp->match_string); + if (la == lb) return 0; + if (la > lb) return -1; return 1; } |