[U-Boot] [PATCH 05/17] sunxi: video: Improve monitor video-mode option handling

Ian Campbell ijc at hellion.org.uk
Sun Dec 28 10:40:05 CET 2014


On Wed, 2014-12-24 at 20:06 +0100, Hans de Goede wrote:

> +enum sunxi_monitor {
> +	sunxi_monitor_none,
> +	sunxi_monitor_dvi,
> +	sunxi_monitor_hdmi,
> +	sunxi_monitor_lcd,
> +	sunxi_monitor_vga,
> +};
[...]
> +	const char *mon_desc[] = { "none", "dvi", "hdmi", "lcd", "vga" };

These risk getting out of sync. I half expect the array will be punted
by the compiler into static storage anyway, so you could just make it a
global up near the enum (and perhaps use the [sunxi_monitor_none] =
"none" initialiser style).

Another option (which I think I prefer) would be a get_mon_desc helper
with a switch in it over the enum, returning the const char *. Then the
compiler will (hopefully) complain if a new enum is added without a
corresponding description.

The rest all looks fine to me.



More information about the U-Boot mailing list