[PATCH -next] coredump: fix unused-function warning

From: Ren Zhijie
Date: Sun Oct 09 2022 - 05:28:48 EST


If CONFIG_ELF_CORE is not set,
gcc warns about unused function:

fs/coredump.c:839:12: error: ‘dump_emit_page’ defined but not used [-Werror=unused-function]
static int dump_emit_page(struct coredump_params *cprm, struct page *page)
^~~~~~~~~~~~~~
cc1: all warnings being treated as errors

dump_emit_page() only be called by dump_user_range(),
so move it under the CONFIG_ELF_CORE.

Fixes: 06bbaa6dc53c ("[coredump] don't use __kernel_write() on kmap_local_page()")
Signed-off-by: Ren Zhijie <renzhijie2@xxxxxxxxxx>
---
fs/coredump.c | 48 ++++++++++++++++++++++++------------------------
1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/fs/coredump.c b/fs/coredump.c
index 3e8630c8d627..dc1cb8440bc9 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -836,6 +836,30 @@ static int __dump_skip(struct coredump_params *cprm, size_t nr)
}
}

+int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
+{
+ if (cprm->to_skip) {
+ if (!__dump_skip(cprm, cprm->to_skip))
+ return 0;
+ cprm->to_skip = 0;
+ }
+ return __dump_emit(cprm, addr, nr);
+}
+EXPORT_SYMBOL(dump_emit);
+
+void dump_skip_to(struct coredump_params *cprm, unsigned long pos)
+{
+ cprm->to_skip = pos - cprm->pos;
+}
+EXPORT_SYMBOL(dump_skip_to);
+
+void dump_skip(struct coredump_params *cprm, size_t nr)
+{
+ cprm->to_skip += nr;
+}
+EXPORT_SYMBOL(dump_skip);
+
+#ifdef CONFIG_ELF_CORE
static int dump_emit_page(struct coredump_params *cprm, struct page *page)
{
struct bio_vec bvec = {
@@ -869,30 +893,6 @@ static int dump_emit_page(struct coredump_params *cprm, struct page *page)
return 1;
}

-int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
-{
- if (cprm->to_skip) {
- if (!__dump_skip(cprm, cprm->to_skip))
- return 0;
- cprm->to_skip = 0;
- }
- return __dump_emit(cprm, addr, nr);
-}
-EXPORT_SYMBOL(dump_emit);
-
-void dump_skip_to(struct coredump_params *cprm, unsigned long pos)
-{
- cprm->to_skip = pos - cprm->pos;
-}
-EXPORT_SYMBOL(dump_skip_to);
-
-void dump_skip(struct coredump_params *cprm, size_t nr)
-{
- cprm->to_skip += nr;
-}
-EXPORT_SYMBOL(dump_skip);
-
-#ifdef CONFIG_ELF_CORE
int dump_user_range(struct coredump_params *cprm, unsigned long start,
unsigned long len)
{
--
2.17.1