QtGui: port away from q(v)snprintf() and mark the module free of it
No format-string warnings here, thankfully. Change-Id: Ib901550ca5e532247635afd995d560dc81628863 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit b2b0a5df25c32c3c36c731e2f5ca092edc2c8385) Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>bb10
parent
33077559a2
commit
ffe4b7cc5b
|
|
@ -275,6 +275,7 @@ qt_internal_add_module(Gui
|
|||
QT_NO_CONTEXTLESS_CONNECT
|
||||
QT_NO_FOREACH
|
||||
QT_NO_USING_NAMESPACE
|
||||
QT_NO_QSNPRINTF
|
||||
QT_USE_NODISCARD_FILE_OPEN
|
||||
QT_QPA_DEFAULT_PLATFORM_NAME="${QT_QPA_DEFAULT_PLATFORM}"
|
||||
INCLUDE_DIRECTORIES
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@
|
|||
#include <qvariant.h>
|
||||
#include <private/qtools_p.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -167,11 +169,11 @@ static bool write_xbm_image(const QImage &sourceImage, QIODevice *device, const
|
|||
const auto msize = s.size() + 100;
|
||||
char *buf = new char[msize];
|
||||
|
||||
qsnprintf(buf, msize, "#define %s_width %d\n", s.data(), w);
|
||||
std::snprintf(buf, msize, "#define %s_width %d\n", s.data(), w);
|
||||
device->write(buf, qstrlen(buf));
|
||||
qsnprintf(buf, msize, "#define %s_height %d\n", s.data(), h);
|
||||
std::snprintf(buf, msize, "#define %s_height %d\n", s.data(), h);
|
||||
device->write(buf, qstrlen(buf));
|
||||
qsnprintf(buf, msize, "static char %s_bits[] = {\n ", s.data());
|
||||
std::snprintf(buf, msize, "static char %s_bits[] = {\n ", s.data());
|
||||
device->write(buf, qstrlen(buf));
|
||||
|
||||
if (image.format() != QImage::Format_MonoLSB)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@
|
|||
#include <quuid.h>
|
||||
#include <qxmlstream.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
|
||||
#ifndef QT_NO_COMPRESS
|
||||
|
|
@ -1750,30 +1751,30 @@ void QPdfEnginePrivate::writeInfo(const QDateTime &date)
|
|||
constexpr size_t formattedDateSize = 26;
|
||||
char formattedDate[formattedDateSize];
|
||||
const int year = qBound(0, d.year(), 9999); // ASN.1, max 4 digits
|
||||
auto printedSize = qsnprintf(formattedDate,
|
||||
formattedDateSize,
|
||||
"(D:%04d%02d%02d%02d%02d%02d",
|
||||
year,
|
||||
d.month(),
|
||||
d.day(),
|
||||
t.hour(),
|
||||
t.minute(),
|
||||
t.second());
|
||||
auto printedSize = std::snprintf(formattedDate,
|
||||
formattedDateSize,
|
||||
"(D:%04d%02d%02d%02d%02d%02d",
|
||||
year,
|
||||
d.month(),
|
||||
d.day(),
|
||||
t.hour(),
|
||||
t.minute(),
|
||||
t.second());
|
||||
const int offset = date.offsetFromUtc();
|
||||
const int hours = (offset / 60) / 60;
|
||||
const int mins = (offset / 60) % 60;
|
||||
if (offset < 0) {
|
||||
qsnprintf(formattedDate + printedSize,
|
||||
formattedDateSize - printedSize,
|
||||
"-%02d'%02d')", -hours, -mins);
|
||||
std::snprintf(formattedDate + printedSize,
|
||||
formattedDateSize - printedSize,
|
||||
"-%02d'%02d')", -hours, -mins);
|
||||
} else if (offset > 0) {
|
||||
qsnprintf(formattedDate + printedSize,
|
||||
formattedDateSize - printedSize,
|
||||
"+%02d'%02d')", hours, mins);
|
||||
std::snprintf(formattedDate + printedSize,
|
||||
formattedDateSize - printedSize,
|
||||
"+%02d'%02d')", hours, mins);
|
||||
} else {
|
||||
qsnprintf(formattedDate + printedSize,
|
||||
formattedDateSize - printedSize,
|
||||
"Z)");
|
||||
std::snprintf(formattedDate + printedSize,
|
||||
formattedDateSize - printedSize,
|
||||
"Z)");
|
||||
}
|
||||
|
||||
write("\n/CreationDate ");
|
||||
|
|
@ -2472,7 +2473,7 @@ void QPdfEnginePrivate::xprintf(const char* fmt, ...)
|
|||
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int bufsize = qvsnprintf(buf, msize, fmt, args);
|
||||
int bufsize = std::vsnprintf(buf, msize, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
if (Q_LIKELY(bufsize < msize)) {
|
||||
|
|
@ -2481,7 +2482,7 @@ void QPdfEnginePrivate::xprintf(const char* fmt, ...)
|
|||
// Fallback for abnormal cases
|
||||
QScopedArrayPointer<char> tmpbuf(new char[bufsize + 1]);
|
||||
va_start(args, fmt);
|
||||
bufsize = qvsnprintf(tmpbuf.data(), bufsize + 1, fmt, args);
|
||||
bufsize = std::vsnprintf(tmpbuf.data(), bufsize + 1, fmt, args);
|
||||
va_end(args);
|
||||
stream->writeRawData(tmpbuf.data(), bufsize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@
|
|||
#include <QtCore/private/qsystemerror_p.h>
|
||||
#include "qrhid3dhelpers_p.h"
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
using namespace Qt::StringLiterals;
|
||||
|
|
@ -4697,7 +4699,7 @@ bool QD3D11GraphicsPipeline::create()
|
|||
} else {
|
||||
QByteArray sem;
|
||||
sem.resize(16);
|
||||
qsnprintf(sem.data(), sem.size(), "TEXCOORD%d_", it->location() - matrixSlice);
|
||||
std::snprintf(sem.data(), sem.size(), "TEXCOORD%d_", it->location() - matrixSlice);
|
||||
matrixSliceSemantics.append(sem);
|
||||
desc.SemanticName = matrixSliceSemantics.last().constData();
|
||||
desc.SemanticIndex = UINT(matrixSlice);
|
||||
|
|
|
|||
|
|
@ -5703,7 +5703,7 @@ bool QD3D12GraphicsPipeline::create()
|
|||
} else {
|
||||
QByteArray sem;
|
||||
sem.resize(16);
|
||||
qsnprintf(sem.data(), sem.size(), "TEXCOORD%d_", it->location() - matrixSlice);
|
||||
std::snprintf(sem.data(), sem.size(), "TEXCOORD%d_", it->location() - matrixSlice);
|
||||
matrixSliceSemantics.append(sem);
|
||||
desc.SemanticName = matrixSliceSemantics.last().constData();
|
||||
desc.SemanticIndex = UINT(matrixSlice);
|
||||
|
|
|
|||
Loading…
Reference in New Issue