Giovanni Mascellani (@giomasce) commented about libs/vkd3d-shader/hlsl.c:
d = hlsl_new_switch_case(ctx, NULL, &body, &c->loc);
hlsl_block_cleanup(&body);
if (!d)
{
hlsl_cleanup_ir_switch_cases(&cases);
return NULL;
}
d->value = c->value;
d->is_default = c->is_default;
list_add_tail(&cases, &d->entry);
- }
- ret = hlsl_new_switch(ctx, map_instr(map, s->selector.node), &cases, &s->node.loc);
- if (!ret)
hlsl_cleanup_ir_switch_cases(&cases);
Notice that here you can skip the `if (!ret)` part. I don't really care whether you leave it or not, I just noticed that you call `hlsl_block_cleanup()` unconditionally, even though the situation is the same. Your choice.