From: Chris Wilson Subject: Re: [PATCH 1/2] drm: expose subpixel order name routine Date: Tue, 21 Jan 2014 21:27:54 +0000 Message-ID: <20140121212754.GA28361@nuc-i3427.alporthouse.com> References: <1390262100-13526-1-git-send-email-jbarnes@virtuousgeek.org> <20140121090504.GA28641@nuc-i3427.alporthouse.com> <20140121124608.43210683@jbarnes-desktop> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from fireflyinternet.com (mail.fireflyinternet.com [87.106.93.118]) by gabe.freedesktop.org (Postfix) with ESMTP id 2ACBCFB634 for ; Tue, 21 Jan 2014 13:27:58 -0800 (PST) Content-Disposition: inline In-Reply-To: <20140121124608.43210683@jbarnes-desktop> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org To: Jesse Barnes Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Tue, Jan 21, 2014 at 12:46:08PM -0800, Jesse Barnes wrote: > On Tue, 21 Jan 2014 09:05:04 +0000 > Chris Wilson 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