Change NULL to nullptr 67/25467/5
authorMarcin Niesluchowski <m.niesluchow@samsung.com>
Wed, 27 Aug 2014 07:51:12 +0000 (09:51 +0200)
committerMarcin Niesluchowski <m.niesluchow@samsung.com>
Wed, 27 Aug 2014 07:51:58 +0000 (09:51 +0200)
Change-Id: I316a253e25a2460c9e2ff85a791550073ebde51a

39 files changed:
tests/common/db_sqlite.cpp
tests/common/db_sqlite.h
tests/common/dbus_access.cpp
tests/common/fs_label_manager.cpp
tests/common/smack_access.cpp
tests/common/tests_common.cpp
tests/framework/include/dpl/abstract_input.h
tests/framework/include/dpl/binary_queue.h
tests/framework/include/dpl/exception.h
tests/framework/include/dpl/scoped_fclose.h
tests/framework/include/dpl/scoped_free.h
tests/framework/include/dpl/test/test_runner.h
tests/framework/src/abstract_log_provider.cpp
tests/framework/src/binary_queue.cpp
tests/framework/src/exception.cpp
tests/framework/src/gdbbacktrace.cpp
tests/framework/src/log.cpp
tests/framework/src/old_style_log_provider.cpp
tests/framework/src/test_results_collector.cpp
tests/framework/src/test_runner.cpp
tests/libprivilege-control-tests/common/db.cpp
tests/libprivilege-control-tests/common/duplicates.cpp
tests/libprivilege-control-tests/libprivilege-control_test_common.cpp
tests/libprivilege-control-tests/test_cases.cpp
tests/libprivilege-control-tests/test_cases_incorrect_params.cpp
tests/libprivilege-control-tests/test_cases_nosmack.cpp
tests/libprivilege-control-tests/test_cases_stress.cpp
tests/libsmack-tests/test_cases.cpp
tests/perf
tests/security-manager-tests/security_manager_tests.cpp
tests/security-server-tests/cookie_api.cpp
tests/security-server-tests/security_server_measurer_API_speed.cpp
tests/security-server-tests/security_server_tests_client_smack.cpp
tests/security-server-tests/security_server_tests_dbus.cpp
tests/security-server-tests/security_server_tests_password.cpp
tests/security-server-tests/security_server_tests_privilege.cpp
tests/security-server-tests/security_server_tests_stress.cpp
tests/security-server-tests/server.cpp
tests/security-server-tests/weird_arguments.cpp

index f6852aa..73c842b 100644 (file)
@@ -25,7 +25,7 @@
 #include "db_sqlite.h"
 
 Sqlite3DBase::Sqlite3DBase(const std::string& db_path, int flags)
-    : m_db_handle(NULL), m_db_path(db_path), m_flags(flags)
+    : m_db_handle(nullptr), m_db_path(db_path), m_flags(flags)
 {
 }
 
@@ -34,7 +34,7 @@ Sqlite3DBase::~Sqlite3DBase()
     sqlite3_close(m_db_handle);
 }
 
-#define VFS_NOT_USED    NULL
+#define VFS_NOT_USED    nullptr
 
 void Sqlite3DBase::open(void)
 {
@@ -53,7 +53,7 @@ void Sqlite3DBase::close(void)
     RUNNER_ASSERT_MSG(ret == SQLITE_OK, "Error closing the database: " <<
                          sqlite3_errmsg(m_db_handle));
 
-    m_db_handle = NULL;
+    m_db_handle = nullptr;
 }
 
 bool Sqlite3DBase::is_open(void) const
@@ -63,7 +63,7 @@ bool Sqlite3DBase::is_open(void) const
 
 void Sqlite3DBase::execute(const std::string& sql_query, Sqlite3DBaseSelectResult& result)
 {
-    char* tmp = NULL;
+    char* tmp = nullptr;
     std::string errmsg;
 
     int ret = sqlite3_exec(m_db_handle, sql_query.c_str(), callback, &result, &tmp);
index 226fc3f..9a17083 100644 (file)
@@ -149,7 +149,7 @@ private:
  * @var db_handle
  * @brief Handle to sqlite3 database
  *
- * NULL when database not opened.
+ * nullptr when database not opened.
  */
     sqlite3* m_db_handle;
 
index d214b1a..95e5592 100644 (file)
@@ -32,9 +32,9 @@
 #include "dbus_access.h"
 
 DBusAccess::DBusAccess(const char *service_name)
-  : m_conn(NULL)
-  , m_msg(NULL)
-  , m_pending(NULL)
+  : m_conn(nullptr)
+  , m_msg(nullptr)
+  , m_pending(nullptr)
   , m_handled(FALSE)
 {
     dbus_error_init(&m_err);
@@ -76,7 +76,7 @@ void DBusAccess::newMethodCall(const char *method) {
                                          dbus_systemd_object.c_str(),
                                          dbus_systemd_interface.c_str(),
                                          method);
-    RUNNER_ASSERT_MSG(NULL != m_msg,
+    RUNNER_ASSERT_MSG(nullptr != m_msg,
         "Error in dbus_message_new_method_call");
 }
 
@@ -95,18 +95,18 @@ void DBusAccess::sendMsgWithReply() {
     RUNNER_ASSERT_MSG(ret == 1,
         "Error in dbus_connection_send_with_reply");
 
-    RUNNER_ASSERT_MSG(NULL != m_pending, "Pending call null");
+    RUNNER_ASSERT_MSG(nullptr != m_pending, "Pending call null");
 
     dbus_connection_flush(m_conn);
     dbus_pending_call_block(m_pending);
 
     dbus_message_unref(m_msg);
-    m_msg = NULL;
+    m_msg = nullptr;
 }
 
 void DBusAccess::getMsgReply() {
     m_msg = dbus_pending_call_steal_reply(m_pending);
-    RUNNER_ASSERT_MSG(NULL != m_msg,
+    RUNNER_ASSERT_MSG(nullptr != m_msg,
         "Error in dbus_pending_call_steal_reply");
 }
 
@@ -120,8 +120,8 @@ void DBusAccess::handleMsgReply() {
     }
     dbus_message_unref(m_msg);
     dbus_pending_call_unref(m_pending);
-    m_msg = NULL;
-    m_pending = NULL;
+    m_msg = nullptr;
+    m_pending = nullptr;
 }
 
 void DBusAccess::connectToDBus() {
index bd8fccb..484ec76 100644 (file)
@@ -32,7 +32,7 @@ static const char* get_xattr_name(enum smack_label_type type)
             return XATTR_NAME_SMACKIPOUT;
         default:
             /*  Should not reach this point */
-            return NULL;
+            return nullptr;
     }
 }
 }
