Markus Armbruster <[email protected]> writes:
> g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer,
> for two reasons. One, it catches multiplication overflowing size_t.
> Two, it returns T * rather than void *, which lets the compiler catch
> more type errors.
>
<snip>
> diff --git a/semihosting/config.c b/semihosting/config.c
> index 137171b717..6d48ec9566 100644
> --- a/semihosting/config.c
> +++ b/semihosting/config.c
> @@ -98,7 +98,7 @@ static int add_semihosting_arg(void *opaque,
> if (strcmp(name, "arg") == 0) {
> s->argc++;
> /* one extra element as g_strjoinv() expects NULL-terminated array */
> - s->argv = g_realloc(s->argv, (s->argc + 1) * sizeof(void *));
> + s->argv = g_renew(void *, s->argv, s->argc + 1);
This did indeed break CI because s->argv is an array of *char:
../semihosting/config.c:101:17: error: assignment to ‘const char **’ from
incompatible pointer type ‘void **’ [-Werror=incompatible-pointer-types]
101 | s->argv = g_renew(void *, s->argv, s->argc + 1);
| ^
cc1: all warnings being treated as errors
So it did the job of type checking but failed to build ;-)
--
Alex Bennée