format/fxt1: Clean up fxt1_variance's argument list

gcc 11 warns:

../src/util/format/u_format_fxt1.c:940:22: warning: ‘fxt1_variance.constprop’ accessing 128 bytes in a region of size 64 [-Wstringop-overflow=]
  940 |    int32_t maxVarR = fxt1_variance(NULL, &input[N_TEXELS / 2], n_comp);

But, suspiciously, if you inline fxt1_variance the warning goes away.
What's happening is that the 2nd arg is uint8_t[N_TEXELS][MAX_COMP], so
it looks like we're passing too small of an array in since gcc knows
that `input` is also [N_TEXELS][MAX_COMP]. Fair enough. Fix the
signature to reflect what's actually going on, and remove some unused
arguments while we're at it.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10671>
This commit is contained in:
Adam Jackson 2021-05-06 12:04:33 -04:00 committed by Marge Bot
parent d96507b73f
commit 4770d6c01d

View file

@ -189,9 +189,9 @@ fxt1_worst (float vec[MAX_COMP],
static int32_t
fxt1_variance (double variance[MAX_COMP],
uint8_t input[N_TEXELS][MAX_COMP], int32_t nc, int32_t n)
fxt1_variance (uint8_t input[N_TEXELS / 2][MAX_COMP], int32_t nc)
{
const int n = N_TEXELS / 2;
int32_t i, k, best = 0;
int32_t sx, sx2;
double var, maxvar = -1; /* small enough */
@ -209,9 +209,6 @@ fxt1_variance (double variance[MAX_COMP],
maxvar = var;
best = i;
}
if (variance) {
variance[i] = var;
}
}
return best;
@ -935,8 +932,8 @@ fxt1_quantize_MIXED0 (uint32_t *cc,
#else
int32_t minVal;
int32_t maxVal;
int32_t maxVarL = fxt1_variance(NULL, input, n_comp, N_TEXELS / 2);
int32_t maxVarR = fxt1_variance(NULL, &input[N_TEXELS / 2], n_comp, N_TEXELS / 2);
int32_t maxVarL = fxt1_variance(input, n_comp);
int32_t maxVarR = fxt1_variance(&input[N_TEXELS / 2], n_comp);
/* Scan the channel with max variance for lo & hi
* and use those as the two representative colors.