[Intel-gfx] [PATCH 1/2] drm: expose subpixel order name routine
Chris Wilson
chris at chris-wilson.co.uk
Tue Jan 21 22:27:54 CET 2014
On Tue, Jan 21, 2014 at 12:46:08PM -0800, Jesse Barnes wrote:
> On Tue, 21 Jan 2014 09:05:04 +0000
> Chris Wilson <chris at chris-wilson.co.uk> wrote:
>
> > On Mon, Jan 20, 2014 at 03:54:59PM -0800, Jesse Barnes wrote:
> > > Just like we have for connector type etc.
> >
> > Then we might as well take a similar defensive approach if we want to
> > expand the number of contexts we call it from.
>
> Since I'm not printing an identifier number into the string I can just
> return the one from the array, if that's what you mean. Fixed.
Heh, sounds useful as well. :)
I was thinking of the style encouraged for intel_output_name(), viz
const char *intel_subpixel_order_to_string(enum subpixel_order order) /* or whatever it was called */
{
static const char *names[] = {
[SubPixelUnknown] = "unknown",
};
if ((unsigned)order >= ARRAY_SIZE(names) || !names[order])
return "unknown"
return names[order];
}
If we were consistent in using that approach, the code is robust against
any changes or bad input, without being too cumbersome.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
More information about the Intel-gfx
mailing list