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@gmail.com>
Acked-by: Frediano Ziglio <freddy77@gmail.com>
This commit is contained in:
Rosen Penev 2020-10-05 03:17:18 -07:00 committed by Frediano Ziglio
parent 127c047ad7
commit 0bc7e80ec6
3 changed files with 6 additions and 6 deletions

View File

@ -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);
}
/*

View File

@ -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)

View File

@ -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);
}