[xerces-c] branch master updated: Fix -Wmemset-transposed-args warnings of clang++

[email protected]
Newsgroups gmane.text.xml.xerces-c.devel
Message-ID <[email protected]>
This is an automated email from the ASF dual-hosted git repository.

rleigh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/xerces-c.git


The following commit(s) were added to refs/heads/master by this push:
     new dc3bd8f  Fix -Wmemset-transposed-args warnings of clang++
     new 4f5404b  Merge pull request #33 from rouault/fix_memset-transposed-args
dc3bd8f is described below

commit dc3bd8fd1bffc7c7d7ca37dc98036954921691ef
Author: Even Rouault <[email protected]>
AuthorDate: Fri Aug 27 23:46:48 2021 +0200

    Fix -Wmemset-transposed-args warnings of clang++
    
    Fixes:
    xercesc/util/XMLChTranscoder.cpp:73:23: warning: setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments? [-Wmemset-transposed-args]
        memset(charSizes, sizeof(XMLCh), countToDo);
                          ^
    xercesc/util/XMLChTranscoder.cpp:73:23: note: cast the second argument to 'int' to silence
    
    and
    
    xercesc/util/XMLUTF16Transcoder.cpp:114:23: warning: setting buffer to a 'sizeof' expression; did you mean to transpose the last two arguments? [-Wmemset-transposed-args]
        memset(charSizes, sizeof(UTF16Ch), countToDo);
                          ^
    xercesc/util/XMLUTF16Transcoder.cpp:114:23: note: cast the second argument to 'int' to silence
    1 warning generated.
---
 src/xercesc/util/XMLChTranscoder.cpp    | 2 +-
 src/xercesc/util/XMLUTF16Transcoder.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/xercesc/util/XMLChTranscoder.cpp b/src/xercesc/util/XMLChTranscoder.cpp
index 05b0692..8b57cc1 100644
--- a/src/xercesc/util/XMLChTranscoder.cpp
+++ b/src/xercesc/util/XMLChTranscoder.cpp
@@ -70,7 +70,7 @@ XMLChTranscoder::transcodeFrom( const   XMLByte* const          srcData
     bytesEaten = countToDo * sizeof(XMLCh);
 
     // Set the character sizes to the fixed size
-    memset(charSizes, sizeof(XMLCh), countToDo);
+    memset(charSizes, static_cast<int>(sizeof(XMLCh)), countToDo);
 
     // Return the chars we transcoded
     return countToDo;
diff --git a/src/xercesc/util/XMLUTF16Transcoder.cpp b/src/xercesc/util/XMLUTF16Transcoder.cpp
index 6d7f4f2..2233f8a 100644
--- a/src/xercesc/util/XMLUTF16Transcoder.cpp
+++ b/src/xercesc/util/XMLUTF16Transcoder.cpp
@@ -111,7 +111,7 @@ XMLUTF16Transcoder::transcodeFrom(  const   XMLByte* const       srcData
     bytesEaten = countToDo * sizeof(UTF16Ch);
 
     // Set the character sizes to the fixed size
-    memset(charSizes, sizeof(UTF16Ch), countToDo);
+    memset(charSizes, static_cast<int>(sizeof(UTF16Ch)), countToDo);
 
     // Return the chars we transcoded
     return countToDo;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.