[PATCH v3 12/29] dm: core: Add basic ACPI support

Simon Glass sjg at chromium.org
Thu Apr 9 00:15:39 CEST 2020


Hi Andy,

On Wed, 8 Apr 2020 at 11:02, Andy Shevchenko
<andriy.shevchenko at linux.intel.com> wrote:
>
> On Tue, Apr 07, 2020 at 08:57:24PM -0600, Simon Glass wrote:
> > On Fri, 3 Apr 2020 at 05:35, Andy Shevchenko
> > <andriy.shevchenko at linux.intel.com> wrote:
> > > On Mon, Mar 30, 2020 at 05:12:48PM -0600, Simon Glass wrote:
>
> ...
>
> > > > +     strncpy(out_name, name, ACPI_NAME_MAX);
> > >
> > > memcpy()?
> >
> > strcpy() seems better since it doesn't rely on the correct string in name.
>
> Definitely not. It has no boundary checks.
>
> > > > +     out_name[ACPI_NAME_LEN] = '\0';
> > >
> > > I dunno if compiler is clever enough to catch this and avoid any warnings.
> >
> > I don't see any warnings.
>
> strncpy() fine then.
>
> > > Also it seems above should also have _LEN, and not _MAX.
> >
> > Do you mean for the strncpy()? I could do that but I still want to set
> > the terminator to nul so that the string is definitely terminated.
>
> Terminator can be not present.
> I should be
>
>      strncpy(out_name, name, ACPI_NAME_LEN);
>      out_name[ACPI_NAME_LEN] = '\0';

Why? The code I have seems to work just fine?

Regards,
Simon


More information about the U-Boot mailing list