[Spice-commits] server/reds.cpp server/red-stream.cpp server/tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 5 06:04:10 UTC 2021


 server/red-stream.cpp    |    4 ++--
 server/reds.cpp          |    4 ++--
 server/tests/vmc-emu.cpp |    4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

New commits:
commit 0bc7e80ec62c0cb5b0f5bd5e711ff5d15e63b7b3
Author: Rosen Penev <rosenp at gmail.com>
Date:   Mon Oct 5 03:17:18 2020 -0700

    clang-tidy: convert C casts to C++ ones
    
    Found with google-readability-casting
    
    https://google.github.io/styleguide/cppguide.html#Casting
    
    Makes the operation clearer.
    
    This commit uses const_cast where needed.
    
    Signed-off-by: Rosen Penev <rosenp at gmail.com>
    Acked-by: Frediano Ziglio <freddy77 at gmail.com>

diff --git a/server/red-stream.cpp b/server/red-stream.cpp
index 090883f3..e27a0ef3 100644
--- a/server/red-stream.cpp
+++ b/server/red-stream.cpp
@@ -363,7 +363,7 @@ int red_stream_send_msgfd(RedStream *stream, int fd)
     spice_return_val_if_fail(red_stream_is_plain_unix(stream), -1);
 
     /* set the payload */
-    iov.iov_base = (char*)"@";
+    iov.iov_base = const_cast<char *>("@");
     iov.iov_len = 1;
     msgh.msg_iovlen = 1;
     msgh.msg_iov = &iov;
@@ -1179,7 +1179,7 @@ static ssize_t stream_websocket_write(RedStream *s, const void *buf, size_t size
 
 static ssize_t stream_websocket_writev(RedStream *s, const struct iovec *iov, int iovcnt)
 {
-    return websocket_writev(s->priv->ws, (struct iovec *) iov, iovcnt, WEBSOCKET_BINARY_FINAL);
+    return websocket_writev(s->priv->ws, iov, iovcnt, WEBSOCKET_BINARY_FINAL);
 }
 
 /*
diff --git a/server/reds.cpp b/server/reds.cpp
index b31a6a5c..c2909a9e 100644
--- a/server/reds.cpp
+++ b/server/reds.cpp
@@ -3107,7 +3107,7 @@ static const char *const spice_server_char_device_recognized_subtypes_list[] = {
 
 SPICE_GNUC_VISIBLE const char** spice_server_char_device_recognized_subtypes(void)
 {
-    return (const char **) spice_server_char_device_recognized_subtypes_list;
+    return const_cast<const char **>(spice_server_char_device_recognized_subtypes_list);
 }
 
 static void reds_add_char_device(RedsState *reds, const red::shared_ptr<RedCharDevice> &dev)
@@ -4051,7 +4051,7 @@ SPICE_GNUC_VISIBLE const char *spice_server_get_video_codecs(SpiceServer *reds)
 
 SPICE_GNUC_VISIBLE void spice_server_free_video_codecs(SpiceServer *reds, const char *video_codecs)
 {
-    g_free((char *) video_codecs);
+    g_free(const_cast<char *>(video_codecs));
 }
 
 GArray* reds_get_video_codecs(const RedsState *reds)
diff --git a/server/tests/vmc-emu.cpp b/server/tests/vmc-emu.cpp
index c3311d5e..3e43f179 100644
--- a/server/tests/vmc-emu.cpp
+++ b/server/tests/vmc-emu.cpp
@@ -97,8 +97,8 @@ VmcEmu *vmc_emu_new(const char *subtype, const char *portname)
 
 void vmc_emu_destroy(VmcEmu *vmc)
 {
-    g_free((char *) vmc->instance.portname);
-    g_free((char *) vmc->instance.subtype);
+    g_free(const_cast<char *>(vmc->instance.portname));
+    g_free(const_cast<char *>(vmc->instance.subtype));
     g_free(vmc);
 }
 


More information about the Spice-commits mailing list