From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Shevchenko Date: Wed, 8 Apr 2020 20:01:22 +0300 Subject: [PATCH v3 12/29] dm: core: Add basic ACPI support In-Reply-To: References: <20200330231305.130488-1-sjg@chromium.org> <20200330171226.v3.12.Ia5e9ba1f146567b18e9183395484bf04d2e5ba6a@changeid> <20200403113556.GS1922688@smile.fi.intel.com> Message-ID: <20200408170122.GJ3676135@smile.fi.intel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, Apr 07, 2020 at 08:57:24PM -0600, Simon Glass wrote: > On Fri, 3 Apr 2020 at 05:35, Andy Shevchenko > 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'; -- With Best Regards, Andy Shevchenko