OSDN Git Service

kwin: use QHostInfo::localHostName() to get the local host name
authorIvailo Monev <xakepa10@gmail.com>
Sun, 22 May 2022 23:42:46 +0000 (02:42 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 22 May 2022 23:42:46 +0000 (02:42 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
kwin/tests/test_client_machine.cpp

index aea9484..db5549b 100644 (file)
@@ -25,7 +25,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "../xcbutils.h"
 // Qt
 #include <QApplication>
-#include <QtTest/QtTest>
+#include <QtTest>
+#include <QHostInfo>
 // xcb
 #include <xcb/xcb.h>
 // system
@@ -66,15 +67,8 @@ void TestClientMachine::setClientMachineProperty(xcb_window_t window, const QByt
 
 void TestClientMachine::initTestCase()
 {
-#ifdef HOST_NAME_MAX
-    char hostnamebuf[HOST_NAME_MAX];
-#else
-    char hostnamebuf[256];
-#endif
-    if (gethostname(hostnamebuf, sizeof hostnamebuf) >= 0) {
-        hostnamebuf[sizeof(hostnamebuf)-1] = 0;
-        m_hostName = hostnamebuf;
-    }
+    m_hostName = QHostInfo::localHostName().toAscii();
+
     addrinfo *res = NULL;
     addrinfo addressHints;
     memset(&addressHints, 0, sizeof(addressHints));