[Spice-devel] [PATCH spice-streaming-agent] Remove using entire std namespace

Frediano Ziglio fziglio at redhat.com
Thu Feb 8 16:21:43 UTC 2018


As discussed about style the usage or "using namespace" should be
avoided.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 src/concrete-agent.cpp        | 11 +++++------
 src/mjpeg-fallback.cpp        |  3 +--
 src/spice-streaming-agent.cpp |  5 ++---
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/concrete-agent.cpp b/src/concrete-agent.cpp
index ebeef33..891c09b 100644
--- a/src/concrete-agent.cpp
+++ b/src/concrete-agent.cpp
@@ -13,7 +13,6 @@
 #include "concrete-agent.hpp"
 #include "static-plugin.hpp"
 
-using namespace std;
 using namespace spice::streaming_agent;
 
 static inline unsigned MajorVersion(unsigned version)
@@ -40,7 +39,7 @@ bool ConcreteAgent::PluginVersionIsCompatible(unsigned pluginVersion) const
 
 void ConcreteAgent::Register(Plugin& plugin)
 {
-    plugins.push_back(shared_ptr<Plugin>(&plugin));
+    plugins.push_back(std::shared_ptr<Plugin>(&plugin));
 }
 
 const ConfigureOption* ConcreteAgent::Options() const
@@ -56,11 +55,11 @@ void ConcreteAgent::AddOption(const char *name, const char *value)
     options.insert(--options.end(), ConcreteConfigureOption(name, value));
 }
 
-void ConcreteAgent::LoadPlugins(const string &directory)
+void ConcreteAgent::LoadPlugins(const std::string &directory)
 {
     StaticPlugin::InitAll(*this);
 
-    string pattern = directory + "/*.so";
+    std::string pattern = directory + "/*.so";
     glob_t globbuf;
 
     int glob_result = glob(pattern.c_str(), 0, NULL, &globbuf);
@@ -77,7 +76,7 @@ void ConcreteAgent::LoadPlugins(const string &directory)
     globfree(&globbuf);
 }
 
-void ConcreteAgent::LoadPlugin(const string &plugin_filename)
+void ConcreteAgent::LoadPlugin(const std::string &plugin_filename)
 {
     void *dl = dlopen(plugin_filename.c_str(), RTLD_LOCAL|RTLD_NOW);
     if (!dl) {
@@ -101,7 +100,7 @@ void ConcreteAgent::LoadPlugin(const string &plugin_filename)
 
 FrameCapture *ConcreteAgent::GetBestFrameCapture(const std::set<SpiceVideoCodecType>& codecs)
 {
-    vector<pair<unsigned, shared_ptr<Plugin>>> sorted_plugins;
+    std::vector<std::pair<unsigned, std::shared_ptr<Plugin>>> sorted_plugins;
 
     // sort plugins base on ranking, reverse order
     for (const auto& plugin: plugins) {
diff --git a/src/mjpeg-fallback.cpp b/src/mjpeg-fallback.cpp
index 10543ad..74682f3 100644
--- a/src/mjpeg-fallback.cpp
+++ b/src/mjpeg-fallback.cpp
@@ -18,7 +18,6 @@
 #include "static-plugin.hpp"
 #include "jpeg.hpp"
 
-using namespace std;
 using namespace spice::streaming_agent;
 
 #define ERROR(args) do { \
@@ -55,7 +54,7 @@ private:
     MjpegSettings settings;
     Display *dpy;
 
-    vector<uint8_t> frame;
+    std::vector<uint8_t> frame;
 
     // last frame sizes
     uint32_t last_width = ~0u, last_height = ~0u;
diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 0e7641e..f4fee2d 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -35,7 +35,6 @@
 #include "hexdump.h"
 #include "concrete-agent.hpp"
 
-using namespace std;
 using namespace spice::streaming_agent;
 
 static ConcreteAgent agent;
@@ -351,7 +350,7 @@ static void cursor_changes(Display *display, int event_base)
 }
 
 static void
-do_capture(const string &streamport, FILE *f_log)
+do_capture(const std::string &streamport, FILE *f_log)
 {
     streamfd = open(streamport.c_str(), O_RDWR);
     if (streamfd < 0)
@@ -437,7 +436,7 @@ done:
 
 int main(int argc, char* argv[])
 {
-    string streamport = "/dev/virtio-ports/com.redhat.stream.0";
+    std::string streamport = "/dev/virtio-ports/com.redhat.stream.0";
     char opt;
     const char *log_filename = NULL;
     int logmask = LOG_UPTO(LOG_WARNING);
-- 
2.14.3



More information about the Spice-devel mailing list