[PATCH] exception: Add missing string.h

Michal Simek michal.simek at amd.com
Fri Jul 25 14:41:52 CEST 2025


The commit 1e50f7457fca ("include/command.h: Drop <env.h>") removed env.h
which also included string.h which generate compilation error.
But because none is enabling CMD_EXCEPTION it by default it hasn't been
spot.

Signed-off-by: Michal Simek <michal.simek at amd.com>
---

  CC      drivers/mtd/mtd-uclass.o
In file included from cmd/riscv/exception.c:91:
include/exception.h: In function 'exception_complete':
include/exception.h:41:23: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
   41 |                 len = strlen(argv[1]);
      |                       ^~~~~~
include/exception.h:1:1: note: 'strlen' is defined in header '<string.h>'; this is probably fixable by adding '#include <string.h>'
  +++ |+#include <string.h>
    1 | /* SPDX-License-Identifier: GPL-2.0+ */
include/exception.h:49:22: error: implicit declaration of function 'strncmp' [-Wimplicit-function-declaration]
   49 |                 if (!strncmp(argv[1], cmdtp->name, len))
      |                      ^~~~~~~
include/exception.h:49:22: note: 'strncmp' is defined in header '<string.h>'; this is probably fixable by adding '#include <string.h>'
make[2]: *** [scripts/Makefile.build:297: cmd/riscv/exception.o] Error 1
make[2]: *** Waiting for unfinished jobs....
  CC      drivers/serial/serial-uclass.o

---
 include/exception.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/exception.h b/include/exception.h
index a7f21e73d753..0d4dff49954b 100644
--- a/include/exception.h
+++ b/include/exception.h
@@ -6,6 +6,7 @@
  */
 
 #include <command.h>
+#include <string.h>
 
 static int do_exception(struct cmd_tbl *cmdtp, int flag, int argc,
 			char *const argv[])
-- 
2.43.0

base-commit: 2aed9f720ab6fddcf49bdc361063e53451a7dddb
branch: debian-sent3


More information about the U-Boot mailing list