[Spice-devel] [PATCH] common: constify some declarations
Frediano Ziglio
fziglio at redhat.com
Mon Aug 17 03:38:25 PDT 2015
Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
common/log.c | 4 ++--
common/marshaller.c | 7 +++++--
common/marshaller.h | 2 +-
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/common/log.c b/common/log.c
index fc5c129..c61156b 100644
--- a/common/log.c
+++ b/common/log.c
@@ -36,14 +36,14 @@ static const char * spice_log_level_to_string(SpiceLogLevel level)
{
#ifdef _MSC_VER
/* MSVC++ does not implement C99 */
- static const char *to_string[] = {
+ static const char *const to_string[] = {
"ERROR",
"CRITICAL",
"Warning",
"Info",
"Debug"};
#else
- static const char *to_string[] = {
+ static const char *const to_string[] = {
[ SPICE_LOG_LEVEL_ERROR ] = "ERROR",
[ SPICE_LOG_LEVEL_CRITICAL ] = "CRITICAL",
[ SPICE_LOG_LEVEL_WARNING ] = "Warning",
diff --git a/common/marshaller.c b/common/marshaller.c
index 55b9d51..0e6e972 100644
--- a/common/marshaller.c
+++ b/common/marshaller.c
@@ -342,9 +342,12 @@ uint8_t *spice_marshaller_add(SpiceMarshaller *m, const uint8_t *data, size_t si
return ptr;
}
-uint8_t *spice_marshaller_add_ref(SpiceMarshaller *m, uint8_t *data, size_t size)
+uint8_t *spice_marshaller_add_ref(SpiceMarshaller *m, const uint8_t *data, size_t size)
{
- return spice_marshaller_add_ref_full(m, data, size, NULL, NULL);
+ /* the cast to no-const here is safe as data is used for writing only if
+ * free_data pointer is not NULL
+ */
+ return spice_marshaller_add_ref_full(m, (uint8_t *) data, size, NULL, NULL);
}
void spice_marshaller_add_ref_chunks(SpiceMarshaller *m, SpiceChunks *chunks)
diff --git a/common/marshaller.h b/common/marshaller.h
index e19c0f6..a0dd72a 100644
--- a/common/marshaller.h
+++ b/common/marshaller.h
@@ -37,7 +37,7 @@ void spice_marshaller_destroy(SpiceMarshaller *m);
uint8_t *spice_marshaller_reserve_space(SpiceMarshaller *m, size_t size);
void spice_marshaller_unreserve_space(SpiceMarshaller *m, size_t size);
uint8_t *spice_marshaller_add(SpiceMarshaller *m, const uint8_t *data, size_t size);
-uint8_t *spice_marshaller_add_ref(SpiceMarshaller *m, uint8_t *data, size_t size);
+uint8_t *spice_marshaller_add_ref(SpiceMarshaller *m, const uint8_t *data, size_t size);
uint8_t *spice_marshaller_add_ref_full(SpiceMarshaller *m, uint8_t *data, size_t size,
spice_marshaller_item_free_func free_data, void *opaque);
void spice_marshaller_add_ref_chunks(SpiceMarshaller *m, SpiceChunks *chunks);
--
2.4.3
More information about the Spice-devel
mailing list