[PATCH] rtems-fdt / shell - Fix string truncation warning
chrisj at rtems.org
Thu Oct 15 19:13:10 UTC 2020
On 15/10/20 10:27 pm, Frank Kuehndel wrote:
> From: Frank Kühndel <frank.kuehndel at embedded-brains.de>
> The compiler warning was:
> ../../../cpukit/libmisc/rtems-fdt/rtems-fdt.c:267:5: warning:
> 'strncpy' specified bound depends on the length of the source argument
> 267 | strncpy(path, name, namelen);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> It turns out that the `strncpy()` nor the buffer `path` is needed when
> one uses `strncmp()` instead of `strcmp()`. This needs some change to
> the algorithm but has the advantage that `name` is never truncated
> to the size of the buffer `path`.
> rtems-fdt.c, rtems-fdt-shell.c and cpukit/include/rtems/rtems-fdt.h
> seem to be dead code.
We cannot tell this is as a user may depend on it. With this command I know
users on Zynq platforms that use FDT to map PL logic to drivers. The command is
very much in use and is used as a PS to PL testing method.
> They implement a shell command `fdt` but that
> command is not part of the shell nor of any macro in
It have been missed and needs be added. Adding something in shellconfig.h would
be a help.
More information about the devel