@@ -143,9 +143,9 @@ void FsLabelManager::testSmackGetLabel(const std::string &relativePath,
     RUNNER_ASSERT_MSG(ret == 0, "Error in normal getting label");
     SmackLabelPtr labelPtr(tmpLabel);
 
-    if (label == NULL && !m_label.compare(tmpLabel))
+    if (label == nullptr && !m_label.compare(tmpLabel))
         return;
-    RUNNER_ASSERT_MSG(label != NULL, "Path should be related with file system default label. "
+    RUNNER_ASSERT_MSG(label != nullptr, "Path should be related with file system default label. "
                                         << tmpLabel << " != " << m_label);
 
     ret = strcmp(tmpLabel, label);
@@ -165,9 +165,9 @@ void FsLabelManager::testSmackLGetLabel(const std::string &relativePath,
     RUNNER_ASSERT_MSG(ret == 0, "Error in link getting label");
     SmackLabelPtr labelPtr(tmpLabel);
 
-    if (label == NULL && !m_label.compare(tmpLabel))
+    if (label == nullptr && !m_label.compare(tmpLabel))
         return;
-    RUNNER_ASSERT_MSG(label != NULL, "Path should be related with file system default label. "
+    RUNNER_ASSERT_MSG(label != nullptr, "Path should be related with file system default label. "
                                         << tmpLabel << " != " << m_label);
 
     ret = strcmp(tmpLabel, label);
@@ -190,9 +190,9 @@ void FsLabelManager::testSmackFGetLabel(const std::string &relativePath,
     RUNNER_ASSERT_MSG(ret == 0, "Error in fd getting label");
     SmackLabelPtr labelPtr(tmpLabel);
 
-    if (label == NULL && !m_label.compare(tmpLabel))
+    if (label == nullptr && !m_label.compare(tmpLabel))
         return;
-    RUNNER_ASSERT_MSG(label != NULL, "Fd should be related with file system default label. "
+    RUNNER_ASSERT_MSG(label != nullptr, "Fd should be related with file system default label. "
                                         << tmpLabel << " != " << m_label);
 
     ret = strcmp(tmpLabel, label);
@@ -203,10 +203,10 @@ void FsLabelManager::testSmackFGetLabel(const std::string &relativePath,
 
 void FsLabelManager::testSmackClearLabels(const std::string &relativePath)
 {
-    testSmackSetLabel(relativePath, NULL, SMACK_LABEL_ACCESS);
-    testSmackGetLabel(relativePath, NULL, SMACK_LABEL_ACCESS);
-    testSmackSetLabel(relativePath, NULL, SMACK_LABEL_EXEC);
-    testSmackGetLabel(relativePath, NULL, SMACK_LABEL_EXEC);
+    testSmackSetLabel(relativePath, nullptr, SMACK_LABEL_ACCESS);
+    testSmackGetLabel(relativePath, nullptr, SMACK_LABEL_ACCESS);
+    testSmackSetLabel(relativePath, nullptr, SMACK_LABEL_EXEC);
+    testSmackGetLabel(relativePath, nullptr, SMACK_LABEL_EXEC);
 }
 
 void FsLabelManager::checkLabel(const std::string &path,
@@ -218,7 +218,7 @@ void FsLabelManager::checkLabel(const std::string &path,
     RUNNER_ASSERT_ERRNO_MSG(ret > 0, "Error in getting xattr");
 
     const char *tmpLabel;
-    if (label == NULL)
+    if (label == nullptr)
         tmpLabel = m_label.c_str();
     else
         tmpLabel = label;
@@ -236,7 +236,7 @@ void FsLabelManager::checkLinkLabel(const std::string &path,
     RUNNER_ASSERT_ERRNO_MSG(ret > 0, "Error in getting xattr");
 
     const char *tmpLabel;
-    if (label == NULL)
+    if (label == nullptr)
         tmpLabel = m_label.c_str();
     else
         tmpLabel = label;
index a9bf5b4..354b997 100644 (file)
@@ -27,7 +27,7 @@
 #include <smack_access.h>
 
 SmackAccess::SmackAccess()
-  : m_handle(NULL)
+  : m_handle(nullptr)
 {
     RUNNER_ASSERT_MSG(0 == smack_accesses_new(&m_handle),
         "Error in smack_accesses_new");
index 318fee2..5fa6125 100644 (file)
@@ -87,11 +87,11 @@ void add_process_group(const char* group_name)
 {
     // get group ID by group name
     group *gr = getgrnam(group_name);
-    RUNNER_ASSERT_ERRNO_MSG(gr != NULL, "getgrnam failed on '" << group_name << "' group");
+    RUNNER_ASSERT_ERRNO_MSG(gr != nullptr, "getgrnam failed on '" << group_name << "' group");
     const gid_t new_group_id = gr->gr_gid;
 
     // get number of groups that the current process belongs to
-    int ngroups = getgroups(0, NULL);
+    int ngroups = getgroups(0, nullptr);
 
     //allocate groups table + space for new group entry
     std::vector<gid_t> groups(ngroups + 1);
@@ -113,10 +113,10 @@ void remove_process_group(const char* group_name)
 {
     // get group ID by group name
     group *gr = getgrnam(group_name);
-    RUNNER_ASSERT_ERRNO_MSG(gr != NULL, "getgrnam failed on '" << group_name << "' group");
+    RUNNER_ASSERT_ERRNO_MSG(gr != nullptr, "getgrnam failed on '" << group_name << "' group");
     const gid_t new_group_id = gr->gr_gid;
 
-    int ngroups = getgroups(0, NULL);
+    int ngroups = getgroups(0, nullptr);
     std::vector<gid_t> groups(ngroups);
     getgroups(ngroups, groups.data());
 
index 8c0e16a..69cdc53 100644 (file)
@@ -44,7 +44,7 @@ class AbstractInput
 
     /**
      * Read binary data from input
-     * If no data is available method returns NULL buffer.
+     * If no data is available method returns nullptr buffer.
      * In case connection was successfuly close, method returns empty buffer
      *
      * @param[in] size Maximum number of bytes to read from input
index f4fa278..cd76a0e 100644 (file)
@@ -163,7 +163,7 @@ class BinaryQueue :
         size_t bufferSize,
         BufferDeleter deleter =
             &BinaryQueue::BufferDeleterFree,
-        void *userParam = NULL);
+        void *userParam = nullptr);
 
     /**
      * Append copy of other binary queue to the end of this binary queue
index cdbdc53..eb5cfc7 100644 (file)
@@ -58,20 +58,20 @@ class Exception
     static void UnRef(Exception* e)
     {
         if (m_lastException == e) {
-            m_lastException = NULL;
+            m_lastException = nullptr;
         }
 
         --m_exceptionCount;
 
         if (!m_exceptionCount) {
             std::set_terminate(m_terminateHandler);
-            m_terminateHandler = NULL;
+            m_terminateHandler = nullptr;
         }
     }
 
     static void TerminateHandler()
     {
-        if (m_lastException != NULL) {
+        if (m_lastException != nullptr) {
             DisplayKnownException(*m_lastException);
             abort();
         } else {
@@ -125,10 +125,10 @@ class Exception
     Exception(const Exception &other)
     {
         // Deep copy
-        if (other.m_reason != NULL) {
+        if (other.m_reason != nullptr) {
             m_reason = new Exception(*other.m_reason);
         } else {
-            m_reason = NULL;
+            m_reason = nullptr;
         }
 
         m_message = other.m_message;
@@ -148,10 +148,10 @@ class Exception
         }
 
         // Deep copy
-        if (other.m_reason != NULL) {
+        if (other.m_reason != nullptr) {
             m_reason = new Exception(*other.m_reason);
         } else {
-            m_reason = NULL;
+            m_reason = nullptr;
         }
 
         m_message = other.m_message;
@@ -170,7 +170,7 @@ class Exception
               const char *function,
               int line,
               const std::string &message) :
-        m_reason(NULL),
+        m_reason(nullptr),
         m_path(path),
         m_function(function),
         m_line(line),
@@ -195,9 +195,9 @@ class Exception
 
     virtual ~Exception() throw()
     {
-        if (m_reason != NULL) {
+        if (m_reason != nullptr) {
             delete m_reason;
-            m_reason = NULL;
+            m_reason = nullptr;
         }
 
         UnRef(this);
@@ -206,14 +206,14 @@ class Exception
     void Dump() const
     {
         // Show reason first
-        if (m_reason != NULL) {
+        if (m_reason != nullptr) {
             m_reason->Dump();
         }
 
         // Afterward, dump exception
         const char *file = strchr(m_path.c_str(), '/');
 
-        if (file == NULL) {
+        if (file == nullptr) {
             file = m_path.c_str();
         } else {
             ++file;
@@ -229,13 +229,13 @@ class Exception
     std::string DumpToString() const
     {
         std::string ret;
-        if (m_reason != NULL) {
+        if (m_reason != nullptr) {
             ret = m_reason->DumpToString();
         }
 
         const char *file = strchr(m_path.c_str(), '/');
 
-        if (file == NULL) {
+        if (file == nullptr) {
             file = m_path.c_str();
         } else {
             ++file;
index e8deb15..402d03b 100644 (file)
@@ -37,11 +37,11 @@ struct ScopedFClosePolicy
     typedef FILE* Type;
     static Type NullValue()
     {
-        return NULL;
+        return nullptr;
     }
     static void Destroy(Type file)
     {
-        if (file != NULL) {
+        if (file != nullptr) {
             // Try to flush first
             if (TEMP_FAILURE_RETRY(fflush(file)) != 0) {
                 std::string errString = strerror(errno);
index 7bebe39..e4f7ed6 100644 (file)
@@ -35,7 +35,7 @@ struct ScopedFreePolicy
     typedef Class* Type;
     static Type NullValue()
     {
-        return NULL;
+        return nullptr;
     }
     static void Destroy(Type ptr)
     {
index c7071f4..e705df8 100644 (file)
@@ -51,7 +51,7 @@ class TestRunner
 
   public:
     TestRunner() :
-        m_currentTestCase(NULL)
+        m_currentTestCase(nullptr)
       , m_terminate(false)
       , m_allowChildLogs(false)
     {}
index a03f8a0..a62a288 100644 (file)
@@ -28,7 +28,7 @@ namespace Log {
 const char *AbstractLogProvider::LocateSourceFileName(const char *filename)
 {
     const char *ptr = strrchr(filename, '/');
-    return ptr != NULL ? ptr + 1 : filename;
+    return ptr != nullptr ? ptr + 1 : filename;
 }
 }
 }
index 2234c8f..cd169bc 100644 (file)
@@ -60,13 +60,13 @@ void BinaryQueue::AppendCopyFrom(const BinaryQueue &other)
     // To speed things up, always copy as one bucket
     void *bufferCopy = malloc(other.m_size);
 
-    if (bufferCopy == NULL) {
+    if (bufferCopy == nullptr) {
         throw std::bad_alloc();
     }
 
     try {
         other.Flatten(bufferCopy, other.m_size);
-        AppendUnmanaged(bufferCopy, other.m_size, &BufferDeleterFree, NULL);
+        AppendUnmanaged(bufferCopy, other.m_size, &BufferDeleterFree, nullptr);
     } catch (const std::bad_alloc &) {
         // Free allocated memory
         free(bufferCopy);
@@ -109,7 +109,7 @@ void BinaryQueue::AppendCopy(const void* buffer, size_t bufferSize)
     void *bufferCopy = malloc(bufferSize);
 
     // Check if allocation succeded
-    if (bufferCopy == NULL) {
+    if (bufferCopy == nullptr) {
         throw std::bad_alloc();
     }
 
@@ -118,7 +118,7 @@ void BinaryQueue::AppendCopy(const void* buffer, size_t bufferSize)
 
     try {
         // Try to append new bucket
-        AppendUnmanaged(bufferCopy, bufferSize, &BufferDeleterFree, NULL);
+        AppendUnmanaged(bufferCopy, bufferSize, &BufferDeleterFree, nullptr);
     } catch (const std::bad_alloc &) {
         // Free allocated memory
         free(bufferCopy);
@@ -248,8 +248,8 @@ BinaryQueue::Bucket::Bucket(const void* data,
     deleter(dataDeleter),
     param(userParam)
 {
-    Assert(data != NULL);
-    Assert(deleter != NULL);
+    Assert(data != nullptr);
+    Assert(deleter != nullptr);
 }
 
 BinaryQueue::Bucket::~Bucket()
@@ -275,7 +275,7 @@ void BinaryQueue::BucketVisitorCall::operator()(Bucket *bucket) const
 
 void BinaryQueue::VisitBuckets(BucketVisitor *visitor) const
 {
-    Assert(visitor != NULL);
+    Assert(visitor != nullptr);
 
     // Visit all buckets
     std::for_each(m_buckets.begin(), m_buckets.end(), BucketVisitorCall(visitor));
@@ -296,7 +296,7 @@ BinaryQueueAutoPtr BinaryQueue::Read(size_t size)
 
     Flatten(bufferCopy.Get(), available);
     result->AppendUnmanaged(
-        bufferCopy.Get(), available, &BufferDeleterFree, NULL);
+        bufferCopy.Get(), available, &BufferDeleterFree, nullptr);
     bufferCopy.Release();
     Consume(available);
 
index d3673e6..f4cd4a6 100644 (file)
@@ -25,9 +25,9 @@
 #include <cstdio>
 
 namespace DPL {
-Exception* Exception::m_lastException = NULL;
+Exception* Exception::m_lastException = nullptr;
 unsigned int Exception::m_exceptionCount = 0;
-void (*Exception::m_terminateHandler)() = NULL;
+void (*Exception::m_terminateHandler)() = nullptr;
 
 void LogUnhandledException(const std::string &str)
 {
index a585285..7efe4e5 100644 (file)
@@ -85,7 +85,7 @@ std::string backtrace_read(int fd)
 
     result << std::endl;
     size_t line_number = 1;
-    while (fgets(read_buffer, sizeof(read_buffer) - 1, bt_fd) != NULL) {
+    while (fgets(read_buffer, sizeof(read_buffer) - 1, bt_fd) != nullptr) {
         if (backtrace_parse_line(read_buffer, result, line_number))
             ++line_number;
     }
@@ -120,7 +120,7 @@ std::string gdbbacktrace(void)
         if (dup2(pipe_fd[1], 1) == -1)
             exit(2);
         execlp("/usr/bin/gdb", "gdb", "--batch", "-n", "-ex", "thread", "-ex", "bt", "--pid",
-               pid_buf.c_str(), NULL);
+               pid_buf.c_str(), nullptr);
         // gdb failed to start...
         exit(1);
     }
index 5e155bf..1625088 100644 (file)
@@ -44,8 +44,8 @@ bool LogSystem::IsLoggingEnabled() const
 }
 
 LogSystem::LogSystem() :
-    m_dlogProvider(NULL),
-    m_oldStyleProvider(NULL),
+    m_dlogProvider(nullptr),
+    m_oldStyleProvider(nullptr),
     m_isLoggingEnabled(!getenv(DPL_LOG_OFF))
 {
     bool oldStyleLogs = false;
@@ -58,19 +58,19 @@ LogSystem::LogSystem() :
     // Check environment settings about pedantic logs
     const char *value = getenv(OLD_STYLE_LOGS_ENV_NAME);
 
-    if (value != NULL && !strcmp(value, "1")) {
+    if (value != nullptr && !strcmp(value, "1")) {
         oldStyleLogs = true;
     }
 
     value = getenv(OLD_STYLE_PEDANTIC_LOGS_ENV_NAME);
 
-    if (value != NULL && !strcmp(value, "1")) {
+    if (value != nullptr && !strcmp(value, "1")) {
         oldStylePedanticLogs = true;
     }
 
     value = getenv(OLD_STYLE_LOGS_MASK_ENV_NAME);
 
-    if (value != NULL) {
+    if (value != nullptr) {
         size_t len = strlen(value);
 
         if (len >= 1) {
@@ -135,13 +135,13 @@ LogSystem::~LogSystem()
     m_providers.clear();
 
     // And even default providers
-    m_dlogProvider = NULL;
-    m_oldStyleProvider = NULL;
+    m_dlogProvider = nullptr;
+    m_oldStyleProvider = nullptr;
 }
 
 void LogSystem::SetTag(const char* tag)
 {
-    if (m_dlogProvider != NULL) {
+    if (m_dlogProvider != nullptr) {
         m_dlogProvider->SetTag(tag);
     }
 }
index b8060dd..a8abe06 100644 (file)
@@ -49,7 +49,7 @@ std::string GetFormattedTime()
     timeval tv;
     tm localNowTime;
 
-    gettimeofday(&tv, NULL);
+    gettimeofday(&tv, nullptr);
     localtime_r(&tv.tv_sec, &localNowTime);
 
     char format[64];
index e42f60e..860e8ab 100644 (file)
@@ -1033,7 +1033,7 @@ TestResultsCollectorBase* TestResultsCollectorBase::Create(
     if (found != m_constructorsMap.end()) {
         return found->second();
     } else {
-        return NULL;
+        return nullptr;
     }
 }
 
index ff38f90..af76536 100644 (file)
@@ -64,7 +64,7 @@ namespace // anonymous
 std::string BaseName(std::string aPath)
 {
     ScopedFree<char> path(strdup(aPath.c_str()));
-    if (NULL == path.Get()) {
+    if (nullptr == path.Get()) {
         throw std::bad_alloc();
     }
     char* baseName = basename(path.Get());
@@ -163,13 +163,13 @@ bool TestRunner::filterGroupsByXmls(const std::vector<std::string> & files)
             xmlDocPtr doc;
             xmlXPathContextPtr xpathCtx;
 
-            doc = xmlReadFile(file.c_str(), NULL, 0);
-            if (doc == NULL) {
+            doc = xmlReadFile(file.c_str(), nullptr, 0);
+            if (doc == nullptr) {
                 ThrowMsg(XMLError, "File Problem");
             } else {
                 //context
                 xpathCtx = xmlXPathNewContext(doc);
-                if (xpathCtx == NULL) {
+                if (xpathCtx == nullptr) {
                     ThrowMsg(XMLError,
                              "Error: unable to create new XPath context\n");
                 }
@@ -180,7 +180,7 @@ bool TestRunner::filterGroupsByXmls(const std::vector<std::string> & files)
             xmlXPathObjectPtr xpathObject;
             //get requested node's values
             xpathObject = xmlXPathEvalExpression(BAD_CAST idPath.c_str(), xpathCtx);
-            if (xpathObject == NULL)
+            if (xpathObject == nullptr)
             {
                 ThrowMsg(XMLError, "XPath evaluation failure: " << idPath);
             }
@@ -255,7 +255,7 @@ TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
                       TestResultsCollectorBase::FailStatus::FAILED,
                       e.GetMessage());
 
-        setCurrentTestCase(NULL);
+        setCurrentTestCase(nullptr);
         return FAILED;
     } catch (const Ignored &e) {
         if (m_runIgnored) {
@@ -266,7 +266,7 @@ TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
                           e.GetMessage());
         }
 
-        setCurrentTestCase(NULL);
+        setCurrentTestCase(nullptr);
         return IGNORED;
     } catch (const DPL::Exception &e) {
         // DPL exception failure
@@ -275,7 +275,7 @@ TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
                       TestResultsCollectorBase::FailStatus::INTERNAL,
                       "DPL exception:" + e.GetMessage());
 
-        setCurrentTestCase(NULL);
+        setCurrentTestCase(nullptr);
         return FAILED;
     } catch (const std::exception &) {
         // std exception failure
@@ -284,7 +284,7 @@ TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
                       TestResultsCollectorBase::FailStatus::INTERNAL,
                       "std exception");
 
-        setCurrentTestCase(NULL);
+        setCurrentTestCase(nullptr);
         return FAILED;
     } catch (...) {
         // Unknown exception failure
@@ -293,7 +293,7 @@ TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
                       TestResultsCollectorBase::FailStatus::INTERNAL,
                       "unknown exception");
 
-        setCurrentTestCase(NULL);
+        setCurrentTestCase(nullptr);
         return FAILED;
     }
 
@@ -304,7 +304,7 @@ TestRunner::Status TestRunner::RunTestCase(const TestCaseStruct& testCase)
                   testCase.m_isPerformanceTest,
                   testCase.m_performanceTestDurationTime,
                   testCase.m_performanceMaxTime);
-    setCurrentTestCase(NULL);
+    setCurrentTestCase(nullptr);
 
     // Everything OK
     return PASS;
index 67a3fac..bbfd12e 100644 (file)
@@ -79,7 +79,7 @@ void TestLibPrivilegeControlDatabase::test_db_after__perm_app_enable_permissions
                    PERMISSION_ENABLED);
 
     int i;
-    for (i = 0; perm_list[i] != NULL; ++i) {
+    for (i = 0; perm_list[i] != nullptr; ++i) {
         // Ignore empty lines
         if (strspn(perm_list[i], " \t\n") == strlen(perm_list[i]))
             continue;
index 68e5729..652e1d8 100644 (file)
@@ -72,7 +72,7 @@ std::string app_type_group_name(app_type_t app_type)
 int base_name_from_perm(const char *perm, std::string& name)
 {
     iri_t *iris = iri_parse(perm);
-    if (iris == NULL || iris->host == NULL)
+    if (iris == nullptr || iris->host == nullptr)
     {
         iri_destroy(iris);
         return PC_ERR_INVALID_PARAM;
@@ -83,7 +83,7 @@ int base_name_from_perm(const char *perm, std::string& name)
     std::string path;
     std::string::size_type pos;
 
-    if (iris->path == NULL)
+    if (iris->path == nullptr)
     {
         path = iris->host;
     }
index d45ac7c..ef7681f 100644 (file)
 
 const char *USER_APP_ID = "User";
 
-const char *PRIVS1[] = { "WRT", "test_privilege_control_rules1", NULL };
-const char *PRIVS2[] = { "test_privilege_control_rules2", NULL };
-const char *PRIVS2_NO_R[] = { "test_privilege_control_rules2_no_r", NULL };
-const char *PRIVS2_R[] = { "test_privilege_control_rules2_r", NULL };
-const char *PRIVS2_R_AND_NO_R[] = { "test_privilege_control_rules2_r", "test_privilege_control_rules2_no_r", NULL };
+const char *PRIVS1[] = { "WRT", "test_privilege_control_rules1", nullptr };
+const char *PRIVS2[] = { "test_privilege_control_rules2", nullptr };
+const char *PRIVS2_NO_R[] = { "test_privilege_control_rules2_no_r", nullptr };
+const char *PRIVS2_R[] = { "test_privilege_control_rules2_r", nullptr };
+const char *PRIVS2_R_AND_NO_R[] = { "test_privilege_control_rules2_r", "test_privilege_control_rules2_no_r", nullptr };
 
-const char *PRIVS_WGT[] = { "test_privilege_control_rules_wgt", NULL };
-const char *PRIVS_OSP[] = { "test_privilege_control_rules_osp", NULL };
-const char *PRIVS_EFL[] = { "test_privilege_control_rules_efl", NULL };
+const char *PRIVS_WGT[] = { "test_privilege_control_rules_wgt", nullptr };
+const char *PRIVS_OSP[] = { "test_privilege_control_rules_osp", nullptr };
+const char *PRIVS_EFL[] = { "test_privilege_control_rules_efl", nullptr };
 
-const char *PRIV_APPSETTING[] {"org.tizen.privilege.appsetting", NULL};
+const char *PRIV_APPSETTING[] {"org.tizen.privilege.appsetting", nullptr};
 const char *PRIV_APPSETTING_RULES[] = { "~APP~ ~SETTINGS_PATH~ rwx",
                                         "~APP~ ~ALL_APPS~ rx",
-                                        NULL};
+                                        nullptr};
 /**
  * Check if every rule is true.
  * @return 1 if ALL rules in SMACK, 0 if ANY rule isn't, -1 on failure
@@ -123,7 +123,7 @@ bool check_no_accesses(bool smack, const rules_t &rules)
 void read_gids(std::set<unsigned> &set, const char *file_path)
 {
     FILE *f = fopen(file_path, "r");
-    RUNNER_ASSERT_ERRNO_MSG(f != NULL, "Unable to open file " << file_path);
+    RUNNER_ASSERT_ERRNO_MSG(f != nullptr, "Unable to open file " << file_path);
     unsigned gid;
     while (fscanf(f, "%u\n", &gid) == 1) {
         set.insert(gid);
@@ -137,16 +137,16 @@ void read_user_gids(std::set<unsigned> &set, const uid_t user_id)
 
     errno = 0;
     struct passwd *pw = getpwuid(user_id);
-    RUNNER_ASSERT_ERRNO_MSG(pw != NULL, "getpwuid() failed");
+    RUNNER_ASSERT_ERRNO_MSG(pw != nullptr, "getpwuid() failed");
 
     int groups_cnt = 0;
-    gid_t *groups_list = NULL;
+    gid_t *groups_list = nullptr;
     ret = getgrouplist(pw->pw_name,  pw->pw_gid, groups_list, &groups_cnt);
     RUNNER_ASSERT_MSG(ret == -1, "getgrouplist() failed.");
     if (groups_cnt == 0)
         return;
     groups_list = (gid_t*) calloc(groups_cnt, sizeof(gid_t));
-    RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed.");
+    RUNNER_ASSERT_MSG(groups_list != nullptr, "Memory allocation failed.");
 
     ret = getgrouplist(pw->pw_name,  pw->pw_gid, groups_list, &groups_cnt);
     if (ret == -1) {
@@ -162,10 +162,10 @@ void read_user_gids(std::set<unsigned> &set, const uid_t user_id)
 
 void read_current_gids(std::set<unsigned> &set)
 {
-    int groups_cnt = getgroups(0, NULL);
+    int groups_cnt = getgroups(0, nullptr);
     RUNNER_ASSERT_ERRNO_MSG(groups_cnt > 0, "Wrong number of supplementary groups");
     gid_t *groups_list = (gid_t*) calloc(groups_cnt, sizeof(gid_t));
-    RUNNER_ASSERT_MSG(groups_list != NULL, "Memory allocation failed.");
+    RUNNER_ASSERT_MSG(groups_list != nullptr, "Memory allocation failed.");
     if (getgroups(groups_cnt, groups_list) == -1){
         free(groups_list);
         RUNNER_FAIL_MSG("getgroups failed.");
@@ -181,7 +181,7 @@ void check_groups(const std::set<unsigned> &groups_prev, const char *dac_file)
 {
     std::set<unsigned> groups_check;
     std::set<unsigned> groups_current;
-    if(dac_file != NULL)
+    if(dac_file != nullptr)
         read_gids(groups_check, dac_file);
     read_current_gids(groups_current);
 
@@ -230,9 +230,9 @@ void check_app_installed(const char *app_path)
 int nftw_remove_labels(const char *fpath, const struct stat* /*sb*/,
                        int /*typeflag*/, struct FTW* /*ftwbuf*/)
 {
-    smack_lsetlabel(fpath, NULL, SMACK_LABEL_ACCESS);
-    smack_lsetlabel(fpath, NULL, SMACK_LABEL_EXEC);
-    smack_lsetlabel(fpath, NULL, SMACK_LABEL_TRANSMUTE);
+    smack_lsetlabel(fpath, nullptr, SMACK_LABEL_ACCESS);
+    smack_lsetlabel(fpath, nullptr, SMACK_LABEL_EXEC);
+    smack_lsetlabel(fpath, nullptr, SMACK_LABEL_TRANSMUTE);
 
     return 0;
 }
@@ -257,13 +257,13 @@ int nftw_check_labels_app_dir(const char *fpath, const struct stat *sb,
 {
     int result;
     CStringPtr labelPtr;
-    char* label = NULL;
+    char* label = nullptr;
 
     /* ACCESS */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
     labelPtr.reset(label);
-    RUNNER_ASSERT_MSG(label != NULL, "ACCESS label on " << fpath << " is not set");
+    RUNNER_ASSERT_MSG(label != nullptr, "ACCESS label on " << fpath << " is not set");
     result = strcmp(correctLabel, label);
     RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is incorrect");
 
@@ -272,17 +272,17 @@ int nftw_check_labels_app_dir(const char *fpath, const struct stat *sb,
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
     labelPtr.reset(label);
     if (S_ISREG(sb->st_mode) && (sb->st_mode & S_IXUSR)) {
-        RUNNER_ASSERT_MSG(label != NULL, "EXEC label on " << fpath << " is not set");
+        RUNNER_ASSERT_MSG(label != nullptr, "EXEC label on " << fpath << " is not set");
         result = strcmp(correctLabel, label);
         RUNNER_ASSERT_MSG(result == 0, "EXEC label on executable file " << fpath << " is incorrect");
     } else
-        RUNNER_ASSERT_MSG(label == NULL, "EXEC label on " << fpath << " is set");
+        RUNNER_ASSERT_MSG(label == nullptr, "EXEC label on " << fpath << " is set");
 
     /* TRANSMUTE */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE);
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
     labelPtr.reset(label);
-    RUNNER_ASSERT_MSG(label == NULL, "TRANSMUTE label on " << fpath << " is set");
+    RUNNER_ASSERT_MSG(label == nullptr, "TRANSMUTE label on " << fpath << " is set");
 
     return 0;
 }
@@ -311,7 +311,7 @@ int nftw_check_labels_app_public_ro_dir(const char *fpath, const struct stat *sb
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
     labelPtr.reset(label);
-    RUNNER_ASSERT_MSG(label != NULL, "ACCESS label on " << fpath << " is not set");
+    RUNNER_ASSERT_MSG(label != nullptr, "ACCESS label on " << fpath << " is not set");
     result = strcmp(LABEL_FOR_PUBLIC_SHARED_DIRS, label);
     RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is incorrect");
 
@@ -319,18 +319,18 @@ int nftw_check_labels_app_public_ro_dir(const char *fpath, const struct stat *sb
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_EXEC);
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
     labelPtr.reset(label);
-    RUNNER_ASSERT_MSG(label == NULL, "EXEC label on " << fpath << " is set");
+    RUNNER_ASSERT_MSG(label == nullptr, "EXEC label on " << fpath << " is set");
 
     /* TRANSMUTE */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE);
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
     labelPtr.reset(label);
     if (S_ISDIR(sb->st_mode)) {
-        RUNNER_ASSERT_MSG(label != NULL, "TRANSMUTE label on " << fpath << " is not set");
+        RUNNER_ASSERT_MSG(label != nullptr, "TRANSMUTE label on " << fpath << " is not set");
         result = strcmp("TRUE", label);
         RUNNER_ASSERT_MSG(result == 0, "TRANSMUTE label on " << fpath << " is not set");
     } else
-        RUNNER_ASSERT_MSG(label == NULL, "TRANSMUTE label on " << fpath << " is set");
+        RUNNER_ASSERT_MSG(label == nullptr, "TRANSMUTE label on " << fpath << " is set");
 
     return 0;
 }
@@ -340,7 +340,7 @@ int nftw_set_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/,
 {
     smack_lsetlabel(fpath, CANARY_LABEL, SMACK_LABEL_ACCESS);
     smack_lsetlabel(fpath, CANARY_LABEL, SMACK_LABEL_EXEC);
-    smack_lsetlabel(fpath, NULL, SMACK_LABEL_TRANSMUTE);
+    smack_lsetlabel(fpath, nullptr, SMACK_LABEL_TRANSMUTE);
 
     return 0;
 }
@@ -350,7 +350,7 @@ int nftw_check_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/,
 {
     int result;
     CStringPtr labelPtr;
-    char* label = NULL;
+    char* label = nullptr;
 
     /* ACCESS */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
@@ -370,7 +370,7 @@ int nftw_check_labels_non_app_dir(const char *fpath, const struct stat* /*sb*/,
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_TRANSMUTE);
     labelPtr.reset(label);
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
-    RUNNER_ASSERT_MSG(labelPtr.get() == NULL, "TRANSMUTE label on " << fpath << " is set");
+    RUNNER_ASSERT_MSG(labelPtr.get() == nullptr, "TRANSMUTE label on " << fpath << " is set");
 
     return 0;
 }
index e1e96f8..f3a4a70 100644 (file)
@@ -232,7 +232,7 @@ void test_set_app_privilege(
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result >= 0,
             " Error getting current process label");
-    RUNNER_ASSERT_MSG(label != NULL,
+    RUNNER_ASSERT_MSG(label != nullptr,
             " Process label is not set");
 
     result = strcmp(USER_APP_ID, label);
@@ -279,60 +279,60 @@ RUNNER_TEST(privilege_control08_add_api_feature)
     DB_BEGIN
 
     // argument validation
-    result = perm_add_api_feature(APP_TYPE_OSP, NULL, NULL, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_OSP, nullptr, nullptr, nullptr, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
 
-    result = perm_add_api_feature(APP_TYPE_OSP,"", NULL, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_OSP,"", nullptr, nullptr, 0);
     RUNNER_ASSERT(result == PC_ERR_INVALID_PARAM);
 
 
     // Already existing feature:
     // TODO: Database will be malformed. (Rules for these features will be removed.)
-    result = perm_add_api_feature(APP_TYPE_OSP,"http://tizen.org/privilege/messaging.read", NULL, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_OSP,"http://tizen.org/privilege/messaging.read", nullptr, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
-    result = perm_add_api_feature(APP_TYPE_WGT,"http://tizen.org/privilege/messaging.sms", NULL, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_WGT,"http://tizen.org/privilege/messaging.sms", nullptr, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
     // empty features
-    result = perm_add_api_feature(APP_TYPE_OSP,"blahblah", NULL, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_OSP,"blahblah", nullptr, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
-    result = perm_add_api_feature(APP_TYPE_WGT,"blahblah", NULL, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_WGT,"blahblah", nullptr, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
     // empty rules
-    const char *test1[] = { NULL };
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[0].c_str(), test1, NULL, 0);
+    const char *test1[] = { nullptr };
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[0].c_str(), test1, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
-    const char *test2[] = { "", NULL };
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[1].c_str(), test2, NULL, 0);
+    const char *test2[] = { "", nullptr };
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[1].c_str(), test2, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
-    const char *test3[] = { " \t\n", "\t \n", "\n\t  ", NULL };
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[2].c_str(), test3, NULL, 0);
+    const char *test3[] = { " \t\n", "\t \n", "\n\t  ", nullptr };
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[2].c_str(), test3, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
     // malformed rules
-    const char *test4[] = { "malformed", NULL };
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[3].c_str(), test4, NULL, 0);
+    const char *test4[] = { "malformed", nullptr };
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[3].c_str(), test4, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
 
-    const char *test5[] = { "malformed malformed", NULL };
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[4].c_str(), test5, NULL, 0);
+    const char *test5[] = { "malformed malformed", nullptr };
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[4].c_str(), test5, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
 
-    const char *test6[] = { "-malformed malformed rwxat", NULL };
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[5].c_str(), test6, NULL, 0);
+    const char *test6[] = { "-malformed malformed rwxat", nullptr };
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[5].c_str(), test6, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
 
-    const char *test7[] = { "~/\"\\ malformed rwxat", NULL };
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[6].c_str(), test7, NULL, 0);
+    const char *test7[] = { "~/\"\\ malformed rwxat", nullptr };
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[6].c_str(), test7, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
 
-    const char *test8[] = { "subject object rwxat something else", NULL };
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[7].c_str(), test8, NULL, 0);
+    const char *test8[] = { "subject object rwxat something else", nullptr };
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[7].c_str(), test8, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_ERR_INVALID_PARAM, "perm_add_api_feature returned: " << result);
 
 
@@ -342,17 +342,17 @@ RUNNER_TEST(privilege_control08_add_api_feature)
             " \t \n",
             "subject2\t~APP~ ltxarw",
             "",
-            NULL};
+            nullptr};
 
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[8].c_str(), test9, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[8].c_str(), test9, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
-    const char *test10[] = { "Sub::jE,ct ~APP~ a-rwxl", NULL };
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[9].c_str(), test10, NULL, 0);
+    const char *test10[] = { "Sub::jE,ct ~APP~ a-rwxl", nullptr };
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[9].c_str(), test10, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
-    const char *test11[] = { "Sub::sjE,ct ~APP~ a-RwXL", NULL }; // TODO This fails.
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[10].c_str(), test11, NULL, 0);
+    const char *test11[] = { "Sub::sjE,ct ~APP~ a-RwXL", nullptr }; // TODO This fails.
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[10].c_str(), test11, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
 
@@ -362,12 +362,12 @@ RUNNER_TEST(privilege_control08_add_api_feature)
             " \t \n",
             "subject2 ~APP~ ltxarw",
             "",
-            NULL};
-    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[11].c_str(), test12, NULL, 0);
+            nullptr};
+    result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[11].c_str(), test12, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
 
     // empty group ids
-    const char *test13[] = { "~APP~ b a", NULL};
+    const char *test13[] = { "~APP~ b a", nullptr};
     result = perm_add_api_feature(APP_TYPE_OSP, BLAHBLAH_FEATURE[12].c_str(), test13,(const gid_t[]) {0,1,2},0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS, "perm_add_api_feature returned: " << result);
     result = file_exists(OSP_BLAHBLAH_DAC[12].c_str());
@@ -401,7 +401,7 @@ RUNNER_TEST(privilege_control08_add_api_feature)
 RUNNER_TEST_SMACK(privilege_control09_perm_add_api_feature_redefine)
 {
     int result;
-    const char *permissionName[] = { "org.tizen.test.permtoberedefined", NULL};
+    const char *permissionName[] = { "org.tizen.test.permtoberedefined", nullptr};
 
     // Rules to be used with the first check
     const rules_t test_rules1 = {
@@ -428,7 +428,7 @@ RUNNER_TEST_SMACK(privilege_control09_perm_add_api_feature_redefine)
         "~APP~ " PERM_TO_REDEFINE " rx",
         PERM_TO_REDEFINE " ~APP~ rwx",
         "~APP~ " PERM_SUB_TO_REDEFINE " rx",
-        NULL
+        nullptr
     };
 
     // Rules that contain differences - to be used with the second definition (re-def)
@@ -436,7 +436,7 @@ RUNNER_TEST_SMACK(privilege_control09_perm_add_api_feature_redefine)
         "~APP~ " PERM_TO_REDEFINE " rwx",
         PERM_TO_REDEFINE " ~APP~ rx",
         "~APP~ " PERM_SUB_TO_REDEFINE " watl",
-        NULL
+        nullptr
     };
 
     DB_BEGIN
@@ -450,7 +450,7 @@ RUNNER_TEST_SMACK(privilege_control09_perm_add_api_feature_redefine)
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
             "perm_app_install failed: " << perm_strerror(result));
 
-    result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules1, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules1, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
             "perm_add_api_feature failed: " << result);
 
