From 01c8053dfbfdc1ca32ec46264bdee1e33cb50856 Mon Sep 17 00:00:00 2001 From: Yin Fengwei Date: Tue, 27 Mar 2018 21:43:23 +0800 Subject: [PATCH] DM: fix build error with gcc-8. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc8 showed following errors when build DM: error: argument to ‘sizeof’ in ‘strncpy’ call is the same expression as the source; did you mean to use the size of the destination? [-Werror=sizeof-pointer-memaccess] It looks like wrong parameter was given to strncpy. Signed-off-by: Yin Fengwei Acked-by: Anthony Xu --- devicemodel/hw/acpi/acpi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/devicemodel/hw/acpi/acpi.c b/devicemodel/hw/acpi/acpi.c index e1200b089..132657617 100644 --- a/devicemodel/hw/acpi/acpi.c +++ b/devicemodel/hw/acpi/acpi.c @@ -921,7 +921,7 @@ basl_make_templates(void) len--; basl_template[len] = '/'; strncpy(&basl_template[len + 1], ASL_TEMPLATE, - sizeof(ASL_TEMPLATE)); + MAXPATHLEN - len - 1); } else err = -1; @@ -934,10 +934,10 @@ basl_make_templates(void) strncpy(basl_stemplate, tmpdir, len); basl_stemplate[len] = '/'; strncpy(&basl_stemplate[len + 1], ASL_TEMPLATE, - sizeof(ASL_TEMPLATE)); + MAXPATHLEN - len - 1); len += sizeof(ASL_TEMPLATE); strncpy(&basl_stemplate[len], ASL_SUFFIX, - sizeof(ASL_SUFFIX)); + sizeof(ASL_TEMPLATE)); } else err = -1; }