Re: Build fail in drivers/gpu/drm/i915/display/intel_tc.c

From: Linus Torvalds
Date: Thu Nov 09 2023 - 19:52:04 EST


On Thu, 9 Nov 2023 at 15:34, Imre Deak <imre.deak@xxxxxxxxx> wrote:
>
> The compiler warn should be fixed/suppressed by:
> https://lore.kernel.org/all/20231026125636.5080-1-nirmoy.das@xxxxxxxxx

Ugh, so now it's a dynamic allocation, wasting memory, and a pointer
to it, using as much memory as the array did in the first place.

All because of a pointless warning that was a false positive - and was
always harmless anyway, since snprintf() is safe (ie it was only a
"might be truncated").

Please don't do this. Either do that ((tc_port & 7) + 1) suggestion of
David's, or just do '%c' and make the expression be

'1' + tc_port

which should be fine since I915_MAX_PORTS is 8 or whatever.

I do wonder why those ports are printed out as '1-8', when the 'enum
port' is PORT_A..I.

So it would actually have made more sense to print them out as %c with
the expression being

'A'+tc_port

but I guess by now people might depend on the 1..8 naming?

Linus