[PATCH] rtems-fdt / shell - Fix string truncation warning
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Oct 15 12:09:37 UTC 2020
On 15/10/2020 13:27, 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`.
Does it help to use bsearch() to simplify this code further?
More information about the devel
mailing list