]> git.stg.codes - stg.git/blobdiff - projects/stargazer/plugins/other/rscript/rscript.cpp
Various fixes of issues reported by static analyzers.
[stg.git] / projects / stargazer / plugins / other / rscript / rscript.cpp
index 00114df4c501fa0cd4aa6e3d7fc2031d8e7dc3ed..1e842d255865925fa642d0cdaeb50502f7da2e25 100644 (file)
  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
  */
 
-#include <sys/time.h>
+#include "rscript.h"
 
-#include <csignal>
-#include <cassert>
-#include <cstdlib>
-#include <cerrno>
-#include <cstring>
-#include <algorithm>
+#include "ur_functor.h"
+#include "send_functor.h"
 
 #include "stg/common.h"
 #include "stg/locker.h"
 #include "stg/user_property.h"
 #include "stg/plugin_creator.h"
 #include "stg/logger.h"
-#include "rscript.h"
-#include "ur_functor.h"
-#include "send_functor.h"
+
+#include <algorithm>
+
+#include <csignal>
+#include <cassert>
+#include <cstdlib>
+#include <cerrno>
+#include <cstring>
+
+#include <sys/time.h>
+#include <netinet/ip.h>
 
 extern volatile time_t stgTime;
 
@@ -47,7 +51,7 @@ namespace {
 template<typename T>
 struct USER_IS
 {
-    USER_IS(USER_PTR u) : user(u) {}
+    explicit USER_IS(USER_PTR u) : user(u) {}
     bool operator()(const T & notifier) { return notifier.GetUser() == user; }
 
     USER_PTR user;
@@ -73,12 +77,7 @@ return rsc.GetPlugin();
 //-----------------------------------------------------------------------------
 RS::SETTINGS::SETTINGS()
     : sendPeriod(0),
-      port(0),
-      errorStr(),
-      netRouters(),
-      userParams(),
-      password(),
-      subnetFile()
+      port(0)
 {
 }
 //-----------------------------------------------------------------------------
@@ -91,7 +90,7 @@ netRouters.clear();
 ///////////////////////////
 pv.param = "Port";
 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
-if (pvi == s.moduleParams.end())
+if (pvi == s.moduleParams.end() || pvi->value.empty())
     {
     errorStr = "Parameter \'Port\' not found.";
     printfd(__FILE__, "Parameter 'Port' not found\n");
@@ -107,7 +106,7 @@ port = static_cast<uint16_t>(p);
 ///////////////////////////
 pv.param = "SendPeriod";
 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
-if (pvi == s.moduleParams.end())
+if (pvi == s.moduleParams.end() || pvi->value.empty())
     {
     errorStr = "Parameter \'SendPeriod\' not found.";
     printfd(__FILE__, "Parameter 'SendPeriod' not found\n");
@@ -123,7 +122,7 @@ if (ParseIntInRange(pvi->value[0], 5, 600, &sendPeriod))
 ///////////////////////////
 pv.param = "UserParams";
 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
-if (pvi == s.moduleParams.end())
+if (pvi == s.moduleParams.end() || pvi->value.empty())
     {
     errorStr = "Parameter \'UserParams\' not found.";
     printfd(__FILE__, "Parameter 'UserParams' not found\n");
@@ -133,7 +132,7 @@ userParams = pvi->value;
 ///////////////////////////
 pv.param = "Password";
 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
-if (pvi == s.moduleParams.end())
+if (pvi == s.moduleParams.end() || pvi->value.empty())
     {
     errorStr = "Parameter \'Password\' not found.";
     printfd(__FILE__, "Parameter 'Password' not found\n");
@@ -143,7 +142,7 @@ password = pvi->value[0];
 ///////////////////////////
 pv.param = "SubnetFile";
 pvi = find(s.moduleParams.begin(), s.moduleParams.end(), pv);
-if (pvi == s.moduleParams.end())
+if (pvi == s.moduleParams.end() || pvi->value.empty())
     {
     errorStr = "Parameter \'SubnetFile\' not found.";
     printfd(__FILE__, "Parameter 'SubnetFile' not found\n");
@@ -301,7 +300,7 @@ if (isRunning)
 return 0;
 }
 //-----------------------------------------------------------------------------
-int REMOTE_SCRIPT::Reload()
+int REMOTE_SCRIPT::Reload(const MODULE_SETTINGS & /*ms*/)
 {
 NRMapParser nrMapParser;