@@ -467,7 +467,7 @@ RUNNER_TEST_SMACK(privilege_control09_perm_add_api_feature_redefine)
     DB_BEGIN
 
     // Redefine the permission
-    result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules2, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_OSP, permissionName[0], perm_rules2, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
             "perm_add_api_feature failed: " << result);
 
@@ -839,7 +839,7 @@ static void smack_unix_sock_server(int sock)
     char *smack_label;
 
     alarm(2);
-    fd = accept(sock, NULL, NULL);
+    fd = accept(sock, nullptr, nullptr);
     alarm(0);
     if (fd < 0)
         return;
@@ -918,7 +918,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(privilege_control15_app_id_from_socket)
 
             smack_label1[result] = '\0';
             smack_label2 = perm_app_id_from_socket(sock);
-            RUNNER_ASSERT_MSG(smack_label2 != NULL, "perm_app_id_from_socket failed");
+            RUNNER_ASSERT_MSG(smack_label2 != nullptr, "perm_app_id_from_socket failed");
             result = strcmp(smack_label1, smack_label2);
             RUNNER_ASSERT_MSG(result == 0, "smack labels differ: '" << smack_label1
                                  << "' != '" << smack_label2 << "-" << random() << "'");
index 2fbea88..077e248 100644 (file)
@@ -39,32 +39,32 @@ RUNNER_TEST_GROUP_INIT(libprivilegecontrol_incorrect_params)
 
 RUNNER_TEST(privilege_control21c_incorrect_params_perm_app_set_privilege)
 {
-    RUNNER_ASSERT_MSG(perm_app_set_privilege(NULL, NULL, APP_SET_PRIV_PATH) == PC_ERR_INVALID_PARAM,
-            "perm_app_set_privilege didn't check if package name isn't NULL.");
+    RUNNER_ASSERT_MSG(perm_app_set_privilege(nullptr, nullptr, APP_SET_PRIV_PATH) == PC_ERR_INVALID_PARAM,
+            "perm_app_set_privilege didn't check if package name isn't nullptr.");
 }
 
 RUNNER_TEST(privilege_control21d_incorrect_params_perm_app_install)
 {
-    RUNNER_ASSERT_MSG(perm_app_install(NULL) == PC_ERR_INVALID_PARAM,
-            "perm_app_install didn't check if pkg_id isn't NULL.");
+    RUNNER_ASSERT_MSG(perm_app_install(nullptr) == PC_ERR_INVALID_PARAM,
+            "perm_app_install didn't check if pkg_id isn't nullptr.");
     RUNNER_ASSERT_MSG(perm_app_install("") == PC_ERR_INVALID_PARAM,
             "perm_app_install didn't check if pkg_id isn't empty.");
 }
 
 RUNNER_TEST(privilege_control21e_incorrect_params_perm_app_uninstall)
 {
-    RUNNER_ASSERT_MSG(perm_app_uninstall(NULL) == PC_ERR_INVALID_PARAM,
-            "perm_app_uninstall didn't check if pkg_id isn't NULL.");
+    RUNNER_ASSERT_MSG(perm_app_uninstall(nullptr) == PC_ERR_INVALID_PARAM,
+            "perm_app_uninstall didn't check if pkg_id isn't nullptr.");
     RUNNER_ASSERT_MSG(perm_app_uninstall("") == PC_ERR_INVALID_PARAM,
             "perm_app_uninstall didn't check if pkg_id isn't empty.");
 }
 
 RUNNER_TEST(privilege_control21f_incorrect_params_perm_app_enable_permissions)
 {
-    RUNNER_ASSERT_MSG(perm_app_enable_permissions(APP_ID, APP_TYPE_OTHER, NULL, 1) == PC_ERR_INVALID_PARAM,
-            "perm_app_enable_permissions didn't check if perm_list isn't NULL.");
-    RUNNER_ASSERT_MSG(perm_app_enable_permissions(NULL, APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM,
-            "perm_app_enable_permissions didn't check if pkg_id isn't NULL.");
+    RUNNER_ASSERT_MSG(perm_app_enable_permissions(APP_ID, APP_TYPE_OTHER, nullptr, 1) == PC_ERR_INVALID_PARAM,
+            "perm_app_enable_permissions didn't check if perm_list isn't nullptr.");
+    RUNNER_ASSERT_MSG(perm_app_enable_permissions(nullptr, APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM,
+            "perm_app_enable_permissions didn't check if pkg_id isn't nullptr.");
     RUNNER_ASSERT_MSG(perm_app_enable_permissions("", APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM,
             "perm_app_enable_permissions didn't check if pkg_id isn't empty.");
     RUNNER_ASSERT_MSG(perm_app_enable_permissions("~APP~", APP_TYPE_OTHER, PRIVS2, 1) == PC_ERR_INVALID_PARAM,
@@ -73,8 +73,8 @@ RUNNER_TEST(privilege_control21f_incorrect_params_perm_app_enable_permissions)
 
 RUNNER_TEST(privilege_control21g_incorrect_params_app_revoke_permissions)
 {
-    RUNNER_ASSERT_MSG(perm_app_revoke_permissions(NULL) == PC_ERR_INVALID_PARAM,
-            "perm_app_revoke_permissions didn't check if pkg_id isn't NULL.");
+    RUNNER_ASSERT_MSG(perm_app_revoke_permissions(nullptr) == PC_ERR_INVALID_PARAM,
+            "perm_app_revoke_permissions didn't check if pkg_id isn't nullptr.");
     RUNNER_ASSERT_MSG(perm_app_revoke_permissions("") == PC_ERR_INVALID_PARAM,
             "perm_app_revoke_permissions didn't check if pkg_id isn't empty.");
     RUNNER_ASSERT_MSG(perm_app_revoke_permissions("~APP~") == PC_ERR_INVALID_PARAM,
@@ -83,8 +83,8 @@ RUNNER_TEST(privilege_control21g_incorrect_params_app_revoke_permissions)
 
 RUNNER_TEST(privilege_control21h_incorrect_params_app_reset_permissions)
 {
-    RUNNER_ASSERT_MSG(perm_app_reset_permissions(NULL) == PC_ERR_INVALID_PARAM,
-            "perm_app_reset_permissions didn't check if pkg_id isn't NULL.");
+    RUNNER_ASSERT_MSG(perm_app_reset_permissions(nullptr) == PC_ERR_INVALID_PARAM,
+            "perm_app_reset_permissions didn't check if pkg_id isn't nullptr.");
     RUNNER_ASSERT_MSG(perm_app_reset_permissions("") == PC_ERR_INVALID_PARAM,
             "perm_app_reset_permissions didn't check if pkg_id isn't empty.");
     RUNNER_ASSERT_MSG(perm_app_reset_permissions("~APP~") == PC_ERR_INVALID_PARAM,
@@ -93,10 +93,10 @@ RUNNER_TEST(privilege_control21h_incorrect_params_app_reset_permissions)
 
 RUNNER_TEST(privilege_control21i_incorrect_params_app_setup_path)
 {
-    RUNNER_ASSERT_MSG(perm_app_setup_path(APPID_DIR, NULL, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
-            "perm_app_setup_path didn't check if path isn't NULL.");
-    RUNNER_ASSERT_MSG(perm_app_setup_path(NULL, TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
-            "perm_app_setup_path didn't check if pkg_id isn't NULL.");
+    RUNNER_ASSERT_MSG(perm_app_setup_path(APPID_DIR, nullptr, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
+            "perm_app_setup_path didn't check if path isn't nullptr.");
+    RUNNER_ASSERT_MSG(perm_app_setup_path(nullptr, TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
+            "perm_app_setup_path didn't check if pkg_id isn't nullptr.");
     RUNNER_ASSERT_MSG(perm_app_setup_path("", TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
             "perm_app_setup_path didn't check if pkg_id isn't empty.");
     RUNNER_ASSERT_MSG(perm_app_setup_path("~APP~", TEST_APP_DIR, APP_PATH_PRIVATE) == PC_ERR_INVALID_PARAM,
@@ -105,18 +105,18 @@ RUNNER_TEST(privilege_control21i_incorrect_params_app_setup_path)
 
 RUNNER_TEST(privilege_control21k_incorrect_params_add_api_feature)
 {
-    RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, NULL, NULL, NULL, 0) == PC_ERR_INVALID_PARAM,
-            "perm_add_api_feature didn't check if api_feature_name isn't NULL.");
-    RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, "", NULL, NULL, 0) == PC_ERR_INVALID_PARAM,
+    RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, nullptr, nullptr, nullptr, 0) == PC_ERR_INVALID_PARAM,
+            "perm_add_api_feature didn't check if api_feature_name isn't nullptr.");
+    RUNNER_ASSERT_MSG(perm_add_api_feature(APP_TYPE_OSP, "", nullptr, nullptr, 0) == PC_ERR_INVALID_PARAM,
             "perm_add_api_feature didn't check if api_feature_name isn't empty.");
 }
 
 RUNNER_TEST(privilege_control21l_incorrect_params_ignored_disable_permissions)
 {
-    RUNNER_ASSERT_MSG(perm_app_disable_permissions(APP_ID, APP_TYPE_OTHER, NULL) == PC_ERR_INVALID_PARAM,
-            "perm_app_disable_permissions didn't check if perm_list isn't NULL.");
-    RUNNER_ASSERT_MSG(perm_app_disable_permissions(NULL, APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM,
-            "perm_app_disable_permissions didn't check if pkg_id isn't NULL.");
+    RUNNER_ASSERT_MSG(perm_app_disable_permissions(APP_ID, APP_TYPE_OTHER, nullptr) == PC_ERR_INVALID_PARAM,
+            "perm_app_disable_permissions didn't check if perm_list isn't nullptr.");
+    RUNNER_ASSERT_MSG(perm_app_disable_permissions(nullptr, APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM,
+            "perm_app_disable_permissions didn't check if pkg_id isn't nullptr.");
     RUNNER_ASSERT_MSG(perm_app_disable_permissions("", APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM,
             "perm_app_disable_permissions didn't check if pkg_id isn't empty.");
     RUNNER_ASSERT_MSG(perm_app_disable_permissions("~APP~", APP_TYPE_OTHER, PRIVS2) == PC_ERR_INVALID_PARAM,
@@ -128,16 +128,16 @@ RUNNER_TEST(privilege_control21m_incorrect_params_perm_app_has_permission)
     bool has_permission;
     const char *app_label = "test_app_label";
 
-    RUNNER_ASSERT_MSG(perm_app_has_permission(NULL, APP_TYPE_WGT,
+    RUNNER_ASSERT_MSG(perm_app_has_permission(nullptr, APP_TYPE_WGT,
                                               PRIVS2[0], &has_permission) == PC_ERR_INVALID_PARAM,
-            "perm_app_has_permission didn't check if pkg_id isn't NULL.");
+            "perm_app_has_permission didn't check if pkg_id isn't nullptr.");
     RUNNER_ASSERT_MSG(perm_app_has_permission(app_label, APP_TYPE_OTHER,
                                               PRIVS2[0], &has_permission) == PC_ERR_INVALID_PARAM,
             "perm_app_has_permission should not accept app_type = OTHER.");
     RUNNER_ASSERT_MSG(perm_app_has_permission(app_label, APP_TYPE_WGT,
-                                              NULL, &has_permission) == PC_ERR_INVALID_PARAM,
-            "perm_app_has_permission didn't check if permission_name isn't NULL.");
+                                              nullptr, &has_permission) == PC_ERR_INVALID_PARAM,
+            "perm_app_has_permission didn't check if permission_name isn't nullptr.");
     RUNNER_ASSERT_MSG(perm_app_has_permission(app_label, APP_TYPE_WGT,
-                                              PRIVS2[0], NULL) == PC_ERR_INVALID_PARAM,
-            "perm_app_has_permission didn't check if has_permission isn't NULL.");
+                                              PRIVS2[0], nullptr) == PC_ERR_INVALID_PARAM,
+            "perm_app_has_permission didn't check if has_permission isn't nullptr.");
 }
index 9aa0bd1..dcef042 100644 (file)
@@ -145,11 +145,11 @@ void test_set_app_privilege_nosmack(
             " Error in perm_app_set_privilege. Error: " << result);
 
     //Even though app privileges are set, no smack label should be extracted.
-    char* label = NULL;
+    char* label = nullptr;
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == -1,
             " new_label_from_self should return error (SMACK is off). Result: " << result);
-    RUNNER_ASSERT_MSG(label == NULL,
+    RUNNER_ASSERT_MSG(label == nullptr,
             " new_label_from_self shouldn't allocate memory for label.");
 
     check_groups(groups_before, dac_file);
@@ -179,16 +179,16 @@ RUNNER_CHILD_TEST_NOSMACK(privilege_control05_set_app_privilege_nosmack)
     read_user_gids(groups_before, APP_UID);
 
     //Set app privileges
-    result = perm_app_set_privilege(APP_ID, NULL, APP_SET_PRIV_PATH);
+    result = perm_app_set_privilege(APP_ID, nullptr, APP_SET_PRIV_PATH);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
             "Error in perm_app_set_privilege. Error: " << result);
 
     //Even though app privileges are set, no smack label should be extracted.
-    char* label = NULL;
+    char* label = nullptr;
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == -1,
             "new_label_from_self should return error (SMACK is off). Result: " << result);
-    RUNNER_ASSERT_MSG(label == NULL, "new_label_from_self shouldn't allocate memory for label.");
+    RUNNER_ASSERT_MSG(label == nullptr, "new_label_from_self shouldn't allocate memory for label.");
 
     //Check if DAC privileges really set
     RUNNER_ASSERT_MSG(getuid() == APP_UID, "Wrong UID");
@@ -200,7 +200,7 @@ RUNNER_CHILD_TEST_NOSMACK(privilege_control05_set_app_privilege_nosmack)
     result = strcmp(getenv("USER"), APP_USER_NAME);
     RUNNER_ASSERT_MSG(result == 0, "Wrong user USER NAME. Result: " << result);
 
-    check_groups(groups_before, NULL);
+    check_groups(groups_before, nullptr);
 }
 
 /**
@@ -381,7 +381,7 @@ RUNNER_TEST_NOSMACK(privilege_control13_app_reset_permissions_nosmack)
  *
  * This test works similarly to libsmack test smack09_new_label_from_socket. At first server and
  * client are created then sockets are set up and perm_app_id_from_socket is used. On NOSMACK env
- * correct behavior for perm_app_id_from_socket would be returning NULL label.
+ * correct behavior for perm_app_id_from_socket would be returning nullptr label.
  */
 RUNNER_MULTIPROCESS_TEST_NOSMACK(privilege_control15_app_id_from_socket_nosmack)
 {
@@ -413,7 +413,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(privilege_control15_app_id_from_socket_nosmack)
 
         //Accept connection
         alarm(2);
-        fd = accept(sock, NULL, NULL);
+        fd = accept(sock, nullptr, nullptr);
         alarm(0);
         RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "accept failed");
 
@@ -426,7 +426,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(privilege_control15_app_id_from_socket_nosmack)
         // Give server some time to setup listening socket
         sleep(1);
         int sock, result;
-        char* smack_label = NULL;
+        char* smack_label = nullptr;
 
         //Create socket
         sock = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -437,11 +437,11 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(privilege_control15_app_id_from_socket_nosmack)
         result = connect(sock, (struct sockaddr*) &sockaddr, sizeof(struct sockaddr_un));
         RUNNER_ASSERT_ERRNO_MSG(result == 0, "connect failed");
 
-        //Use perm_app_id_from_socket. Should fail and return NULL smack_label.
+        //Use perm_app_id_from_socket. Should fail and return nullptr smack_label.
         smack_label = perm_app_id_from_socket(sock);
         RUNNER_ASSERT_MSG(!smack_label, "perm_app_id_from_socket should fail.");
 
         //cleanup
-        RUNNER_ASSERT_MSG(smack_label == NULL, "perm_app_id_from_socket should fail.");
+        RUNNER_ASSERT_MSG(smack_label == nullptr, "perm_app_id_from_socket should fail.");
     }
 }
index 71277d6..fd4242a 100644 (file)
 // OSP Api Feature Test data - gives rxl access to OSP app and rl access to WGT app also!
 const char *test_osp_feature_rule_set[] = { "~APP~ " TEST_OSP_FEATURE_APP_ID " rxl",
                                             "~APP~ " TEST_WGT_FEATURE_APP_ID " rl",
-                                            NULL };
-const char *TEST_OSP_FEATURE_PRIVS[] = { TEST_OSP_FEATURE, NULL };
+                                            nullptr };
+const char *TEST_OSP_FEATURE_PRIVS[] = { TEST_OSP_FEATURE, nullptr };
 // WGT Api Feature Test data - rwx access only to WGT app
 const char *test_wgt_feature_rule_set[] = { "~APP~ " TEST_WGT_FEATURE_APP_ID " rwx",
-                                            NULL };
-const char *TEST_WGT_FEATURE_PRIVS[] = { TEST_WGT_FEATURE, NULL };
+                                            nullptr };
+const char *TEST_WGT_FEATURE_PRIVS[] = { TEST_WGT_FEATURE, nullptr };
 
 rules_t rules_to_test_any_access1 = {
       { TEST_OSP_FEATURE_APP_ID, APP_ID, "r" },
@@ -121,7 +121,7 @@ void privilege_control22_app_installation_1x100(bool smack)
                   "Error in perm_app_install. Result: " << result);
 
     // Register appsettings feature
-    result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
                  " Error while registering api feature. Result: " << result);
 
@@ -140,7 +140,7 @@ void privilege_control22_app_installation_1x100(bool smack)
     result = perm_app_install(TEST_OSP_FEATURE_APP_ID);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
                   "Error in perm_app_install. Result: " << result);
-    const char *test1[] = { NULL };
+    const char *test1[] = { nullptr };
     result = perm_app_enable_permissions(TEST_OSP_FEATURE_APP_ID,
                                         APP_TYPE_OSP, test1, true);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
@@ -148,13 +148,13 @@ void privilege_control22_app_installation_1x100(bool smack)
 
     // Register two valid api features
     result = perm_add_api_feature(APP_TYPE_OSP, TEST_OSP_FEATURE,
-                                  test_osp_feature_rule_set, NULL, 0);
+                                  test_osp_feature_rule_set, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
                   "Error in perm_add_api_feature. Cannot add TEST_OSP_FEATURE: "
                   << TEST_OSP_FEATURE << ". Result: " << result);
 
     result = perm_add_api_feature(APP_TYPE_WGT, TEST_WGT_FEATURE,
-                                  test_wgt_feature_rule_set, NULL, 0);
+                                  test_wgt_feature_rule_set, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
                   "Error in perm_add_api_feature. Cannot add TEST_WGT_FEATURE: "
                   << TEST_WGT_FEATURE << ". Result: " << result);
@@ -395,12 +395,12 @@ void privilege_control23_app_installation2_10x10(bool smack)
                                                  "~APP~ " APP_ID "7 rxl",
                                                  "~APP~ " APP_ID "8 rwxal",
                                                  "~APP~ " APP_ID "9 rwxatl",
-                                                 NULL };
+                                                 nullptr };
     const char *test_wgt_feature_rule_set2[] = { "~APP~ " APP_ID "1 r",
                                                  "~APP~ " APP_ID "2 rxl",
                                                  "~APP~ " APP_ID "3 rwxal",
                                                  "~APP~ " APP_ID "4 rwxatl",
-                                                 NULL };
+                                                 nullptr };
 
 
     // generate app ids: test_APP0, test_APP1, test_APP2 etc.:
