This squashes the following compiler warnings:
tvnodes.c: In function ‘update_tree’:
tvnodes.c:294:28: warning: conversion to ‘size_t’ {aka ‘long unsigned
int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
294 | types = gv_calloc(g->count, sizeof(GType));
| ~^~~~~~~
tvnodes.c: In function ‘add_column’:
tvnodes.c:312:43: warning: conversion to ‘size_t’ {aka ‘long unsigned
int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
312 | g->columns = gv_recalloc(g->columns, g->count, g->count + 1,
| ~^~~~~~~
tvnodes.c:312:61: warning: conversion to ‘size_t’ {aka ‘long unsigned
int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
312 | g->columns = gv_recalloc(g->columns, g->count, g->count + 1,
| ~~~~~~~~~^~~
`count` is known non-negative all the time, but cannot be easily converted to a
`size_t` because we need to interact with the GTK APIs that take `int` values.
}
if (g->count > 0) {
- types = gv_calloc(g->count, sizeof(GType));
+ types = gv_calloc((size_t)g->count, sizeof(GType));
for (id = 0; id < g->count; id++)
types[id] = g->columns[id]->type;
store = update_tree_store(g->store, g->count, types);
{
if (*name == '\0')
return;
- g->columns = gv_recalloc(g->columns, g->count, g->count + 1,
+ assert(g->count >= 0);
+ g->columns = gv_recalloc(g->columns, (size_t)g->count, (size_t)g->count + 1,
sizeof(gridCol*));
g->columns[g->count] = gv_alloc(sizeof(gridCol));
g->columns[g->count]->editable = editable;