spirv-tools: Replace strncpy with memcpy
PATCH 1/1 spirv-tools: Replace strncpy with memcpy
Fixes warnings produced with gcc 11
Signed-off-by Khem Raj <[email protected]>
--- .../files/0001-fix-strncpy-bound-error.patch | 30 +++++++++++++++++++ .../spir/spirv-tools_2020.6.bb | 4 ++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-graphics/spir/files/0001-fix-strncpy-bound-error.patch
meta/recipes-graphics/spir/files/0001-fix-strncpy-bound-error.patch new file +30 -0
@@ -0,0 +1,30 @@ +From 1ba007583b83468494c4146bcb7267d863de6a7b Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Fri, 26 Feb 2021 23:54:10 -0800 +Subject: [PATCH] fix strncpy bound error + +This patch fixes the following error while using gcc 11 +error: 'char* __builtin_strncpy(char*, const char*, long unsigned int)' specified bound depends on the length of the source argument [-Werror=stringop-overflow=] + +Upstream-Status: Submitted [https://github.com/KhronosGroup/SPIRV-Tools/pull/4151] +Signed-off-by: Khem Raj <[email protected]> +--- + source/diagnostic.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/source/diagnostic.cpp b/source/diagnostic.cpp +index edc27c8fd..77c29d70c 100644 +--- a/source/diagnostic.cpp ++++ b/source/diagnostic.cpp +@@ -37,7 +37,7 @@ spv_diagnostic spvDiagnosticCreate(const spv_position position, + diagnostic->position = *position; + diagnostic->isTextSource = false; + memset(diagnostic->error, 0, length); +- strncpy(diagnostic->error, message, length); ++ memcpy(diagnostic->error, message, length); + return diagnostic; + } + +-- +2.30.1 +
meta/recipes-graphics/spir/spirv-tools_2020.6.bb +3 -1
@@ -7,7 +7,9 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" SRCREV = "b27b1afd12d05bf238ac7368bb49de73cd620a8e" -SRC_URI = "git://github.com/KhronosGroup/SPIRV-Tools.git" +SRC_URI = "git://github.com/KhronosGroup/SPIRV-Tools.git \ + file://0001-fix-strncpy-bound-error.patch \ + " UPSTREAM_CHECK_GITTAGREGEX = "^v(?P<pver>\d+(\.\d+)+)$" S = "${WORKDIR}/git"
Signature · 1 line
2.30.1
Quoted 30 lines · Khem Raj
Fixes warnings produced with gcc 11
Signed-off-by Khem Raj <[email protected]>--- .../files/0001-fix-strncpy-bound-error.patch | 30 +++++++++++++++++++ .../spir/spirv-tools_2020.6.bb | 4 ++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-graphics/spir/files/0001-fix-strncpy-bound-error.patchmeta/recipes-graphics/spir/files/0001-fix-strncpy-bound-error.patch new file +14
-0@@ -0,0 +1,30 @@ +From 1ba007583b83468494c4146bcb7267d863de6a7b Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Fri, 26 Feb 2021 23:54:10 -0800 +Subject: [PATCH] fix strncpy bound error + +This patch fixes the following error while using gcc 11 +error: 'char* __builtin_strncpy(char*, const char*, long unsigned int)' specified bound depends on the length of the source argument [-Werror=stringop-overflow=] + +Upstream-Status: Submitted [https://github.com/KhronosGroup/SPIRV-Tools/pull/4151] +Signed-off-by: Khem Raj <[email protected]> +--- + source/diagnostic.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) +
meta/recipes-graphics/spir/files/0001-fix-strncpy-bound-error.patch line 24
Quoted 10 lines
meta/recipes-graphics/spir/files/0001-fix-strncpy-bound-error.patch new file +10
-0+diff --git a/source/diagnostic.cpp b/source/diagnostic.cpp +index edc27c8fd..77c29d70c 100644 +--- a/source/diagnostic.cpp ++++ b/source/diagnostic.cpp +@@ -37,7 +37,7 @@ spv_diagnostic spvDiagnosticCreate(const spv_position position, + diagnostic->position = *position; + diagnostic->isTextSource = false; + memset(diagnostic->error, 0, length); +- strncpy(diagnostic->error, message, length); ++ memcpy(diagnostic->error, message, length);
The memset() should be removed too.
Quoted 27 lines
meta/recipes-graphics/spir/files/0001-fix-strncpy-bound-error.patch new file +6
-0+ return diagnostic; + } + +-- +2.30.1 +meta/recipes-graphics/spir/spirv-tools_2020.6.bb +3
-2@@ -7,7 +7,9 @@ LICENSE = "Apache-2.0" LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57" SRCREV = "b27b1afd12d05bf238ac7368bb49de73cd620a8e" -SRC_URI = "git://github.com/KhronosGroup/SPIRV-Tools.git" +SRC_URI = "git://github.com/KhronosGroup/SPIRV-Tools.git \ + file://0001-fix-strncpy-bound-error.patch \ + " UPSTREAM_CHECK_GITTAGREGEX = "^v(?P<pver>\d+(\.\d+)+)$" S = "${WORKDIR}/git" --2.30.1