@@ -441,7 +441,7 @@ void privilege_control23_app_installation2_10x10(bool smack)
                       << " Result: " << result);
 
     // Register appsettings feature
-    result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, NULL, 0);
+    result = perm_add_api_feature(APP_TYPE_OSP, PRIV_APPSETTING[0], PRIV_APPSETTING_RULES, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
                  " Error while registering api feature. Result: " << result);
 
@@ -453,13 +453,13 @@ void privilege_control23_app_installation2_10x10(bool smack)
 
     // Register two valid api features
     result = perm_add_api_feature(APP_TYPE_OSP, TEST_OSP_FEATURE,
-                                  test_osp_feature_rule_set2, NULL, 0);
+                                  test_osp_feature_rule_set2, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
                   "Error in perm_add_api_feature. Cannot add TEST_OSP_FEATURE: "
                   << TEST_OSP_FEATURE << ". Result: " << result);
 
     result = perm_add_api_feature(APP_TYPE_WGT, TEST_WGT_FEATURE,
-                                  test_wgt_feature_rule_set2, NULL, 0);
+                                  test_wgt_feature_rule_set2, nullptr, 0);
     RUNNER_ASSERT_MSG(result == PC_OPERATION_SUCCESS,
                   "Error in perm_add_api_feature. Cannot add TEST_WGT_FEATURE: "
                   << TEST_WGT_FEATURE << ". Result: " << result);
