Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memblock test: fix implicit declaration of function 'memparse'

Commit 1e4c64b71c9b ("mm/memblock: Add "reserve_mem" to reserved named
memory at boot up") introduce the usage of memparse(), which is not
defined in memblock test.

Add the definition and link it to fix the build.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Link: https://lore.kernel.org/r/20240806010319.29194-3-richard.weiyang@gmail.com
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

authored by

Wei Yang and committed by
Mike Rapoport (Microsoft)
a88cde57 9f76c2ad

+56 -1
+1
tools/include/linux/string.h
··· 47 47 extern char *strim(char *); 48 48 49 49 extern void *memchr_inv(const void *start, int c, size_t bytes); 50 + extern unsigned long long memparse(const char *ptr, char **retptr); 50 51 #endif /* _TOOLS_LINUX_STRING_H_ */
+53
tools/lib/cmdline.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * From lib/cmdline.c 4 + */ 5 + #include <stdlib.h> 6 + 7 + #if __has_attribute(__fallthrough__) 8 + # define fallthrough __attribute__((__fallthrough__)) 9 + #else 10 + # define fallthrough do {} while (0) /* fallthrough */ 11 + #endif 12 + 13 + unsigned long long memparse(const char *ptr, char **retptr) 14 + { 15 + char *endptr; /* local pointer to end of parsed string */ 16 + 17 + unsigned long long ret = strtoll(ptr, &endptr, 0); 18 + 19 + switch (*endptr) { 20 + case 'E': 21 + case 'e': 22 + ret <<= 10; 23 + fallthrough; 24 + case 'P': 25 + case 'p': 26 + ret <<= 10; 27 + fallthrough; 28 + case 'T': 29 + case 't': 30 + ret <<= 10; 31 + fallthrough; 32 + case 'G': 33 + case 'g': 34 + ret <<= 10; 35 + fallthrough; 36 + case 'M': 37 + case 'm': 38 + ret <<= 10; 39 + fallthrough; 40 + case 'K': 41 + case 'k': 42 + ret <<= 10; 43 + endptr++; 44 + fallthrough; 45 + default: 46 + break; 47 + } 48 + 49 + if (retptr) 50 + *retptr = endptr; 51 + 52 + return ret; 53 + }
+1 -1
tools/testing/memblock/Makefile
··· 8 8 TARGETS = main 9 9 TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \ 10 10 tests/basic_api.o tests/common.o tests/alloc_exact_nid_api.o 11 - DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o 11 + DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o cmdline.o 12 12 OFILES = main.o $(DEP_OFILES) $(TEST_OFILES) 13 13 EXTR_SRC = ../../../mm/memblock.c 14 14
+1
tools/testing/memblock/linux/kernel.h
··· 8 8 #include <linux/printk.h> 9 9 #include <linux/linkage.h> 10 10 #include <linux/kconfig.h> 11 + #include <linux/string.h> 11 12 12 13 #endif