[PATCH v2 04/24] Do not create std::string for constants

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christophe de Dinechin <dinechin@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 src/spice-streaming-agent.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 894f86c..acec001 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -354,12 +354,13 @@ 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);
+    streamfd = open(streamport, O_RDWR);
     if (streamfd < 0)
         throw std::runtime_error("failed to open the streaming device (" +
-                                 streamport + "): " + strerror(errno));
+                                 std::string(streamport) + "): "
+                                 + strerror(errno));
 
     unsigned int frame_count = 0;
     while (!quit_requested) {
@@ -443,7 +444,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)

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]