-Werror,-Wdeprecated-declarations (sprintf, macOS 13 SDK): tools

(The "clang-format off" in tools/source/misc/json_writer.cxx is necessary
because otherwise the code between the SAL_WNODEPRECATED_DECLARATIONS_PUSH/POP
macros would be ill-formatted in a way that would trigger loplugin:indentation.)

Change-Id: Ic96787865d4c96be07c41f4939893420dfa04046
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142339
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
Stephan Bergmann
2022-11-05 16:08:39 +01:00
parent 5cbc205281
commit 4280a32579
4 changed files with 13 additions and 10 deletions

View File

@ -23,6 +23,7 @@
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include <rtl/character.hxx> #include <rtl/character.hxx>
#include <o3tl/safeint.hxx> #include <o3tl/safeint.hxx>
#include <o3tl/sprintf.hxx>
#include <o3tl/string_view.hxx> #include <o3tl/string_view.hxx>
#include <map> #include <map>
@ -265,7 +266,7 @@ void INetMIMEMessage::EnableAttachMultipartFormDataChild()
tools::Time aCurTime( tools::Time::SYSTEM ); tools::Time aCurTime( tools::Time::SYSTEM );
sal_uInt64 nThis = reinterpret_cast< sal_uIntPtr >( this ); // we can be on a 64bit architecture sal_uInt64 nThis = reinterpret_cast< sal_uIntPtr >( this ); // we can be on a 64bit architecture
nThis = ( ( nThis >> 32 ) ^ nThis ) & SAL_MAX_UINT32; nThis = ( ( nThis >> 32 ) ^ nThis ) & SAL_MAX_UINT32;
sprintf (sTail, "%08X%08X", o3tl::sprintf (sTail, "%08X%08X",
static_cast< unsigned int >(aCurTime.GetTime()), static_cast< unsigned int >(aCurTime.GetTime()),
static_cast< unsigned int >(nThis)); static_cast< unsigned int >(nThis));
m_aBoundary = "------------_4D48"; m_aBoundary = "------------_4D48";

View File

@ -326,7 +326,11 @@ void JsonWriter::put(const char* pPropName, sal_Int64 nPropVal)
memcpy(mPos, "\": ", 3); memcpy(mPos, "\": ", 3);
mPos += 3; mPos += 3;
// clang-format off
SAL_WNODEPRECATED_DECLARATIONS_PUSH // sprintf (macOS 13 SDK)
mPos += sprintf(mPos, "%" SAL_PRIdINT64, nPropVal); mPos += sprintf(mPos, "%" SAL_PRIdINT64, nPropVal);
SAL_WNODEPRECATED_DECLARATIONS_POP
// clang-format on
validate(); validate();
} }

View File

@ -17,10 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 . * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/ */
#include <stdio.h>
#include <string.h> #include <string.h>
#include <comphelper/mimeconfighelper.hxx> #include <comphelper/mimeconfighelper.hxx>
#include <o3tl/sprintf.hxx>
#include <rtl/character.hxx> #include <rtl/character.hxx>
#include <tools/stream.hxx> #include <tools/stream.hxx>
@ -153,7 +153,7 @@ bool SvGlobalName::MakeId( std::u16string_view rIdStr )
OUString SvGlobalName::GetHexName() const OUString SvGlobalName::GetHexName() const
{ {
char buf[ 37 ]; char buf[ 37 ];
int n = sprintf(buf, int n = o3tl::sprintf(buf,
"%8.8" SAL_PRIXUINT32 "-%4.4X-%4.4X-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x", "%8.8" SAL_PRIXUINT32 "-%4.4X-%4.4X-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
m_aData.Data1, m_aData.Data2, m_aData.Data3, m_aData.Data1, m_aData.Data2, m_aData.Data3,
m_aData.Data4[0], m_aData.Data4[1], m_aData.Data4[2], m_aData.Data4[3], m_aData.Data4[0], m_aData.Data4[1], m_aData.Data4[2], m_aData.Data4[3],

View File

@ -26,12 +26,12 @@
#include <memory> #include <memory>
#include <string.h> #include <string.h>
#include <stdio.h>
#include <o3tl/safeint.hxx> #include <o3tl/safeint.hxx>
#include <osl/endian.h> #include <osl/endian.h>
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <rtl/strbuf.hxx> #include <rtl/strbuf.hxx>
#include <rtl/string.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <sal/log.hxx> #include <sal/log.hxx>
#include <tools/long.hxx> #include <tools/long.hxx>
@ -1361,17 +1361,15 @@ void SvStream::RefreshBuffer()
SvStream& SvStream::WriteInt32AsString(sal_Int32 nInt32) SvStream& SvStream::WriteInt32AsString(sal_Int32 nInt32)
{ {
char buffer[12]; auto const buffer = OString::number(nInt32);
std::size_t nLen = sprintf(buffer, "%" SAL_PRIdINT32, nInt32); WriteBytes(buffer.getStr(), buffer.length);
WriteBytes(buffer, nLen);
return *this; return *this;
} }
SvStream& SvStream::WriteUInt32AsString(sal_uInt32 nUInt32) SvStream& SvStream::WriteUInt32AsString(sal_uInt32 nUInt32)
{ {
char buffer[11]; auto const buffer = OString::number(nUInt32);
std::size_t nLen = sprintf(buffer, "%" SAL_PRIuUINT32, nUInt32); WriteBytes(buffer.getStr(), buffer.length);
WriteBytes(buffer, nLen);
return *this; return *this;
} }