summaryrefslogtreecommitdiff
path: root/tools/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-06-18 11:29:41 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-06-18 15:08:26 +0200
commitde32eb539bbcf291f9968ae12696e1317fdb855d (patch)
tree29e7e06a1697946ccf7b76db85ed57c7e5ea91b3 /tools/source
parentb42ab78fb871924896b3cc38a7b2f1257151f711 (diff)
Avoid unhelpful -Werror=stringop-truncation
...emitted at least by recent GCC 11 trunk (even with --disable-optimized, where optimization level traditionally has some impact on what warnings of this kind are emitted exactly): > tools/source/misc/json_writer.cxx: In member function ‘tools::ScopedJsonWriterNode tools::JsonWriter::startNode(const char*)’: > tools/source/misc/json_writer.cxx:42:12: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 5 bytes from a string of the same length [-Werror=stringop-truncation] > 42 | strncpy(mPos, "\": { ", 5); > | ~~~~~~~^~~~~~~~~~~~~~~~~~~ etc. Change-Id: Id96964b178b61879cf2373c5b418f5c9df4a226f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96593 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Justin Luth <justin_luth@sil.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins
Diffstat (limited to 'tools/source')
-rw-r--r--tools/source/misc/json_writer.cxx10
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/source/misc/json_writer.cxx b/tools/source/misc/json_writer.cxx
index a233381038c4..12ff5eb37641 100644
--- a/tools/source/misc/json_writer.cxx
+++ b/tools/source/misc/json_writer.cxx
@@ -39,7 +39,7 @@ ScopedJsonWriterNode JsonWriter::startNode(const char* pNodeName)
++mPos;
memcpy(mPos, pNodeName, len);
mPos += len;
- strncpy(mPos, "\": { ", 5);
+ memcpy(mPos, "\": { ", 5);
mPos += 5;
mStartNodeCount++;
mbFirstFieldInNode = true;
@@ -66,7 +66,7 @@ void JsonWriter::put(const char* pPropName, const OUString& rPropVal)
++mPos;
memcpy(mPos, pPropName, nPropNameLength);
mPos += nPropNameLength;
- strncpy(mPos, "\": \"", 4);
+ memcpy(mPos, "\": \"", 4);
mPos += 4;
// Convert from UTF-16 to UTF-8 and perform escaping
@@ -125,7 +125,7 @@ void JsonWriter::put(const char* pPropName, const OString& rPropVal)
++mPos;
memcpy(mPos, pPropName, nPropNameLength);
mPos += nPropNameLength;
- strncpy(mPos, "\": \"", 4);
+ memcpy(mPos, "\": \"", 4);
mPos += 4;
// copy and perform escaping
@@ -169,7 +169,7 @@ void JsonWriter::put(const char* pPropName, const char* pPropVal)
++mPos;
memcpy(mPos, pPropName, nPropNameLength);
mPos += nPropNameLength;
- strncpy(mPos, "\": \"", 4);
+ memcpy(mPos, "\": \"", 4);
mPos += 4;
// copy and perform escaping
@@ -215,7 +215,7 @@ void JsonWriter::put(const char* pPropName, int nPropVal)
++mPos;
memcpy(mPos, pPropName, nPropNameLength);
mPos += nPropNameLength;
- strncpy(mPos, "\": ", 3);
+ memcpy(mPos, "\": ", 3);
mPos += 3;
mPos += sprintf(mPos, "%d", nPropVal);