index 6ae3ea4..8ec7bd2 100644 (file)
@@ -128,7 +128,7 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_1){
 
     clean_up();
 
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
     RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
     SmackAccessesPtr rules_ptr(rules);
 
@@ -150,7 +150,7 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_1){
  */
 RUNNER_TEST_SMACK(smack_accesses_add_modify_test_2){
     int result;
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
     RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
     SmackAccessesPtr rules_ptr(rules);
 
@@ -178,7 +178,7 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_2){
  */
 RUNNER_TEST_SMACK(smack_accesses_add_modify_test_3){
     int result;
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
     RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
     SmackAccessesPtr rules_ptr(rules);
 
@@ -212,7 +212,7 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_3){
  */
 RUNNER_TEST_SMACK(smack_accesses_add_modify_test_4){
     int result;
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
     RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
     SmackAccessesPtr rules_ptr(rules);
 
@@ -242,7 +242,7 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_4){
  */
 RUNNER_TEST_SMACK(smack_accesses_add_modify_test_5){
     int result;
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
     RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
     SmackAccessesPtr rules_ptr(rules);
 
@@ -271,7 +271,7 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_5){
  */
 RUNNER_TEST_SMACK(smack_accesses_add_modify_test_6){
     int result;
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
     RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
     SmackAccessesPtr rules_ptr(rules);
 
@@ -302,7 +302,7 @@ RUNNER_TEST_SMACK(smack_accesses_add_modify_test_7){
     unsigned int i;
     int result;
 
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
 
     for (i = 0; i < accessesBasic.size(); ++i) {
         RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
@@ -328,7 +328,7 @@ RUNNER_TEST_SMACK(smack_revoke_subject_test_1){
     unsigned int i;
     int result;
 
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
 
     for (i = 0; i < accessesBasic.size(); ++i) {
         // Creating and adding rules with TEST_OBJECT and TEST_OBJECT_2
@@ -377,7 +377,7 @@ RUNNER_TEST_SMACK(smack_accesses_clear_test_1){
     unsigned int i;
     int result;
 
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
 
     for (i = 0; i < accessesBasic.size(); ++i) {
         // Creating and adding rules with TEST_OBJECT and TEST_OBJECT_2
@@ -444,8 +444,8 @@ RUNNER_TEST(smack01_storing_and_restoring_rules)
      * expect: Rules created and stored in file should be identical to predefined template.
      */
 
-    struct smack_accesses *rules = NULL;        //rules prepared in this test case
-    struct smack_accesses *import_test = NULL;  //rules imported from file
+    struct smack_accesses *rules = nullptr;        //rules prepared in this test case
+    struct smack_accesses *import_test = nullptr;  //rules imported from file
 
     int result;             //result of each operation to be tested by RUNNER_ASSERT
     int fd, tmp, sample;    //file descripptors for save / restore rules tests
@@ -508,7 +508,7 @@ RUNNER_TEST_SMACK(smack02_aplying_rules_into_kernel)
 
     //CAP_MAC_ADMIN needed for process to be able to change rules in kernel (apllying, removing)
 
-    struct smack_accesses *rules = NULL;        //rules prepared in this test case
+    struct smack_accesses *rules = nullptr;        //rules prepared in this test case
     int result;                                 //for storing functions results
 
     RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
@@ -585,7 +585,7 @@ RUNNER_TEST_SMACK(smack03_mixed_rule_string_add)
     //In thist test case mixed string are used as rules applied to kernel, next they are
     //readed and compared with correct form of rules
 
-    struct smack_accesses *rules = NULL;        //rules prepared in this test case
+    struct smack_accesses *rules = nullptr;        //rules prepared in this test case
     int result;                                 //for storing functions results
     int expected;
 
@@ -674,7 +674,7 @@ RUNNER_TEST_SMACK(smack05_self_label)
 
     //In this test case process will manipulate it own label
 
-    char *label = NULL;
+    char *label = nullptr;
     int result;
     int fd;
 
@@ -795,8 +795,8 @@ RUNNER_TEST_SMACK(smack06_setlabel_getlabel_test_2)
     fs.testSmackGetLabel(linkPath, testLabelExec, SMACK_LABEL_EXEC);
 
     // link labels should not be changed
-    fs.testSmackLGetLabel(linkPath, NULL, SMACK_LABEL_ACCESS);
-    fs.testSmackLGetLabel(linkPath, NULL, SMACK_LABEL_EXEC);
+    fs.testSmackLGetLabel(linkPath, nullptr, SMACK_LABEL_ACCESS);
+    fs.testSmackLGetLabel(linkPath, nullptr, SMACK_LABEL_EXEC);
 }
 
 RUNNER_TEST_SMACK(smack06_lsetlabel_lgetlabel_test_1)
@@ -852,7 +852,7 @@ RUNNER_TEST_SMACK(smack10_adding_removing_rules)
     unsigned int i;
     int result;
 
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
 
     for (i = 0; i < accessesBasic.size(); ++i)
     {
@@ -998,7 +998,7 @@ RUNNER_TEST_SMACK(smack11_saving_loading_rules)
     int result;
     int fd;
 
-    struct smack_accesses *rules = NULL;
+    struct smack_accesses *rules = nullptr;
 
     // Pre-cleanup
     removeAccessesAll();
@@ -1136,7 +1136,7 @@ RUNNER_TEST_SMACK(smack11_saving_loading_rules)
 
 static void smack_set_another_label_for_self(void)
 {
-    static int number = time(NULL);
+    static int number = time(nullptr);
 
     number++;
     std::string smack_label("s" + std::to_string(number));
@@ -1151,7 +1151,7 @@ static void smack_unix_sock_server(int sock)
     char *label;
 
     alarm(2);
-    fd = accept(sock, NULL, NULL);
+    fd = accept(sock, nullptr, nullptr);
     alarm(0);
     RUNNER_ASSERT_ERRNO(fd >= 0);
     FdUniquePtr fd_ptr(&fd);
@@ -1251,7 +1251,7 @@ void createFileWithLabel(const std::string &filePath, const std::string &fileLab
     ret = smack_setlabel(filePath.c_str(), fileLabel.c_str(), SMACK_LABEL_ACCESS);
     RUNNER_ASSERT_MSG(ret == 0, "Unable to set label for file: " << ret);
 
-    char *label = NULL;
+    char *label = nullptr;
     ret = smack_getlabel(filePath.c_str(), &label, SMACK_LABEL_ACCESS);
     RUNNER_ASSERT_MSG(ret == 0, "Unable to get label from file");
     std::string label_str(label ? label : "");
@@ -1531,7 +1531,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(smack13_4_3_checking_laccess_mode_l_rule_child)
 RUNNER_TEST_NOSMACK(smack02_aplying_rules_into_kernel_nosmack)
 {
 
-    smack_accesses *rules = NULL;
+    smack_accesses *rules = nullptr;
     int result;
 
     //init rules
@@ -1592,7 +1592,7 @@ RUNNER_TEST_NOSMACK(smack03_saving_loading_rules_nosmack)
     int result;
     int fd;
 
-    smack_accesses* tmp = NULL;
+    smack_accesses* tmp = nullptr;
 
     RUNNER_ASSERT(smack_accesses_new(&tmp) == 0);
     SmackAccessesPtr rules(tmp);
@@ -1613,7 +1613,7 @@ RUNNER_TEST_NOSMACK(smack03_saving_loading_rules_nosmack)
  */
 RUNNER_TEST_NOSMACK(smack04_self_label_nosmack)
 {
-    char* label = NULL;
+    char* label = nullptr;
     int result;
     int fd;
 
@@ -1622,8 +1622,8 @@ RUNNER_TEST_NOSMACK(smack04_self_label_nosmack)
     //smack_new_label_from_self should fail
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == -1, "new_label_from_self should return error (SMACK is off).");
-    RUNNER_ASSERT_MSG(label == NULL, "new_label_from_self shouldn't allocate memory to label.");
-    //We don't need to remember about freeing label - smack_new_label_from_self must return NULL
+    RUNNER_ASSERT_MSG(label == nullptr, "new_label_from_self shouldn't allocate memory to label.");
+    //We don't need to remember about freeing label - smack_new_label_from_self must return nullptr
     //label if it's working properly.
 
     // /proc/self/attr/current shouldn't keep any rules inside
@@ -1641,7 +1641,7 @@ RUNNER_TEST_NOSMACK(smack04_self_label_nosmack)
     //getting previously set label should also fail
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result == -1, "new_label_from_self should return error (SMACK is off).");
-    RUNNER_ASSERT_MSG(label == NULL, "new_label_from_self shouldn't allocate memory to label.");
+    RUNNER_ASSERT_MSG(label == nullptr, "new_label_from_self shouldn't allocate memory to label.");
 
     // /proc/self/attr/current still shouldn't keep any rules inside
     result = lseek(fd, 0, SEEK_SET);    //going to the file beginning
@@ -1662,7 +1662,7 @@ RUNNER_TEST_NOSMACK(smack04_self_label_nosmack)
 RUNNER_TEST_NOSMACK(smack05_accesses_add_modify_nosmack)
 {
     int result;
-    smack_accesses* rules = NULL;
+    smack_accesses* rules = nullptr;
 
     RUNNER_ASSERT(smack_accesses_new(&rules) == 0);
 
@@ -1726,7 +1726,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(smack09_new_label_from_socket_nosmack)
 
         //Accept client
         alarm(2);
-        fd = accept(sock, NULL, NULL);
+        fd = accept(sock, nullptr, nullptr);
         alarm(0);
         RUNNER_ASSERT_ERRNO_MSG(fd >= 0, "Failed when accepting connection from client");
         FdUniquePtr fd_ptr(&fd);
index a8a0ffe..ecebb28 100644 (file)
Binary files a/tests/perf and b/tests/perf differ
index 6b63560..eac5194 100644 (file)
@@ -65,7 +65,7 @@ static bool isLinkToExec(const char *fpath, const struct stat *sb)
     if ( !S_ISLNK(sb->st_mode))
         return false;
 
-    target = realpath(fpath, NULL);
+    target = realpath(fpath, nullptr);
     RUNNER_ASSERT_ERRNO_MSG(target != 0, "Could not obtain real path from link");
 
     ret = stat(target, &buf);
@@ -83,13 +83,13 @@ static int nftw_check_sm_labels_app_dir(const char *fpath, const struct stat *sb
 {
     int result;
     CStringPtr labelPtr;
-    char* label = NULL;
+    char* label = nullptr;
 
     /* ACCESS */
     result = smack_lgetlabel(fpath, &label, SMACK_LABEL_ACCESS);
     RUNNER_ASSERT_MSG(result == 0, "Could not get label for the path");
     labelPtr.reset(label);
-    RUNNER_ASSERT_MSG(label != NULL, "ACCESS label on " << fpath << " is not set");
+    RUNNER_ASSERT_MSG(label != nullptr, "ACCESS label on " << fpath << " is not set");
     result = strcmp(correctLabel, label);
     RUNNER_ASSERT_MSG(result == 0, "ACCESS label on " << fpath << " is incorrect"
             " (should be '" << correctLabel << "' and is '" << label << "')");
@@ -101,11 +101,11 @@ static int nftw_check_sm_labels_app_dir(const char *fpath, const struct stat *sb
     labelPtr.reset(label);
 
     if (S_ISREG(sb->st_mode) && (sb->st_mode & S_IXUSR) && exec_test) {
-        RUNNER_ASSERT_MSG(label != NULL, "EXEC label on " << fpath << " is not set");
+        RUNNER_ASSERT_MSG(label != nullptr, "EXEC label on " << fpath << " is not set");
         result = strcmp(correctLabel, label);
         RUNNER_ASSERT_MSG(result == 0, "Incorrect EXEC label on executable file " << fpath);
     } else
-        RUNNER_ASSERT_MSG(label == NULL, "EXEC label on " << fpath << " is set");
+        RUNNER_ASSERT_MSG(label == nullptr, "EXEC label on " << fpath << " is set");
 
 
     /* LINK TO EXEC */
@@ -127,11 +127,11 @@ static int nftw_check_sm_labels_app_dir(const char *fpath, const struct stat *sb
     labelPtr.reset(label);
 
     if (S_ISDIR(sb->st_mode) && transmute_test == true) {
-        RUNNER_ASSERT_MSG(label != NULL, "TRANSMUTE label on " << fpath << " is not set at all");
+        RUNNER_ASSERT_MSG(label != nullptr, "TRANSMUTE label on " << fpath << " is not set at all");
         RUNNER_ASSERT_MSG(strcmp(label,"TRUE") == 0,
                 "TRANSMUTE label on " << fpath << " is not set properly: '"<<label<<"'");
     } else {
-        RUNNER_ASSERT_MSG(label == NULL, "TRANSMUTE label on " << fpath << " is set");
+        RUNNER_ASSERT_MSG(label == nullptr, "TRANSMUTE label on " << fpath << " is set");
     }
 
     return 0;
@@ -161,12 +161,12 @@ static int nftw_check_sm_labels_app_floor_dir(const char *fpath, const struct st
 static app_inst_req* do_app_inst_req_new()
 {
     int result;
-    app_inst_req *req = NULL;
+    app_inst_req *req = nullptr;
 
     result = security_manager_app_inst_req_new(&req);
     RUNNER_ASSERT_MSG((lib_retcode)result == SECURITY_MANAGER_SUCCESS,
             "creation of new request failed. Result: " << result);
-    RUNNER_ASSERT_MSG(req != NULL, "creation of new request did not allocate memory");
+    RUNNER_ASSERT_MSG(req != nullptr, "creation of new request did not allocate memory");
     return req;
 }
 
@@ -422,7 +422,7 @@ RUNNER_CHILD_TEST_SMACK(security_manager_03_set_label_from_binary)
     const char *const testBinaryPath    = LABELLED_BINARY_PATH;
     const char *const expectedLabel     = USER_APP_ID;
     int result;
-    char *label = NULL;
+    char *label = nullptr;
     CStringPtr labelPtr;
 
     result = security_manager_set_process_label_from_binary(testBinaryPath);
@@ -433,7 +433,7 @@ RUNNER_CHILD_TEST_SMACK(security_manager_03_set_label_from_binary)
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result >= 0,
             " Error getting current process label");
-    RUNNER_ASSERT_MSG(label != NULL,
+    RUNNER_ASSERT_MSG(label != nullptr,
             " Process label is not set");
     labelPtr.reset(label);
 
@@ -459,7 +459,7 @@ RUNNER_CHILD_TEST_SMACK(security_manager_04_set_label_from_appid)
     const char *const app_id = "sm_test_app_id_set_label_from_appid";
     const char *const pkg_id = "sm_test_pkg_id_set_label_from_appid";
     const char *const expected_label = USER_APP_ID;
-    char *label = NULL;
+    char *label = nullptr;
     CStringPtr labelPtr;
     int result;
 
@@ -474,7 +474,7 @@ RUNNER_CHILD_TEST_SMACK(security_manager_04_set_label_from_appid)
     result = smack_new_label_from_self(&label);
     RUNNER_ASSERT_MSG(result >= 0,
             " Error getting current process label");
-    RUNNER_ASSERT_MSG(label != NULL,
+    RUNNER_ASSERT_MSG(label != nullptr,
             " Process label is not set");
     labelPtr.reset(label);
 
index e6332d6..adb9569 100644 (file)
@@ -53,10 +53,10 @@ RUNNER_TEST_GROUP_INIT(COOKIE_API_TESTS)
  */
 
 //---------------------------------------------------------------------------
-//passing NULL as a buffer pointer
+//passing nullptr as a buffer pointer
 RUNNER_CHILD_TEST(tc_arguments_01_01_security_server_request_cookie)
 {
-    int ret = security_server_request_cookie(NULL, KNOWN_COOKIE_SIZE);
+    int ret = security_server_request_cookie(nullptr, KNOWN_COOKIE_SIZE);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
                       "Error in security_server_request_cookie() argument checking: " << ret);
 }
@@ -72,54 +72,54 @@ RUNNER_CHILD_TEST(tc_arguments_01_02_security_server_request_cookie)
 }
 
 //---------------------------------------------------------------------------
-//passing NULL as a cookie pointer
+//passing nullptr as a cookie pointer
 RUNNER_CHILD_TEST(tc_arguments_02_01_security_server_check_privilege)
 {
-    int ret = security_server_check_privilege(NULL, 0);
+    int ret = security_server_check_privilege(nullptr, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
                       "Error in security_server_check_privilege() argument checking: " << ret);
 }
 
 //---------------------------------------------------------------------------
-//passing NULL as a cookie pointer
+//passing nullptr as a cookie pointer
 RUNNER_CHILD_TEST(tc_arguments_03_01_security_server_check_privilege_by_cookie)
 {
     RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
-    int ret = security_server_check_privilege_by_cookie(NULL, "wiadro", "rwx");
+    int ret = security_server_check_privilege_by_cookie(nullptr, "wiadro", "rwx");
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
                       "Error in security_server_check_privilege_by_cookie() argument checking: "
                       << ret);
 }
 
-//passing NULL as an object pointer
+//passing nullptr as an object pointer
 RUNNER_CHILD_TEST(tc_arguments_03_02_security_server_check_privilege_by_cookie)
 {
     RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
     Cookie cookie = getCookieFromSS();
 
-    int ret = security_server_check_privilege_by_cookie(cookie.data(), NULL, "rwx");
+    int ret = security_server_check_privilege_by_cookie(cookie.data(), nullptr, "rwx");
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
                       "Error in security_server_check_privilege_by_cookie() argument checking: "
                       << ret);
 }
 
-//passing NULL as an access pointer
+//passing nullptr as an access pointer
 RUNNER_CHILD_TEST(tc_arguments_03_03_security_server_check_privilege_by_cookie)
 {
     RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
     Cookie cookie = getCookieFromSS();
 
-    int ret = security_server_check_privilege_by_cookie(cookie.data(), "wiadro", NULL);
+    int ret = security_server_check_privilege_by_cookie(cookie.data(), "wiadro", nullptr);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
                       "Error in security_server_check_privilege_by_cookie() argument checking: "
                       << ret);
 }
 
 //---------------------------------------------------------------------------
-//passing NULL as a cookie pointer
+//passing nullptr as a cookie pointer
 RUNNER_CHILD_TEST(tc_arguments_04_01_security_server_get_cookie_pid)
 {
-    int ret = security_server_get_cookie_pid(NULL);
+    int ret = security_server_get_cookie_pid(nullptr);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM,
                       "Error in security_server_get_cookie_pid() argument checking: " << ret);
 }
@@ -133,12 +133,12 @@ RUNNER_TEST(tc_arguments_04_02_security_server_get_cookie_pid)
 }
 
 //---------------------------------------------------------------------------
-//passing NULL as a cookie pointer
+//passing nullptr as a cookie pointer
 RUNNER_CHILD_TEST(tc_arguments_05_01_security_server_get_smacklabel_cookie)
 {
-    char *label = NULL;
-    label = security_server_get_smacklabel_cookie(NULL);
-    RUNNER_ASSERT_MSG(label == NULL,
+    char *label = nullptr;
+    label = security_server_get_smacklabel_cookie(nullptr);
+    RUNNER_ASSERT_MSG(label == nullptr,
                       "Error in security_server_get_smacklabel_cookie() argument checking");
 }
 
@@ -412,8 +412,8 @@ RUNNER_CHILD_TEST_NOSMACK(tc_unit_06_01_security_server_get_smacklabel_cookie_no
     Cookie cookie = getCookieFromSS();
 
     char *receivedLabel = security_server_get_smacklabel_cookie(cookie.data());
-    RUNNER_ASSERT_MSG(receivedLabel != NULL,
-                         "security_server_get_smacklabel_cookie returned NULL");
+    RUNNER_ASSERT_MSG(receivedLabel != nullptr,
+                         "security_server_get_smacklabel_cookie returned nullptr");
     std::string label(receivedLabel);
     free(receivedLabel);
     RUNNER_ASSERT_MSG(label.empty(),
@@ -430,8 +430,8 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_06_02_app_user_security_server_get_smacklabel_co
     provider.applyAndSwithToUser(APP_UID, APP_GID);
 
     CStringPtr label(security_server_get_smacklabel_cookie(cookie.data()));
-    RUNNER_ASSERT_MSG(label.get() == NULL,
-                      "NULL should be received due to access denied, received label: "
+    RUNNER_ASSERT_MSG(label.get() == nullptr,
+                      "nullptr should be received due to access denied, received label: "
                       << label.get());
 }
 
@@ -476,7 +476,7 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_09_01_app_user_cookie_API_access_allow)
     RUNNER_ASSERT_MSG(ret == getpid(), "ret: " << ret);
 
     CStringPtr ss_label(security_server_get_smacklabel_cookie(cookie.data()));
-    RUNNER_ASSERT_MSG(ss_label.get() != NULL, "ss_label: " << ss_label.get());
+    RUNNER_ASSERT_MSG(ss_label.get() != nullptr, "ss_label: " << ss_label.get());
 
     RUNNER_IGNORED_MSG("security_server_check_privilege_by_cookie is temporarily disabled: always returns success");
 
@@ -509,8 +509,8 @@ RUNNER_CHILD_TEST_SMACK(tc_unit_09_02_app_user_cookie_API_access_deny)
             "ret: " << ret);
 
     CStringPtr ss_label(security_server_get_smacklabel_cookie(cookie.data()));
-    RUNNER_ASSERT_MSG(ss_label.get() == NULL,
-            "access should be denied so label should be NULL: " << ss_label.get());
+    RUNNER_ASSERT_MSG(ss_label.get() == nullptr,
+            "access should be denied so label should be nullptr: " << ss_label.get());
 
     RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success");
 
@@ -548,7 +548,7 @@ RUNNER_CHILD_TEST_NOSMACK(tc_unit_09_01_app_user_cookie_API_access_allow_nosmack
             "get_cookie_pid returned different pid than it should. Result: " << ret);
 
     CStringPtr ss_label(security_server_get_smacklabel_cookie(cookie.data()));
-    RUNNER_ASSERT_MSG(ss_label.get() != NULL, "get_smacklabel_cookie failed.");
+    RUNNER_ASSERT_MSG(ss_label.get() != nullptr, "get_smacklabel_cookie failed.");
 
     RUNNER_IGNORED_MSG("security_server_check_privilege_by_sockfd is temporarily disabled: always returns success");
 
index 9d64994..f9da513 100644 (file)
@@ -102,7 +102,7 @@ int my_nanosecsleep(long nanoseconds) {
     timespec sleep_spec;
     sleep_spec.tv_sec = 0;
     sleep_spec.tv_nsec = nanoseconds;
-    return nanosleep(&sleep_spec, NULL);
+    return nanosleep(&sleep_spec, nullptr);
 }
 
 /**Read from pipe descriptor to buffer; retries if less than count bytes were read.
@@ -166,7 +166,7 @@ int communication_succeeded(int result_code) {
 */
 timeval my_gettime() {
     timeval t;
-    int res = gettimeofday(&t, NULL);
+    int res = gettimeofday(&t, nullptr);
     RUNNER_ASSERT_ERRNO_MSG(res == 0, "gettimeofday() returned error value: " << res);
     return t;
 }
index 4f9b1e1..194584e 100644 (file)
@@ -140,7 +140,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc06_check_privilege_by_sockfd)
         SockUniquePtr sockfd_ptr(&sockfd);
 
         label = security_server_get_smacklabel_sockfd(sockfd);
-        RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
+        RUNNER_ASSERT_MSG(label != nullptr, "security_server_get_smacklabel_sockfd failed");
         RUNNER_ASSERT_MSG(strcmp(label,"") == 0, "label is \"" << label << "\"");
         free(label);
 
@@ -149,7 +149,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc06_check_privilege_by_sockfd)
         RUNNER_ASSERT_ERRNO_MSG(listen(sockfd, 5) >= 0, "child listen failed");
 
         label = security_server_get_smacklabel_sockfd(sockfd);
-        RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
+        RUNNER_ASSERT_MSG(label != nullptr, "security_server_get_smacklabel_sockfd failed");
         RUNNER_ASSERT_MSG(strcmp(label,"") == 0, "label is \"" << label << "\"");
         free(label);
 
@@ -172,7 +172,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc06_check_privilege_by_sockfd)
         SockUniquePtr sockfd_ptr(&sockfd);
 
         label = security_server_get_smacklabel_sockfd(sockfd);
-        RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
+        RUNNER_ASSERT_MSG(label != nullptr, "security_server_get_smacklabel_sockfd failed");
         RUNNER_ASSERT_MSG(strcmp(label,subject_label) == 0, "label is \"" << label << "\"" << ", subject_label is \"" << subject_label << "\"" );
         free(label);
 
@@ -347,7 +347,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc06_check_privilege_by_sockfd_nosmack)
 
         //check if get_smacklabel_sockfd works correctly
         label = security_server_get_smacklabel_sockfd(sockfd);
-        RUNNER_ASSERT_MSG(label != NULL, "security_server_get_smacklabel_sockfd failed");
+        RUNNER_ASSERT_MSG(label != nullptr, "security_server_get_smacklabel_sockfd failed");
         ret = strcmp(label, "");
         free(label);
         RUNNER_ASSERT_MSG(ret == 0, "label is \"" << label << "\"");
@@ -378,7 +378,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc06_check_privilege_by_sockfd_nosmack)
         SockUniquePtr sockfd_ptr(&sockfd);
 
         label = security_server_get_smacklabel_sockfd(sockfd);
-        RUNNER_ASSERT_MSG(label != NULL, "get_smacklabel_sockfd failed.");
+        RUNNER_ASSERT_MSG(label != nullptr, "get_smacklabel_sockfd failed.");
         ret = strcmp(label, "");
         free(label);
         RUNNER_ASSERT_MSG(ret == 0, "label is \"" << label << "\"");
@@ -463,15 +463,15 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc07_check_privilege_by_sockfd_nosmack)
 RUNNER_TEST_SMACK(tc18_security_server_get_smacklabel_cookie) {
     int res;
 
-    char *label_smack = NULL;
-    char *label_ss = NULL;
-    char *cookie = NULL;
+    char *label_smack = nullptr;
+    char *label_ss = nullptr;
+    char *cookie = nullptr;
 
     int cookie_size = security_server_get_cookie_size();
     RUNNER_ASSERT_MSG(PROPER_COOKIE_SIZE == cookie_size, "Wrong cookie size from security-server");
 
     cookie = (char*) calloc(cookie_size, 1);
-    RUNNER_ASSERT_MSG(NULL != cookie, "Memory allocation error");
+    RUNNER_ASSERT_MSG(nullptr != cookie, "Memory allocation error");
 
     res = security_server_request_cookie(cookie, cookie_size);
     if (res != SECURITY_SERVER_API_SUCCESS) {
@@ -481,7 +481,7 @@ RUNNER_TEST_SMACK(tc18_security_server_get_smacklabel_cookie) {
 
     label_ss = security_server_get_smacklabel_cookie(cookie);
     free(cookie);
-    RUNNER_ASSERT_MSG(label_ss != NULL, "Error in getting label by cookie");
+    RUNNER_ASSERT_MSG(label_ss != nullptr, "Error in getting label by cookie");
 
 
     std::string label_cookie(label_ss);
@@ -506,32 +506,32 @@ RUNNER_TEST_SMACK(tc18_security_server_get_smacklabel_cookie) {
  * NOSMACK version of tc_security_server_get_smacklabel_cookie test.
  *
  * Most of this test goes exactly as the original one. The only difference are the labels:
- * - We assume that libsmack tests passed and smack_new_label_from_self will return -1 and NULL
+ * - We assume that libsmack tests passed and smack_new_label_from_self will return -1 and nullptr
  *   label - there is no need to re-check it.
  * - Label acquired from security_server_get_smacklabel_cookie should be an empty string.
  */
 RUNNER_TEST_NOSMACK(tc18_security_server_get_smacklabel_cookie_nosmack) {
     int res;
 
-    char* label_ss = NULL;
-    char* cookie = NULL;
+    char* label_ss = nullptr;
+    char* cookie = nullptr;
 
     int cookie_size = security_server_get_cookie_size();
     RUNNER_ASSERT_MSG(PROPER_COOKIE_SIZE == cookie_size,
             "Wrong cookie size from security-server. Size: " << cookie_size);
 
     cookie = (char*) calloc(cookie_size, sizeof(char));
-    RUNNER_ASSERT_MSG(NULL != cookie, "Memory allocation error");
+    RUNNER_ASSERT_MSG(nullptr != cookie, "Memory allocation error");
 
     //Request cookie from SS
     res = security_server_request_cookie(cookie, cookie_size);
     CookieUniquePtr cookie_ptr(cookie);
-    cookie = NULL;
+    cookie = nullptr;
     RUNNER_ASSERT_MSG(res == SECURITY_SERVER_API_SUCCESS,
             "Error in requesting cookie from security-server. Result: " << res);
 
     label_ss = security_server_get_smacklabel_cookie(cookie_ptr.get());
-    RUNNER_ASSERT_MSG(label_ss != NULL, "Error in getting label by cookie");
+    RUNNER_ASSERT_MSG(label_ss != nullptr, "Error in getting label by cookie");
 
     std::string label(label_ss);
     free(label_ss);
index 04b6024..3a59530 100644 (file)
@@ -28,13 +28,13 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus)
     const char *subject_parent = "subject_parent";
     const char *subject_child = "subject_child";
 
-    DBusMessage* msg = NULL;
+    DBusMessage* msg = nullptr;
     DBusMessageIter args, iter, var, var_iter, var_value;
-    DBusConnection* conn = NULL;
+    DBusConnection* conn = nullptr;
     DBusError err;
-    DBusPendingCall *pending = NULL;
+    DBusPendingCall *pending = nullptr;
     const char *dbus_server_name = DBUS_SERVER_NAME;
-    char *smack_context = NULL;
+    char *smack_context = nullptr;
 
     pid_t pid = fork();
     RUNNER_ASSERT_ERRNO_MSG(-1 != pid, "fork() failed");
@@ -70,7 +70,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus)
                                            DBUS_SMACK_INTERFACE,
                                            DBUS_SMACK_METHOD);
 
-        RUNNER_ASSERT_MSG(NULL != msg,
+        RUNNER_ASSERT_MSG(nullptr != msg,
             "dbus_message_new_method_call() failed, ret: " << ret);
 
         // append arguments, we need SMACK context for our parent process "test.method.server"
@@ -85,7 +85,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus)
         // -1 is default timeout
         ret = dbus_connection_send_with_reply (conn, msg, &pending, -1);
         RUNNER_ASSERT_MSG(1 == ret, "Out of memory");
-        RUNNER_ASSERT_MSG(NULL != pending, "Pending call null");
+        RUNNER_ASSERT_MSG(nullptr != pending, "Pending call null");
 
         dbus_connection_flush(conn);
 
@@ -97,7 +97,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus)
 
         // get the reply
         msg = dbus_pending_call_steal_reply(pending);
-        RUNNER_ASSERT_MSG(NULL != msg, "Reply null");
+        RUNNER_ASSERT_MSG(nullptr != msg, "Reply null");
 
         // free message handle
         dbus_pending_call_unref(pending);
@@ -127,7 +127,7 @@ RUNNER_MULTIPROCESS_TEST_SMACK(tc01_smack_context_from_DBus)
         dbus_message_unref(msg);
         dbus_connection_unref(conn);
 
-        RUNNER_ASSERT(smack_context != NULL);
+        RUNNER_ASSERT(smack_context != nullptr);
         ret = strcmp(smack_context, subject_parent);
         RUNNER_ASSERT_MSG(0 == ret,
             "Context mismatch! context from dbus: " << smack_context);
@@ -179,13 +179,13 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack)
     int ret = -1;
     const char* subject_parent = "subject_parent";
 
-    DBusMessage* msg = NULL;
+    DBusMessage* msg = nullptr;
     DBusMessageIter args, iter, var, var_iter, var_value;
-    DBusConnection* conn = NULL;
+    DBusConnection* conn = nullptr;
     DBusError err;
-    DBusPendingCall *pending = NULL;
+    DBusPendingCall *pending = nullptr;
     const char *dbus_server_name = DBUS_SERVER_NAME;
-    char *smack_context = NULL;
+    char *smack_context = nullptr;
 
     pid_t pid = fork();
     RUNNER_ASSERT_ERRNO_MSG(-1 != pid, "fork() failed");
@@ -217,7 +217,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack)
                                            DBUS_SMACK_INTERFACE,
                                            DBUS_SMACK_METHOD);
 
-        RUNNER_ASSERT_MSG(msg != NULL, "dbus_message_new_method_call() failed.");
+        RUNNER_ASSERT_MSG(msg != nullptr, "dbus_message_new_method_call() failed.");
 
         // append arguments, we need SMACK context for our parent process "test.method.server"
         dbus_message_iter_init_append(msg, &args);
@@ -231,7 +231,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack)
         // -1 is default timeout
         ret = dbus_connection_send_with_reply (conn, msg, &pending, -1);
         RUNNER_ASSERT_MSG(ret == 1, "Out of memory. Ret " << ret);
-        RUNNER_ASSERT_MSG(pending != NULL, "Pending call is NULL.");
+        RUNNER_ASSERT_MSG(pending != nullptr, "Pending call is nullptr.");
 
         dbus_connection_flush(conn);
 
@@ -243,7 +243,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack)
 
         // get the reply
         msg = dbus_pending_call_steal_reply(pending);
-        RUNNER_ASSERT_MSG(msg != NULL, "Failed to get the reply from bus.");
+        RUNNER_ASSERT_MSG(msg != nullptr, "Failed to get the reply from bus.");
 
         // free message handle
         dbus_pending_call_unref(pending);
@@ -272,7 +272,7 @@ RUNNER_MULTIPROCESS_TEST_NOSMACK(tc01_smack_context_from_DBus_nosmack)
         dbus_message_unref(msg);
         dbus_connection_unref(conn);
 
-        RUNNER_ASSERT(smack_context != NULL);
+        RUNNER_ASSERT(smack_context != nullptr);
         ret = strcmp(smack_context, subject_parent);
         RUNNER_ASSERT_MSG(ret == 0, "Context mismatch. Context " << smack_context);
 
index 6f358f5..d914e5d 100644 (file)
@@ -127,7 +127,7 @@ RUNNER_TEST(tc02_security_server_set_pwd_validity)
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret);
 
     // WITH password
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     ret = security_server_set_pwd_validity(10);
@@ -156,7 +156,7 @@ RUNNER_TEST(tc03_security_server_set_pwd_max_challenge)
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret = " << ret);
 
     // WITH password
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     ret = security_server_set_pwd_max_challenge(5);
@@ -187,16 +187,16 @@ RUNNER_TEST(tc05_security_server_chk_pwd_null_input_case)
     int ret;
     unsigned int attempt, max_attempt, expire_sec;
 
-    ret = security_server_chk_pwd(NULL, &attempt, &max_attempt, &expire_sec);
+    ret = security_server_chk_pwd(nullptr, &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 
-    ret = security_server_chk_pwd("password", NULL, &max_attempt, &expire_sec);
+    ret = security_server_chk_pwd("password", nullptr, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 
-    ret = security_server_chk_pwd("password", &attempt, NULL, &expire_sec);
+    ret = security_server_chk_pwd("password", &attempt, nullptr, &expire_sec);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 
-    ret = security_server_chk_pwd("password", &attempt, &max_attempt, NULL);
+    ret = security_server_chk_pwd("password", &attempt, &max_attempt, nullptr);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 }
 
@@ -230,7 +230,7 @@ RUNNER_TEST(tc07_security_server_set_pwd_null_input_case)
     reset_security_server();
 
     // TEST
-    ret = security_server_set_pwd(NULL, NULL, 0, 0);
+    ret = security_server_set_pwd(nullptr, nullptr, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 }
 
@@ -261,7 +261,7 @@ RUNNER_TEST(tc09_security_server_set_pwd_current_pwd_empty)
     reset_security_server();
 
     // TEST
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 }
 
@@ -273,7 +273,7 @@ RUNNER_TEST(tc10_security_server_set_pwd_current_pwd_max_valid_period_in_days)
     int ret;
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -284,7 +284,7 @@ RUNNER_TEST(tc10_security_server_set_pwd_current_pwd_max_valid_period_in_days)
     usleep(PASSWORD_RETRY_TIMEOUT_US);
     // calculate max applicable valid days that will not be rejected by ss
     // ensure, that after conversion from days to seconds in ss there will be no uint overflow
-    unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1;
+    unsigned int valid_days = ((UINT_MAX - time(nullptr)) / 86400) - 1;
     ret = security_server_set_pwd(TEST_PASSWORD, SECOND_TEST_PASSWORD, 0, valid_days);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 }
@@ -297,7 +297,7 @@ RUNNER_TEST(tc11_security_server_set_pwd_current_pwd_max_max_challenge)
     int ret;
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -314,7 +314,7 @@ RUNNER_TEST(tc12_security_server_set_pwd_current_pwd_nonempty2zero)
     int ret;
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -331,7 +331,7 @@ RUNNER_TEST(tc14_security_server_set_pwd_current_pwd_too_long_input_param)
     int ret;
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -351,7 +351,7 @@ RUNNER_TEST(tc15_security_server_chk_pwd_empty_password)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -368,7 +368,7 @@ RUNNER_TEST(tc16_security_server_set_pwd_validity)
     int ret;
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -396,7 +396,7 @@ RUNNER_TEST(tc17_security_server_is_pwd_valid)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 2);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 2);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST:
@@ -415,8 +415,8 @@ RUNNER_TEST(tc18_security_server_set_pwd_max_challenge)
     reset_security_server();
     // calculate max applicable valid days that will not be rejected by ss
     // ensure, that after conversion from days to seconds in ss there will be no uint overflow
-    unsigned int valid_days = ((UINT_MAX - time(NULL)) / 86400) - 1;
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, valid_days);
+    unsigned int valid_days = ((UINT_MAX - time(nullptr)) / 86400) - 1;
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, valid_days);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TESTS
@@ -443,7 +443,7 @@ RUNNER_TEST(tc19_security_server_is_pwd_valid)
     unsigned int attempt, max_attempt, expire_sec;
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     ret = security_server_set_pwd_max_challenge(6);
@@ -465,7 +465,7 @@ RUNNER_TEST(tc20_security_server_chk_pwd)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -487,7 +487,7 @@ RUNNER_TEST(tc21_security_server_chk_incorrect_pwd)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //TEST
@@ -505,7 +505,7 @@ RUNNER_TEST(tc22_security_server_set_pwd_incorrect_current)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -523,7 +523,7 @@ RUNNER_TEST(tc23_security_server_set_pwd_correct_current)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -542,7 +542,7 @@ RUNNER_TEST(tc24_security_server_attempt_exceeding)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -575,7 +575,7 @@ RUNNER_TEST(tc25_security_server_attempt_exceeding)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 1);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 1);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -607,7 +607,7 @@ RUNNER_TEST(tc26_security_server_reset_pwd)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 5, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -624,7 +624,7 @@ RUNNER_TEST(tc27_security_server_chk_pwd_too_long_password)
     unsigned int attempt, max_attempt, expire_sec;
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 5, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -643,7 +643,7 @@ RUNNER_TEST(tc28_security_server_check_expiration)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 1);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 5, 1);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -661,7 +661,7 @@ RUNNER_TEST(tc29_security_server_set_pwd_history)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 5, 1);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 5, 1);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TESTS
@@ -808,7 +808,7 @@ RUNNER_TEST(tc32_security_server_challenge_on_expired_password)
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 4, 1);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 4, 1);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // TEST
@@ -816,11 +816,11 @@ RUNNER_TEST(tc32_security_server_challenge_on_expired_password)
     ret = security_server_chk_pwd(TEST_PASSWORD, &attempt, &max_attempt, &expire_sec);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    ret = gettimeofday(&cur_time, NULL);
