From d7e9c717af4bbf3df6cfb8ff1bee995731d60146 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 27 Apr 2021 12:02:38 +0300 Subject: [PATCH] Explicitly cast major() and minor() to uints On FreeBSD, the major() and the minor() macros return ints instead of uints. --- src/session_consolekit.cpp | 6 ++++-- src/session_logind.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/session_consolekit.cpp b/src/session_consolekit.cpp index 6fe7fcd31e..c7df93a60a 100644 --- a/src/session_consolekit.cpp +++ b/src/session_consolekit.cpp @@ -171,7 +171,8 @@ int ConsoleKitSession::openRestricted(const QString &fileName) QDBusMessage message = QDBusMessage::createMethodCall(s_serviceName, m_sessionPath, s_sessionInterface, QStringLiteral("TakeDevice")); - message.setArguments({ major(st.st_rdev), minor(st.st_rdev) }); + // major() and minor() macros return ints on FreeBSD instead of uints. + message.setArguments({uint(major(st.st_rdev)), uint(minor(st.st_rdev))}); const QDBusMessage reply = QDBusConnection::systemBus().call(message); if (reply.type() == QDBusMessage::ErrorMessage) { @@ -199,7 +200,8 @@ void ConsoleKitSession::closeRestricted(int fileDescriptor) QDBusMessage message = QDBusMessage::createMethodCall(s_serviceName, m_sessionPath, s_sessionInterface, QStringLiteral("ReleaseDevice")); - message.setArguments({ major(st.st_rdev), minor(st.st_rdev) }); + // major() and minor() macros return ints on FreeBSD instead of uints. + message.setArguments({uint(major(st.st_rdev)), uint(minor(st.st_rdev))}); QDBusConnection::systemBus().asyncCall(message); diff --git a/src/session_logind.cpp b/src/session_logind.cpp index fc94f56434..b424f1a9f0 100644 --- a/src/session_logind.cpp +++ b/src/session_logind.cpp @@ -177,7 +177,8 @@ int LogindSession::openRestricted(const QString &fileName) QDBusMessage message = QDBusMessage::createMethodCall(s_serviceName, m_sessionPath, s_sessionInterface, QStringLiteral("TakeDevice")); - message.setArguments({ major(st.st_rdev), minor(st.st_rdev) }); + // major() and minor() macros return ints on FreeBSD instead of uints. + message.setArguments({uint(major(st.st_rdev)), uint(minor(st.st_rdev))}); const QDBusMessage reply = QDBusConnection::systemBus().call(message); if (reply.type() == QDBusMessage::ErrorMessage) { @@ -205,7 +206,8 @@ void LogindSession::closeRestricted(int fileDescriptor) QDBusMessage message = QDBusMessage::createMethodCall(s_serviceName, m_sessionPath, s_sessionInterface, QStringLiteral("ReleaseDevice")); - message.setArguments({ major(st.st_rdev), minor(st.st_rdev) }); + // major() and minor() macros return ints on FreeBSD instead of uints. + message.setArguments({uint(major(st.st_rdev)), uint(minor(st.st_rdev))}); QDBusConnection::systemBus().asyncCall(message);