x11-libs/qt: delete old extraversions, rebase to current portage ebuilds.
[gentoo-soor-overlay.git] / x11-libs / qt / files / 0185-fix-format-strings.diff
blobeed38b4785fa6cf9a47308038738116a6023db2c
1 qt-bugs@ issue : N171087
2 Trolltech task ID :
3 bugs.kde.org number :
4 applied: no
5 author: Dirk Mueller <mueller@kde.org>
7 This patch fixes various code issues with handling format strings
8 None of them seem to be exceptionally bad, but its better safe
9 than sorry.
12 --- src/corelib/global/qglobal.h
13 +++ src/corelib/global/qglobal.h
14 @@ -1266,8 +1266,16 @@ Q_CORE_EXPORT void qFatal(const char *,
15 #ifdef QT3_SUPPORT
16 Q_CORE_EXPORT QT3_SUPPORT void qSystemWarning(const char *msg, int code = -1);
17 #endif /* QT3_SUPPORT */
18 -Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...);
19 -Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...);
20 +Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...)
21 +#if defined(Q_CC_GNU) && !defined(__INSURE__)
22 + __attribute__ ((format (printf, 2, 3)))
23 +#endif
24 + ;
25 +Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...)
26 +#if defined(Q_CC_GNU) && !defined(__INSURE__)
27 + __attribute__ ((format (printf, 1, 2)))
28 +#endif
29 + ;
31 #if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM)
32 #define QT_NO_DEBUG_STREAM
33 --- src/corelib/tools/qbytearray.h
34 +++ src/corelib/tools/qbytearray.h
35 @@ -71,8 +71,16 @@ Q_CORE_EXPORT int qstricmp(const char *,
36 Q_CORE_EXPORT int qstrnicmp(const char *, const char *, uint len);
38 // implemented in qvsnprintf.cpp
39 -Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap);
40 -Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...);
41 +Q_CORE_EXPORT int qvsnprintf(char *str, size_t n, const char *fmt, va_list ap)
42 +#if defined(Q_CC_GNU) && !defined(__INSURE__)
43 + __attribute__ ((format (printf, 3, 0)))
44 +#endif
45 + ;
46 +Q_CORE_EXPORT int qsnprintf(char *str, size_t n, const char *fmt, ...)
47 +#if defined(Q_CC_GNU) && !defined(__INSURE__)
48 + __attribute__ ((format (printf, 3, 4)))
49 +#endif
50 + ;
52 #ifdef QT3_SUPPORT
53 inline QT3_SUPPORT void *qmemmove(void *dst, const void *src, uint len)
54 --- src/gui/painting/qprintengine_pdf_p.h
55 +++ src/gui/painting/qprintengine_pdf_p.h
56 @@ -148,7 +148,11 @@ private:
57 void writePage();
59 int addXrefEntry(int object, bool printostr = true);
60 - void xprintf(const char* fmt, ...);
61 + void xprintf(const char* fmt, ...)
62 +#if defined(Q_CC_GNU) && !defined(__INSURE__)
63 + __attribute__ ((format (printf, 2, 3)))
64 +#endif
65 + ;
66 inline void write(const QByteArray &data) {
67 stream->writeRawData(data.constData(), data.size());
68 streampos += data.size();
69 --- src/gui/painting/qprintengine_pdf.cpp
70 +++ src/gui/painting/qprintengine_pdf.cpp
71 @@ -386,9 +386,8 @@ int QPdfEnginePrivate::addConstantAlphaO
72 object = addXrefEntry(-1);
73 QByteArray alphaDef;
74 QPdf::ByteStream s(&alphaDef);
75 - s << "<< /ca " << (alpha/qreal(255.)) << ">>\n";
76 - xprintf(alphaDef.constData());
77 - xprintf("endobj\n");
78 + s << "<< /ca " << (alpha/qreal(255.)) << ">>";
79 + xprintf("%s\nendobj\n", alphaDef.constData());
81 currentPage->graphicStates.append(object);
82 return object;
83 --- src/qt3support/tools/q3gcache.cpp
84 +++ src/qt3support/tools/q3gcache.cpp
85 @@ -622,7 +622,7 @@ void Q3GCache::statistics() const
86 #if defined(QT_DEBUG)
87 QString line;
88 line.fill(QLatin1Char('*'), 80);
89 - qDebug(line.ascii());
90 + qDebug("%s", line.ascii());
91 qDebug("CACHE STATISTICS:");
92 qDebug("cache contains %d item%s, with a total cost of %d",
93 count(), count() != 1 ? "s" : "", tCost);
94 @@ -643,7 +643,7 @@ void Q3GCache::statistics() const
95 lruList->dumps != 1 ? "have" : "has", lruList->dumpCosts);
96 qDebug("Statistics from internal dictionary class:");
97 dict->statistics();
98 - qDebug(line.ascii());
99 + qDebug("%s", line.ascii());
100 #endif
103 --- src/qt3support/tools/q3gdict.cpp
104 +++ src/qt3support/tools/q3gdict.cpp
105 @@ -828,11 +828,11 @@ void Q3GDict::statistics() const
106 QString line;
107 line.fill(QLatin1Char('-'), 60);
108 double real, ideal;
109 - qDebug(line.ascii());
110 + qDebug("%s", line.ascii());
111 qDebug("DICTIONARY STATISTICS:");
112 if (count() == 0) {
113 qDebug("Empty!");
114 - qDebug(line.ascii());
115 + qDebug("%s", line.ascii());
116 return;
118 real = 0.0;
119 @@ -853,7 +853,7 @@ void Q3GDict::statistics() const
120 while (b--)
121 *pbuf++ = '*';
122 *pbuf = '\0';
123 - qDebug(buf);
124 + qDebug("%s", buf);
125 i++;
127 qDebug("Array size = %d", size());
128 @@ -861,7 +861,7 @@ void Q3GDict::statistics() const
129 qDebug("Real dist = %g", real);
130 qDebug("Rand dist = %g", ideal);
131 qDebug("Real/Rand = %g", real/ideal);
132 - qDebug(line.ascii());
133 + qDebug("%s", line.ascii());
134 #endif // QT_DEBUG
137 --- src/qt3support/tools/q3cstring.h
138 +++ src/qt3support/tools/q3cstring.h
139 @@ -57,7 +57,11 @@ public:
142 Q3CString copy() const { return *this; }
143 - Q3CString &sprintf(const char *format, ...);
144 + Q3CString &sprintf(const char *format, ...)
145 +#if defined(Q_CC_GNU) && !defined(__INSURE__)
146 + __attribute__ ((format (printf, 2, 3)))
147 +#endif
150 Q3CString left(uint len) const { return QByteArray::left(len); }
151 Q3CString right(uint len) const { return QByteArray::right(len); }
152 --- tools/designer/src/lib/uilib/formbuilderextra.cpp
153 +++ tools/designer/src/lib/uilib/formbuilderextra.cpp
154 @@ -33,9 +33,7 @@ namespace QFormInternal {
155 #endif
157 void uiLibWarning(const QString &message) {
158 - QString prefixedMessage = QLatin1String("Designer: ");
159 - prefixedMessage += message;
160 - qWarning(prefixedMessage.toUtf8().constData());
161 + qWarning("Designer: %s", qPrintable(message));
164 QFormBuilderExtra::QFormBuilderExtra() :
165 --- tools/designer/src/lib/shared/qdesigner_utils.cpp
166 +++ tools/designer/src/lib/shared/qdesigner_utils.cpp
167 @@ -40,9 +40,7 @@ namespace qdesigner_internal
169 QDESIGNER_SHARED_EXPORT void designerWarning(const QString &message)
171 - QString prefixedMessage = QLatin1String("Designer: ");
172 - prefixedMessage += message;
173 - qWarning(prefixedMessage.toUtf8().constData());
174 + qWarning("Designer: %s", qPrintable(message));
177 QString EnumType::id() const
178 --- tools/qtestlib/src/qtest_global.h
179 +++ tools/qtestlib/src/qtest_global.h
180 @@ -59,7 +59,11 @@ namespace QTest
181 enum SkipMode { SkipSingle = 1, SkipAll = 2 };
182 enum TestFailMode { Abort = 1, Continue = 2 };
184 - int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format, ...);
185 + int Q_TESTLIB_EXPORT qt_snprintf(char *str, int size, const char *format, ...)
186 +#if defined(Q_CC_GNU) && !defined(__INSURE__)
187 + __attribute__ ((format (printf, 3, 4)))
188 +#endif
192 QT_END_HEADER
193 --- tools/assistant/config.cpp
194 +++ tools/assistant/config.cpp
195 @@ -73,12 +73,12 @@ Config *Config::loadConfig(const QString
197 QFile file(profileFileName);
198 if (!file.exists()) {
199 - qWarning( (QLatin1String("File does not exist: ") + profileFileName).toAscii().constData() );
200 + qWarning( "File does not exist: %s", qPrintable(profileFileName) );
201 return 0;
203 DocuParser *parser = DocuParser::createParser( profileFileName );
204 if (!parser) {
205 - qWarning( (QLatin1String("Failed to create parser for file: ") + profileFileName).toAscii().constData() );
206 + qWarning( "Failed to create parser for file: %s", qPrintable(profileFileName) );
207 return 0;
209 if (parser->parserVersion() < DocuParser::Qt320) {
210 @@ -89,7 +89,7 @@ Config *Config::loadConfig(const QString
211 parser->parse(&file);
212 config->profil = profileParser->profile();
213 if (!config->profil) {
214 - qWarning( (QLatin1String("Config::loadConfig(), no profile in: ") + profileFileName).toAscii().constData() );
215 + qWarning( "Config::loadConfig(), no profile in: %s", qPrintable(profileFileName) );
216 return 0;
218 config->profil->setProfileType(Profile::UserProfile);
219 --- tools/assistant/index.cpp
220 +++ tools/assistant/index.cpp
221 @@ -180,7 +180,7 @@ void Index::parseDocument( const QString
223 QFile file( filename );
224 if ( !file.open(QFile::ReadOnly) ) {
225 - qWarning( (QLatin1String("can not open file ") + filename).toAscii().constData() );
226 + qWarning( "can not open file %s", qPrintable(filename) );
227 return;
230 @@ -352,7 +352,7 @@ QString Index::getDocumentTitle( const Q
232 QFile file( fileName );
233 if ( !file.open( QFile::ReadOnly ) ) {
234 - qWarning( (QLatin1String("cannot open file ") + fileName).toAscii().constData() );
235 + qWarning( "cannot open file %s", qPrintable(fileName) );
236 return fileName;
238 QTextStream s( &file );
239 @@ -474,7 +474,7 @@ bool Index::searchForPattern( const QStr
240 QString fName = url.toLocalFile();
241 QFile file( fName );
242 if ( !file.open( QFile::ReadOnly ) ) {
243 - qWarning( (QLatin1String("cannot open file ") + fName).toAscii().constData() );
244 + qWarning( "cannot open file %s", qPrintable(fName) );
245 return false;
248 --- tools/linguist/shared/profileevaluator.h
249 +++ tools/linguist/shared/profileevaluator.h
250 @@ -88,7 +88,11 @@ protected:
252 private:
253 void logMessage(const QString &msg, MessageType mt = MT_DebugLevel2);
254 - void logMessage(MessageType mt, const char *msg, ...);
255 + void logMessage(MessageType mt, const char *msg, ...)
256 +#if defined(Q_CC_GNU) && !defined(__INSURE__)
257 + __attribute__ ((format (printf, 3, 4)))
258 +#endif
260 QString expandVariableReferences(const QString &value);
261 QString evaluateExpandFunction(const QByteArray &func, const QString &arguments);