Re: [PATCH 1/2] drm: expose subpixel order name routine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx> 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
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux