export: avoid code duplication in include/linux/export.h
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 18 Oct 2019 09:31:43 +0000 (10:31 +0100)
committerJessica Yu <jeyu@kernel.org>
Mon, 28 Oct 2019 15:38:26 +0000 (16:38 +0100)
commitc3a6cf19e695c8b0a9bf8b5933f863e12d878b7c
tree5733c9d42072a1c2974669d2890eef0da490a391
parentd6d5df1db6e9d7f8f76d2911707f7d5877251b02
export: avoid code duplication in include/linux/export.h

include/linux/export.h has lots of code duplication between
EXPORT_SYMBOL and EXPORT_SYMBOL_NS.

To improve the maintainability and readability, unify the
implementation.

When the symbol has no namespace, pass the empty string "" to
the 'ns' parameter.

The drawback of this change is, it grows the code size.
When the symbol has no namespace, sym->namespace was previously
NULL, but it is now an empty string "". So, it increases 1 byte
for every no namespace EXPORT_SYMBOL.

A typical kernel configuration has 10K exported symbols, so it
increases 10KB in rough estimation.

I did not come up with a good idea to refactor it without increasing
the code size.

I am not sure how big a deal it is, but at least include/linux/export.h
looks nicer.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
[maennich: rebase on top of 3 fixes for the namespace feature]
Signed-off-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
include/linux/export.h
kernel/module.c