+    ret = gettimeofday(&cur_time, nullptr);
     RUNNER_ASSERT_ERRNO(ret != -1);
 
     cur_time.tv_sec += (expire_sec + 1);
-    ret = settimeofday(&cur_time, NULL);
+    ret = settimeofday(&cur_time, nullptr);
     RUNNER_ASSERT_ERRNO(ret != -1);
 
     usleep(PASSWORD_RETRY_TIMEOUT_US);
@@ -843,7 +843,7 @@ RUNNER_TEST(tc33_security_server_reset_by_null_pwd)
     reset_security_server();
 
     // TEST
-    ret = security_server_reset_pwd(NULL, 10, 10);
+    ret = security_server_reset_pwd(nullptr, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret = " << ret);
 }
 
@@ -895,7 +895,7 @@ RUNNER_TEST(tc34_security_server_max_attempts)
     // Prepare environment
     reset_security_server();
 
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // change max attempts number few times
@@ -933,7 +933,7 @@ RUNNER_TEST(tc35_security_server_decrease_max_attempts)
     // Prepare environment
     reset_security_server();
 
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, max_challenge_more, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, max_challenge_more, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // missed attempts
@@ -1025,7 +1025,7 @@ RUNNER_TEST(tc37_security_server_challenge_mixed)
     reset_security_server();
 
     const unsigned int max_challenge = 2;
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, max_challenge, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, max_challenge, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // 2x correct pwd - verify that 'cuurrent attempt' isn't increased
@@ -1154,7 +1154,7 @@ RUNNER_TEST(tc39_security_server_attempts_num_check_after_reset)
     // Prepare environment
     reset_security_server();
 
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, max_challenge, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, max_challenge, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     // missed attempts
@@ -1305,12 +1305,12 @@ RUNNER_TEST(tc42_security_server_set_new_pwd_with_current_empty)
     reset_security_server();
 
     //set a password
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
-    //try setting different password and giving NULL as current once again
+    //try setting different password and giving nullptr as current once again
     usleep(PASSWORD_RETRY_TIMEOUT_US);
