Change in kio[master]: cleanup: simplify fooPtr != NULL and related

Jan Kundrát (Code Review) noreply at kde.org
Thu Feb 5 14:49:01 UTC 2015


Jan Kundrát has uploaded a new change for review.

  https://gerrit.vesnicky.cesnet.cz/r/362

Change subject: cleanup: simplify fooPtr != NULL and related
......................................................................

cleanup: simplify fooPtr != NULL and related

Also use nullptr on adjacent places; it's already in use in this
project.

This is a followup which was requested on
https://gerrit.vesnicky.cesnet.cz/r/351 .

Change-Id: Iff933c9ef0513b2a88765365b84632a9de601b44
---
M src/ioslaves/ftp/ftp.cpp
M src/ioslaves/trash/trashimpl.cpp
M src/widgets/jobuidelegate.cpp
M src/widgets/krun.cpp
4 files changed, 28 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.vesnicky.cesnet.cz:29418/kio refs/changes/62/362/1

diff --git a/src/ioslaves/ftp/ftp.cpp b/src/ioslaves/ftp/ftp.cpp
index b060c95..24b3676 100644
--- a/src/ioslaves/ftp/ftp.cpp
+++ b/src/ioslaves/ftp/ftp.cpp
@@ -191,8 +191,8 @@
     : SlaveBase("ftp", pool, app)
 {
     // init the socket data
-    m_data = m_control = NULL;
-    m_server = NULL;
+    m_data = m_control = nullptr;
+    m_server = nullptr;
     ftpCloseControlConnection();
 
     // init other members
@@ -212,20 +212,20 @@
 void Ftp::ftpCloseDataConnection()
 {
     delete m_data;
-    m_data = NULL;
+    m_data = nullptr;
     delete m_server;
-    m_server = NULL;
+    m_server = nullptr;
 }
 
 /**
  * This closes a control connection opened by ftpOpenControlConnection() and reinits the
- * related states.  This method gets called from the constructor with m_control = NULL.
+ * related states.  This method gets called from the constructor with m_control = nullptr.
  */
 void Ftp::ftpCloseControlConnection()
 {
     m_extControl = 0;
     delete m_control;
-    m_control = NULL;
+    m_control = nullptr;
     m_cDataMode = 0;
     m_bLoggedOn = false;    // logon needs control connction
     m_bTextMode = false;
@@ -238,7 +238,7 @@
  */
 const char *Ftp::ftpResponse(int iOffset)
 {
-    Q_ASSERT(m_control != NULL);    // must have control connection socket
+    Q_ASSERT(m_control);    // must have control connection socket
     const char *pTxt = m_lastControlLine.data();
 
     // read the next line ...
@@ -292,7 +292,7 @@
 
 void Ftp::closeConnection()
 {
-    if (m_control != NULL || m_data != NULL)
+    if (m_control || m_data)
         // qDebug() << "m_bLoggedOn=" << m_bLoggedOn << " m_bBusy=" << m_bBusy;
 
         if (m_bBusy) {           // ftpCloseCommand not called
@@ -340,7 +340,7 @@
 {
     // check for implicit login if we are already logged on ...
     if (loginMode == loginImplicit && m_bLoggedOn) {
-        Q_ASSERT(m_control != NULL);    // must have control connection socket
+        Q_ASSERT(m_control);    // must have control connection socket
         return true;
     }
 
@@ -741,7 +741,7 @@
  */
 bool Ftp::ftpSendCmd(const QByteArray &cmd, int maxretries)
 {
-    Q_ASSERT(m_control != NULL);    // must have control connection socket
+    Q_ASSERT(m_control);    // must have control connection socket
 
     if (cmd.indexOf('\r') != -1 || cmd.indexOf('\n') != -1) {
         qWarning() << "Invalid command received (contains CR or LF):"
@@ -803,7 +803,7 @@
                 openConnection();  // Attempt to re-establish a new connection...
 
                 if (!m_bLoggedOn) {
-                    if (m_control != NULL) { // if openConnection succeeded ...
+                    if (m_control) { // if openConnection succeeded ...
                         // qDebug() << "Login failure, aborting";
                         error(ERR_CANNOT_LOGIN, m_host);
                         closeConnection();
@@ -835,8 +835,8 @@
  */
 int Ftp::ftpOpenPASVDataConnection()
 {
-    Q_ASSERT(m_control != NULL);    // must have control connection socket
-    Q_ASSERT(m_data == NULL);       // ... but no data connection
+    Q_ASSERT(m_control);    // must have control connection socket
+    Q_ASSERT(!m_data);      // ... but no data connection
 
     // Check that we can do PASV
     QHostAddress address = m_control->peerAddress();
@@ -892,8 +892,8 @@
  */
 int Ftp::ftpOpenEPSVDataConnection()
 {
-    Q_ASSERT(m_control != NULL);    // must have control connection socket
-    Q_ASSERT(m_data == NULL);       // ... but no data connection
+    Q_ASSERT(m_control);    // must have control connection socket
+    Q_ASSERT(!m_data);      // ... but no data connection
 
     QHostAddress address = m_control->peerAddress();
     int portnum;
@@ -986,8 +986,8 @@
  */
 int Ftp::ftpOpenPortDataConnection()
 {
-    Q_ASSERT(m_control != NULL);    // must have control connection socket
-    Q_ASSERT(m_data == NULL);       // ... but no data connection
+    Q_ASSERT(m_control);    // must have control connection socket
+    Q_ASSERT(!m_data);      // ... but no data connection
 
     m_bPasv = false;
     if (m_extControl & eprtUnknown) {
@@ -1001,7 +1001,7 @@
 
     if (!m_server->isListening()) {
         delete m_server;
-        m_server = NULL;
+        m_server = nullptr;
         return ERR_CANNOT_LISTEN;
     }
 
@@ -1028,7 +1028,7 @@
     }
 
     delete m_server;
-    m_server = NULL;
+    m_server = nullptr;
     return ERR_INTERNAL;
 }
 
@@ -1599,7 +1599,7 @@
 
 bool Ftp::ftpReadDir(FtpEntry &de)
 {
-    Q_ASSERT(m_data != NULL);
+    Q_ASSERT(m_data);
 
     // get a line from the data connecetion ...
     while (true) {
diff --git a/src/ioslaves/trash/trashimpl.cpp b/src/ioslaves/trash/trashimpl.cpp
index 9c3973d..2dd074c 100644
--- a/src/ioslaves/trash/trashimpl.cpp
+++ b/src/ioslaves/trash/trashimpl.cpp
@@ -82,7 +82,7 @@
 int TrashImpl::testDir(const QString &_name) const
 {
     DIR *dp = opendir(QFile::encodeName(_name));
-    if (dp == NULL) {
+    if (!dp) {
         QString name = _name;
         if (name.endsWith(QLatin1Char('/'))) {
             name.truncate(name.length() - 1);
diff --git a/src/widgets/jobuidelegate.cpp b/src/widgets/jobuidelegate.cpp
index 9487dc6..7df289f 100644
--- a/src/widgets/jobuidelegate.cpp
+++ b/src/widgets/jobuidelegate.cpp
@@ -360,15 +360,15 @@
 
 KIO::ClipboardUpdater *KIO::JobUiDelegate::createClipboardUpdater(Job *job, ClipboardUpdaterMode mode)
 {
-    if (qobject_cast<QGuiApplication *>(qApp) != NULL) {
+    if (qobject_cast<QGuiApplication *>(qApp)) {
         return new KIO::ClipboardUpdater(job, mode);
     }
-    return NULL;
+    return nullptr;
 }
 
 void KIO::JobUiDelegate::updateUrlInClipboard(const QUrl &src, const QUrl &dest)
 {
-    if (qobject_cast<QGuiApplication *>(qApp) != NULL) {
+    if (qobject_cast<QGuiApplication *>(qApp)) {
         KIO::ClipboardUpdater::update(src, dest);
     }
 }
diff --git a/src/widgets/krun.cpp b/src/widgets/krun.cpp
index 8b21c78..468494a 100644
--- a/src/widgets/krun.cpp
+++ b/src/widgets/krun.cpp
@@ -291,7 +291,7 @@
                                const QString &userVisibleName, const QString &iconName, QWidget *window,
                                const QByteArray &asn)
 {
-    if (window != NULL) {
+    if (window) {
         window = window->topLevelWidget();
     }
     if (service && !service->entryPath().isEmpty()
@@ -389,10 +389,10 @@
 #endif
         }
     }
-    if (silent_arg != NULL) {
+    if (silent_arg) {
         *silent_arg = silent;
     }
-    if (wmclass_arg != NULL) {
+    if (wmclass_arg) {
         *wmclass_arg = wmclass;
     }
     return true;
@@ -750,7 +750,7 @@
 
     QByteArray myasn = asn;
     // startServiceByDesktopPath() doesn't take QWidget*, add it to the startup info now
-    if (window != NULL) {
+    if (window) {
         if (myasn.isEmpty()) {
             myasn = KStartupInfo::createNewStartupId();
         }

-- 
To view, visit https://gerrit.vesnicky.cesnet.cz/r/362
To unsubscribe, visit https://gerrit.vesnicky.cesnet.cz/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff933c9ef0513b2a88765365b84632a9de601b44
Gerrit-PatchSet: 1
Gerrit-Project: kio
Gerrit-Branch: master
Gerrit-Owner: Jan Kundrát <jkt at kde.org>
Gerrit-Reviewer: David Faure <faure at kde.org>
Gerrit-Reviewer: Eike Hein <hein at kde.org>
Gerrit-Reviewer: Sysadmin Testing Account <null at kde.org>


More information about the Kde-frameworks-devel mailing list