[PATCH v3 1/5] modpost: Use for() loop

Peter Zijlstra posted 5 patches 7 months, 2 weeks ago
[PATCH v3 1/5] modpost: Use for() loop
Posted by Peter Zijlstra 7 months, 2 weeks ago
Slight cleanup by using a for() loop instead of while(). This makes it
clearer what is the iteration and what is the actual work done.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 scripts/mod/modpost.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1595,12 +1595,10 @@ static void read_symbols(const char *mod
 			license = get_next_modinfo(&info, "license", license);
 		}
 
-		namespace = get_modinfo(&info, "import_ns");
-		while (namespace) {
+		for (namespace = get_modinfo(&info, "import_ns");
+		     namespace;
+		     namespace = get_next_modinfo(&info, "import_ns", namespace))
 			add_namespace(&mod->imported_namespaces, namespace);
-			namespace = get_next_modinfo(&info, "import_ns",
-						     namespace);
-		}
 
 		if (!get_modinfo(&info, "description"))
 			warn("missing MODULE_DESCRIPTION() in %s\n", modname);
Re: [PATCH v3 1/5] modpost: Use for() loop
Posted by Masahiro Yamada 7 months, 1 week ago
On Fri, May 2, 2025 at 11:25 PM Peter Zijlstra <peterz@infradead.org> wrote:
>
> Slight cleanup by using a for() loop instead of while(). This makes it
> clearer what is the iteration and what is the actual work done.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> ---
>  scripts/mod/modpost.c |    8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)

Applied to linux-kbuild.
Thanks.



> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1595,12 +1595,10 @@ static void read_symbols(const char *mod
>                         license = get_next_modinfo(&info, "license", license);
>                 }
>
> -               namespace = get_modinfo(&info, "import_ns");
> -               while (namespace) {
> +               for (namespace = get_modinfo(&info, "import_ns");
> +                    namespace;
> +                    namespace = get_next_modinfo(&info, "import_ns", namespace))
>                         add_namespace(&mod->imported_namespaces, namespace);
> -                       namespace = get_next_modinfo(&info, "import_ns",
> -                                                    namespace);
> -               }
>
>                 if (!get_modinfo(&info, "description"))
>                         warn("missing MODULE_DESCRIPTION() in %s\n", modname);
>
>


-- 
Best Regards
Masahiro Yamada