[PATCH] rtems-fdt / shell - Fix string truncation warning

Joel Sherrill joel at rtems.org
Thu Oct 15 20:24:32 UTC 2020


On Thu, Oct 15, 2020 at 2:13 PM Chris Johns <chrisj at rtems.org> wrote:

> 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`.
> >
> > Note:
> >
> > 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
> > cpukit/include/rtems/shellconfig.h.
>
> It have been missed and needs be added. Adding something in shellconfig.h
> would
> be a help.
>

Does that mean it also is not in the Shell manual?

--joel

>
> Thanks
> Chris
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20201015/6db5a0cb/attachment-0001.html>


More information about the devel mailing list