lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 14 Jul 2015 14:59:12 +0800
From:	Minfei Huang <mhuang@...hat.com>
To:	akpm@...ux-foundation.org, rob.jones@...ethink.co.uk,
	amhyung@...nel.org, rusty@...tcorp.com.au
Cc:	linux-kernel@...r.kernel.org, Minfei Huang <mnfhuang@...il.com>
Subject: [PATCH 1/2] Define find_symbol_in_section_t as function type to simplify the code

From: Minfei Huang <mnfhuang@...il.com>

It is not elegance, if we use function directly as the argument, like
following:

bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
                                   struct module *owner,
                                   void *data), void *data);

Here introduce a type defined function find_symbol_in_section_t. Now
we can use these type defined function directly, if we want to pass
the function as the argument.

bool each_symbol_section(find_symbol_in_section_t fn, void *data);

Signed-off-by: Minfei Huang <mnfhuang@...il.com>
---
 include/linux/module.h | 6 +++---
 kernel/module.c        | 9 ++-------
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/include/linux/module.h b/include/linux/module.h
index d67b193..1e125b1 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -462,14 +462,14 @@ const struct kernel_symbol *find_symbol(const char *name,
 					bool gplok,
 					bool warn);
 
+typedef bool (*find_symbol_in_section_t)(const struct symsearch *arr,
+		struct module *owner, void *data);
 /*
  * Walk the exported symbol table
  *
  * Must be called with module_mutex held or preemption disabled.
  */
-bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
-				    struct module *owner,
-				    void *data), void *data);
+bool each_symbol_section(find_symbol_in_section_t fn, void *data);
 
 /* Returns 0 and fills in value, defined and namebuf, or -ERANGE if
    symnum out of range. */
diff --git a/kernel/module.c b/kernel/module.c
index 4d2b82e..1400c0b 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -426,9 +426,7 @@ extern const unsigned long __start___kcrctab_unused_gpl[];
 static bool each_symbol_in_section(const struct symsearch *arr,
 				   unsigned int arrsize,
 				   struct module *owner,
-				   bool (*fn)(const struct symsearch *syms,
-					      struct module *owner,
-					      void *data),
+				   find_symbol_in_section_t fn,
 				   void *data)
 {
 	unsigned int j;
@@ -442,10 +440,7 @@ static bool each_symbol_in_section(const struct symsearch *arr,
 }
 
 /* Returns true as soon as fn returns true, otherwise false. */
-bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
-				    struct module *owner,
-				    void *data),
-			 void *data)
+bool each_symbol_section(find_symbol_in_section_t fn, void *data)
 {
 	struct module *mod;
 	static const struct symsearch arr[] = {
-- 
2.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