Replace sprintf with QString::asprintf
ClosedPublic

Authored by nicolasfella on May 12 2019, 4:36 PM.

Details

Summary

sprintf is marked as obsolete (https://doc.qt.io/qt-5/qstring-obsolete.html#sprintf) and causes a build fail against current Qt dev. Use asprintf instead

Test Plan

Ran ctest. impp test is failing, but it did before as well

Diff Detail

Repository
R174 KContacts
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nicolasfella created this revision.May 12 2019, 4:36 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptMay 12 2019, 4:36 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
nicolasfella requested review of this revision.May 12 2019, 4:36 PM
vkrause accepted this revision.May 12 2019, 4:48 PM
vkrause added a subscriber: vkrause.

Change looks correct to me. All unit tests pass here though, and on the CI, can you post the error, maybe some locale setting that isn't explicitly set?

This revision is now accepted and ready to land.May 12 2019, 4:48 PM
********* Start testing of ImppTest *********
Config: Using QtTest library 5.14.0, Qt 5.14.0 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 8.3.0)
PASS   : ImppTest::initTestCase()
PASS   : ImppTest::shouldParseImppVcard4()
PASS   : ImppTest::shouldHaveDefaultValue()
FAIL!  : ImppTest::shouldAssignValue() Compared values are not the same
   Actual   (impp.serviceIcon())     : ""
   Expected (QLatin1String("im-icq")): "im-icq"
   Loc: [/home/nico/kde/src/kcontacts/autotests/impptest.cpp(57)]
PASS   : ImppTest::shouldSerialized()
PASS   : ImppTest::shouldEqualImpp()
PASS   : ImppTest::shouldParseWithoutImpp()
PASS   : ImppTest::shouldParseImpp()
PASS   : ImppTest::shouldParseServiceType(withoutimpp)
PASS   : ImppTest::shouldExportEmptyType()
QFATAL : ImppTest::shouldExportType() ASSERT failure in QTest::fetchData(): "Test data requested, but no testdata available.", file qtestcase.cpp, line 1174
FAIL!  : ImppTest::shouldExportType() Received a fatal error.
   Loc: [Unknown file(0)]
Totals: 9 passed, 2 failed, 0 skipped, 0 blacklisted, 4ms
********* Finished testing of ImppTest *********
[1]    29563 abort (core dumped)  ./bin/impptest
#0  0x00007ffff732c82f in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7317672 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff78a2456 in qt_message_fatal (context=..., message=...) at global/qlogging.cpp:1904
#3  0x00007ffff78a30a1 in QMessageLogger::fatal (this=this@entry=0x7fffffffd230, msg=msg@entry=0x7ffff7b75fb0 "ASSERT failure in %s: \"%s\", file %s, line %d") at global/qlogging.cpp:888
#4  0x00007ffff789d0d4 in qt_assert_x (where=where@entry=0x7ffff7e19c71 "QTest::fetchData()", what=what@entry=0x7ffff7e18180 "Test data requested, but no testdata available.", 
    file=file@entry=0x7ffff7e19bba "qtestcase.cpp", line=line@entry=1174) at ../../include/QtCore/../../src/corelib/global/qlogging.h:91
#5  0x00007ffff7de8ad6 in QTest::fetchData (data=0x0, tagName=tagName@entry=0x555555562137 "type", typeId=typeId@entry=10) at qtestcase.cpp:1174
#6  0x00007ffff7de9572 in QTest::qData (tagName=0x555555562137 "type", typeId=10) at qtestcase.cpp:2294
#7  0x000055555555a6d7 in ImppTest::shouldExportType (this=0x7fffffffdc30) at /home/nico/kde/src/kcontacts/autotests/impptest.cpp:247
#8  0x0000555555557824 in ImppTest::qt_static_metacall (_o=0x7fffffffdc30, _c=QMetaObject::InvokeMetaMethod, _id=11, _a=0x7fffffffd520)
    at /home/nico/kde/build/kcontacts/autotests/impptest_autogen/EWIEGA46WW/moc_impptest.cpp:134
#9  0x00007ffff7a9189a in QMetaMethod::invoke (this=0x555555588eb0, object=0x7fffffffdc30, connectionType=connectionType@entry=Qt::DirectConnection, returnValue=..., val0=..., val1=..., 
    val2=..., val3=..., val4=..., val5=..., val6=..., val7=..., val8=..., val9=...) at kernel/qmetaobject.cpp:2301
#10 0x00007ffff7deee11 in QMetaMethod::invoke (val9=..., val8=..., val7=..., val6=..., val5=..., val4=..., val3=..., val2=..., val1=..., val0=..., connectionType=Qt::DirectConnection, 
    object=<optimized out>, this=<optimized out>) at ../../include/QtCore/../../src/corelib/kernel/qobjectdefs.h:297
#11 QTest::TestMethods::invokeTestOnData (this=this@entry=0x7fffffffdb70, index=index@entry=9) at qtestcase.cpp:941
#12 0x00007ffff7defbf6 in QTest::TestMethods::invokeTest (this=this@entry=0x7fffffffdb70, index=index@entry=9, data=data@entry=0x0, watchDog=watchDog@entry=0x0) at qtestcase.cpp:1141
#13 0x00007ffff7df0379 in QTest::TestMethods::invokeTests (this=this@entry=0x7fffffffdb70, testObject=0x7fffffffdc30) at ../../include/QtCore/../../src/corelib/tools/qscopedpointer.h:138
#14 0x00007ffff7df0a0e in QTest::qRun () at qtestcase.cpp:1922
#15 0x00007ffff7df0b6e in QTest::qExec (testObject=<optimized out>, argc=<optimized out>, argv=<optimized out>) at qtestcase.cpp:1811
#16 0x000055555555bd58 in main (argc=1, argv=0x7fffffffdd48) at /home/nico/kde/src/kcontacts/autotests/impptest.cpp:333

also see this crash in impptest

This revision was automatically updated to reflect the committed changes.