HG proc: remove warning suppression in string object
Use safe cast instead
@@ -58,30 +58,22 @@ hg_string_object_init_char(
}
/*---------------------------------------------------------------------------*/
-/* We need to suppress -Wcast-qual warnings here as the const qualifier is
- * handled by the string object.
- */
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && \
- !defined(__INTEL_COMPILER)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wcast-qual"
-#endif
hg_return_t
hg_string_object_init_const_char(
hg_string_object_t *string, const char *s, hg_bool_t is_owned)
{
+ union {
+ char *p;
+ const char *const_p;
+ } safe_string = {.const_p = s};
hg_return_t ret = HG_SUCCESS;
- string->data = (char *) s;
+ string->data = safe_string.p;
string->is_owned = is_owned;
string->is_const = 1;
return ret;
}
-#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 406) && \
- !defined(__INTEL_COMPILER)
-# pragma GCC diagnostic pop
-#endif
/*---------------------------------------------------------------------------*/
hg_return_t
