diff --git a/tests/auto/corelib/ipc/ipctestcommon.h b/tests/auto/corelib/ipc/ipctestcommon.h index 2347031ad45..4ea9d4eeab6 100644 --- a/tests/auto/corelib/ipc/ipctestcommon.h +++ b/tests/auto/corelib/ipc/ipctestcommon.h @@ -5,6 +5,9 @@ #include #include +#include +#include + namespace IpcTestCommon { static QList supportedKeyTypes; @@ -64,7 +67,7 @@ template<> inline char *toString(const QNativeIpcKey::Type &type) return qstrdup("Invalid"); char buf[32]; - qsnprintf(buf, sizeof(buf), "%u", unsigned(type)); + std::snprintf(buf, sizeof(buf), "%u", qToUnderlying(type)); return qstrdup(buf); } @@ -73,12 +76,11 @@ template<> inline char *toString(const QNativeIpcKey &key) if (!key.isValid()) return qstrdup(""); - const char *type = toString(key.type()); - const char *text = toString(key.nativeKey()); + using UP = std::unique_ptr; + const auto type = UP{toString(key.type())}; + const auto text = UP{toString(key.nativeKey())}; char buf[256]; - qsnprintf(buf, sizeof(buf), "QNativeIpcKey(%s, %s)", text, type); - delete[] type; - delete[] text; + std::snprintf(buf, sizeof(buf), "QNativeIpcKey(%s, %s)", text.get(), type.get()); return qstrdup(buf); } } // namespace QTest