[PATCH 6/8] net: fix build with CONFIG_SHELL_NONE
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri May 17 06:26:54 PDT 2024
Some common networking code like fastboot over UDP calls ifup_all(0) to
bring up all interfaces. ifup_all(0) in turn runs commands to execute
interface discovery scripts and source network configurations.
This leads to a link error, because run_command is not defined in a
CONFIG_SHELL_NONE build as it lacks CONFIG_COMMAND_SUPPORT.
Fix this by adding inline stubs that fail for run_command and friends.
This way ifup_all(0) will either fail if there is a script that should
be run, but couldn't or just succeed if there are no applicable scripts
anyway.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/command.h | 8 ++++++++
net/Kconfig | 1 -
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/command.h b/include/command.h
index 9226756cc00b..26e06077b071 100644
--- a/include/command.h
+++ b/include/command.h
@@ -15,6 +15,7 @@
#include <linux/compiler_types.h>
#include <linux/stddef.h>
#include <string.h>
+#include <errno.h>
#ifndef __ASSEMBLY__
@@ -49,10 +50,17 @@ extern struct command * const __barebox_cmd_end[];
/* common/command.c */
+#ifdef CONFIG_COMMAND_SUPPORT
struct command *find_cmd(const char *cmd);
int execute_command(int argc, char **argv);
void barebox_cmd_usage(struct command *cmdtp);
int run_command(const char *cmd);
+#else
+static inline struct command *find_cmd(const char *cmd) { return NULL; }
+static inline int execute_command(int argc, char **argv) { return -ENOSYS; }
+static inline void barebox_cmd_usage(struct command *cmdtp) {}
+static inline int run_command(const char *cmd) { return -ENOSYS; }
+#endif
#define COMMAND_SUCCESS 0
#define COMMAND_ERROR 1
diff --git a/net/Kconfig b/net/Kconfig
index 07e623670e22..c13ee8bb43d8 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -40,7 +40,6 @@ config NET_RESOLV
config NET_IFUP
default y
- depends on !SHELL_NONE
bool
config NET_DHCP
--
2.39.2
More information about the barebox
mailing list