-    ret = security_server_set_pwd(NULL, SECOND_TEST_PASSWORD, 0, 0);
+    ret = security_server_set_pwd(nullptr, SECOND_TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_PASSWORD_EXIST, "ret = " << ret);
 }
 
@@ -1320,7 +1320,7 @@ RUNNER_TEST(tc43_security_server_no_retry_timeout_is_pwd_valid)
     reset_security_server();
 
     //set a password
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //do test
@@ -1337,7 +1337,7 @@ RUNNER_TEST(tc44_security_server_retry_timeout_chk_pwd)
     reset_security_server();
 
     //set a password
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //do test
@@ -1354,7 +1354,7 @@ RUNNER_TEST(tc45_security_server_retry_timeout_set_pwd)
     reset_security_server();
 
     //set a password
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //do test
@@ -1370,7 +1370,7 @@ RUNNER_TEST(tc46_security_server_no_retry_timeout_set_pwd_validity)
     reset_security_server();
 
     //set a password
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //do test
@@ -1386,7 +1386,7 @@ RUNNER_TEST(tc47_security_server_no_retry_timeout_reset_pwd)
     reset_security_server();
 
     //set a password
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //do test
@@ -1402,7 +1402,7 @@ RUNNER_TEST(tc48_security_server_no_retry_timeout_pwd_history)
     reset_security_server();
 
     //set a password
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //do test
@@ -1418,7 +1418,7 @@ RUNNER_TEST(tc49_security_server_no_retry_timeout_set_pwd_max_challenge)
     reset_security_server();
 
     //set a password
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     //do test
@@ -1435,7 +1435,7 @@ RUNNER_TEST(tc50_security_server_set_pwd_current_pwd_with_infinite_expiration_ti
 
     // Prepare environment
     reset_security_server();
-    ret = security_server_set_pwd(NULL, TEST_PASSWORD, 10, 10);
+    ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 10, 10);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
     usleep(PASSWORD_RETRY_TIMEOUT_US);
 
