[Spice-devel] [PATCH 07/14] Do not create std::string for constants

Christophe de Dinechin christophe at dinechin.org
Wed Feb 14 17:52:15 UTC 2018


From: Christophe de Dinechin <dinechin at redhat.com>

As per e-mail discussions (https://patchwork.freedesktop.org/patch/200629/),
using std::string for C-style string constants is against C++ good practices,
see https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rstr-zstring for reference.

Signed-off-by: Christophe de Dinechin <dinechin at redhat.com>
---
 src/spice-streaming-agent.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 8f25940..25a38a6 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -352,7 +352,7 @@ static void cursor_changes(Display *display, int event_base)
 }
 
 static void
-do_capture(const std::string &streamport, FILE *f_log)
+do_capture(const char *streamport, FILE *f_log)
 {
     streamfd = open(streamport.c_str(), O_RDWR);
     if (streamfd < 0)
@@ -438,7 +438,7 @@ done:
 
 int main(int argc, char* argv[])
 {
-    std::string streamport = "/dev/virtio-ports/com.redhat.stream.0";
+    const char *streamport = "/dev/virtio-ports/com.redhat.stream.0";
     char opt;
     const char *log_filename = NULL;
     int logmask = LOG_UPTO(LOG_WARNING);
-- 
2.13.5 (Apple Git-94)



More information about the Spice-devel mailing list