lima: fix stringop-overflow warning

New versions of gcc output a warning about this code, apparently
because of the mix of signed and unsigned operations in the loop
condition. Rework the types to fix the warning.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22129>
This commit is contained in:
Erico Nunes 2023-03-26 21:12:18 +02:00 committed by Marge Bot
parent 4f42d3b843
commit 1eb2359bbd

View file

@ -765,16 +765,16 @@ static const int ppir_codegen_field_size[] = {
};
static void
bitcopy(char *src, char *dst, unsigned bits, unsigned src_offset)
bitcopy(unsigned char *src, unsigned char *dst, unsigned bits, unsigned src_offset)
{
src += src_offset / 8;
src_offset %= 8;
for (int b = bits; b > 0; b -= 8, src++, dst++) {
unsigned char out = ((unsigned char) *src) >> src_offset;
for (unsigned b = bits; b > 0; b -= MIN2(b, 8), src++, dst++) {
unsigned char out = *src >> src_offset;
if (src_offset > 0 && src_offset + b > 8)
out |= ((unsigned char) *(src + 1)) << (8 - src_offset);
*dst = (char) out;
out |= *(src + 1) << (8 - src_offset);
*dst = out;
}
}
@ -783,11 +783,11 @@ ppir_disassemble_instr(uint32_t *instr, unsigned offset, FILE *fp)
{
ppir_codegen_ctrl *ctrl = (ppir_codegen_ctrl *) instr;
char *instr_code = (char *) (instr + 1);
unsigned char *instr_code = (unsigned char *) (instr + 1);
unsigned bit_offset = 0;
bool first = true;
for (unsigned i = 0; i < ppir_codegen_field_shift_count; i++) {
char code[12];
unsigned char code[12];
if (!((ctrl->fields >> i) & 1))
continue;