@@ -1456,7 +1456,7 @@ RUNNER_TEST(tc51_security_server_is_pwd_valid)
 {
     reset_security_server();
 
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 1);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 1);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     unsigned int attempt, maxAttempt, validSec;
@@ -1479,7 +1479,7 @@ RUNNER_TEST(tc52_security_server_is_pwd_valid)
 {
     reset_security_server();
 
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 0);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     unsigned int attempt, maxAttempt, validSec;
@@ -1494,7 +1494,7 @@ RUNNER_TEST(tc53_security_server_is_pwd_valid)
 {
     reset_security_server();
 
-    int ret = security_server_set_pwd(NULL, TEST_PASSWORD, 0, 3);
+    int ret = security_server_set_pwd(nullptr, TEST_PASSWORD, 0, 3);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret = " << ret);
 
     unsigned int attempt, maxAttempt, validSec;
index f93136a..4b0ac72 100644 (file)
@@ -13,17 +13,17 @@ const char *SSTP_OTHER_LABEL = "sstp_test_other_label";
 const char *SSTP_PERMS[] = {
     "sstp_test_rules1",
     "sstp_test_rules2",
-    NULL
+    nullptr
 };
 
 const char *SSTP_PERMS1[] = {
     SSTP_PERMS[0],
-    NULL
+    nullptr
 };
 
 const char *SSTP_PERMS2[] = {
     SSTP_PERMS[1],
-    NULL
+    nullptr
 };
 
 void check_security_server_app_has_privilege(const char *app_label,
index 330fb0f..9b74a62 100644 (file)
@@ -111,7 +111,7 @@ void cookie_api_thread_function(bool isSmack)
             return;
         }
 
-        char *labelFromSelfTmp = NULL;
+        char *labelFromSelfTmp = nullptr;
         ret = smack_new_label_from_self(&labelFromSelfTmp);
         if (ret < 0) {
             appendError("Error in smack_new_label_from_self(): " + std::to_string(ret));
@@ -139,7 +139,7 @@ void testFunction(bool isSmack)
         int ret = smack_set_label_for_self(g_subject.data());
         RUNNER_ASSERT_MSG(ret == 0, "Error in smack_set_label_for_self()");
 
-        struct smack_accesses *rulesRaw = NULL;
+        struct smack_accesses *rulesRaw = nullptr;
         ret = smack_accesses_new(&rulesRaw);
         RUNNER_ASSERT_MSG(ret == 0, "Error in smack_accesses_new()");
         SmackAccessesPtr rules(rulesRaw);
index b837a34..d7929eb 100644 (file)
@@ -219,7 +219,7 @@ RUNNER_CHILD_TEST_SMACK(tc03_check_API_passwd_allow)
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_PASSWORD, "ret: " << ret);
 
     usleep(PASSWORD_RETRY_TIMEOUT_US);
-    ret = security_server_set_pwd(NULL, "12345", 0, 0);
+    ret = security_server_set_pwd(nullptr, "12345", 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS, "ret: " << ret);
 
     ret = security_server_reset_pwd("12345",0, 0);
@@ -385,7 +385,7 @@ RUNNER_CHILD_TEST_NOSMACK(tc03_check_API_passwd_allow_nosmack)
             "is_pwd_valid should return no password error. Result: " << ret);
 
     usleep(PASSWORD_RETRY_TIMEOUT_US);
-    ret = security_server_set_pwd(NULL, "12345", 0, 0);
+    ret = security_server_set_pwd(nullptr, "12345", 0, 0);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS,
             "set_pwd failed. Result: " << ret);
 
index fbf86db..fab2d6a 100644 (file)
@@ -33,7 +33,7 @@ RUNNER_TEST(tc01_security_server_get_gid_weird_input_case)
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_NO_SUCH_OBJECT, "ret: " << ret);
 
     /* null param case */
-    ret = security_server_get_gid(NULL);
+    ret = security_server_get_gid(nullptr);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
 
     /* param too long case */
@@ -53,7 +53,7 @@ RUNNER_TEST(tc03_security_server_request_cookie_weird_input_case)
     size_t cookie_size = security_server_get_cookie_size();
 
     /* null cookie case */
-    char *cookie = NULL;
+    char *cookie = nullptr;
 
     ret = security_server_request_cookie(cookie, cookie_size);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
@@ -73,7 +73,7 @@ RUNNER_TEST(tc04_security_server_check_privilege_weird_input_case)
     gid_t gid = DB_ALARM_GID;
 
     /* null cookie case */
-    char *cookie = NULL;
+    char *cookie = nullptr;
 
     ret = security_server_check_privilege(cookie, gid);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
@@ -98,12 +98,12 @@ RUNNER_TEST(tc05_security_server_check_privilege_by_cookie_weird_input_case)
     const char *access_rights = "r";
 
     /* null cookie case */
-    char *cookie = NULL;
+    char *cookie = nullptr;
     ret = security_server_check_privilege_by_cookie(cookie, object, access_rights);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
 
     /* null object case */
-    char *object2 = NULL;
+    char *object2 = nullptr;
     char cookie2[cookie_size];
 
     ret = security_server_request_cookie(cookie2, cookie_size);
@@ -113,7 +113,7 @@ RUNNER_TEST(tc05_security_server_check_privilege_by_cookie_weird_input_case)
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
 
     /* null access rights case */
-    access_rights = NULL;
+    access_rights = nullptr;
     ret = security_server_check_privilege_by_cookie(cookie2, object, access_rights);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
 }
@@ -132,12 +132,12 @@ RUNNER_TEST_SMACK(tc06_security_server_check_privilege_by_sockfd_weird_input_cas
     sockfd = 0;
 
     /* null object case */
-    char *object2 = NULL;
+    char *object2 = nullptr;
     ret = security_server_check_privilege_by_sockfd(sockfd, object2, access_rights);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
 
     /* null access rights case */
-    access_rights = NULL;
+    access_rights = nullptr;
     ret = security_server_check_privilege_by_sockfd(sockfd, object, access_rights);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM, "ret: " << ret);
 }
@@ -145,7 +145,7 @@ RUNNER_TEST_SMACK(tc06_security_server_check_privilege_by_sockfd_weird_input_cas
 RUNNER_TEST(tc07_security_server_get_cookie_pid_weird_input_case)
 {
     int ret = 0;
-    char *cookie = NULL;
+    char *cookie = nullptr;
 
     ret = security_server_get_cookie_pid(cookie);
     RUNNER_ASSERT(ret == SECURITY_SERVER_API_ERROR_INPUT_PARAM);
@@ -178,13 +178,13 @@ RUNNER_TEST_NOSMACK(tc06_security_server_check_privilege_by_sockfd_weird_input_c
     sockfd = 0;
 
     //null object case
-    char *object2 = NULL;
+    char *object2 = nullptr;
     ret = security_server_check_privilege_by_sockfd(sockfd, object2, access_rights);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS,
             "check_privilege_by_sockfd failed. Result: " << ret);
 
     //null access rights case
-    access_rights = NULL;
+    access_rights = nullptr;
     ret = security_server_check_privilege_by_sockfd(sockfd, object, access_rights);
     RUNNER_ASSERT_MSG(ret == SECURITY_SERVER_API_SUCCESS,
             "check_privilege_by_sockfd failed. Result: " << ret);