summaryrefslogtreecommitdiff
path: root/kmodloader.c
diff options
context:
space:
mode:
authorNathan Hintz <nlhintz@hotmail.com>2017-02-21 05:14:24 +0000
committerFelix Fietkau <nbd@nbd.name>2017-02-21 14:07:38 +0100
commit8973576f21b2f9b1f21924460e1d8842e3e8d5ce (patch)
treee55d8db3f9eb7b5c041e1c027e4c96f7181df09e /kmodloader.c
parentfce9382b4b99178fdbd188bec098b9b085327fef (diff)
downloadubox-8973576f21b2f9b1f21924460e1d8842e3e8d5ce.tar.gz
kmodloader: fix not being able to find some modules
kmodloader is using slightly different criteria for ordering the AVL tree versus what it uses to traverse it. This sometimes results in not being able to find some modules. Reference: https://bugs.lede-project.org/index.php?do=details&task_id=443 Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
Diffstat (limited to 'kmodloader.c')
-rw-r--r--kmodloader.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/kmodloader.c b/kmodloader.c
index 465d3de..ac14bac 100644
--- a/kmodloader.c
+++ b/kmodloader.c
@@ -985,20 +985,23 @@ out:
return 0;
}
+static inline char weight(char c)
+{
+ return c == '_' ? '-' : c;
+}
+
static int avl_modcmp(const void *k1, const void *k2, void *ptr)
{
const char *s1 = k1;
const char *s2 = k2;
- while (*s1 && ((*s1 == *s2) ||
- ((*s1 == '_') && (*s2 == '-')) ||
- ((*s1 == '-') && (*s2 == '_'))))
+ while (*s1 && (weight(*s1) == weight(*s2)))
{
s1++;
s2++;
}
- return *(const unsigned char *)s1 - *(const unsigned char *)s2;
+ return (unsigned char)weight(*s1) - (unsigned char)weight(*s2);
}
int main(int argc, char **argv)