[LEDE-DEV] [PATCH] kmodloader: fix not being able to find some modules

Yousong Zhou yszhou4tech at gmail.com
Mon Feb 20 19:28:21 PST 2017


On 21 February 2017 at 01:54, Nathan Hintz <nlhintz at hotmail.com> wrote:
> 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 at hotmail.com>
> ---
>  kmodloader.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/kmodloader.c b/kmodloader.c
> index 465d3de..8343836 100644
> --- a/kmodloader.c
> +++ b/kmodloader.c
> @@ -985,20 +985,23 @@ out:
>         return 0;
>  }
>
> +inline char weight(char c)
> +{
> +       return c == '_' ? '-' : c;
> +}

This should be marked as static.

> +
>  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);

This line seems to be the change and it makes sense, but I failed to
see how it will resolve the referred bug report.  Can you please give
an example to show the said subtle difference and how it will cause
issue?

Thanks,
                yousong


>  }
>
>  int main(int argc, char **argv)
> --
> 2.9.3
>
>
> _______________________________________________
> Lede-dev mailing list
> Lede-dev at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev



More information about the Lede-dev mailing list