From 281289dfbba8d02e2fa7121cb54e2569586bf1e9 Mon Sep 17 00:00:00 2001 From: Shubham Jangra Date: Fri, 29 Mar 2019 11:58:56 -0600 Subject: [PATCH] Constantify nonce and some cleanup Reviewers: stikonas, #kde_partition_manager, cjlcarvalho Reviewed By: stikonas, #kde_partition_manager, cjlcarvalho Subscribers: varunp, tctara, teo, abhijeet2096, caiovosilva, cjlcarvalho, #kde_partition_manager Tags: #kde_partition_manager Differential Revision: https://phabricator.kde.org/D20108 --- src/util/externalcommandhelper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp index 7330232..5be2ec7 100644 --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -90,7 +90,7 @@ ActionReply ExternalCommandHelper::init(const QVariantMap& args) */ quint64 ExternalCommandHelper::getNonce() { - quint64 nonce = m_Generator.generate(); + const quint64 nonce = m_Generator.generate(); m_Nonces.insert(nonce); return nonce; } @@ -135,6 +135,7 @@ bool ExternalCommandHelper::readData(const QString& sourceDevice, QByteArray& bu bool ExternalCommandHelper::writeData(const QString &targetDevice, const QByteArray& buffer, const qint64 offset) { QFile device(targetDevice); + if (!device.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered)) { qCritical() << xi18n("Could not open device %1 for writing.", targetDevice); return false; @@ -149,6 +150,7 @@ bool ExternalCommandHelper::writeData(const QString &targetDevice, const QByteAr qCritical() << xi18n("Could not write to device %1.", targetDevice); return false; } + return true; }