From: Michael Brown Date: Mon, 7 Mar 2011 17:10:24 +0000 (+0000) Subject: [image] Use list_first_entry() to clarify logic in main() X-Git-Tag: v1.20.1~2262 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7752541bb7c1c338c2390cf6e4f0c035a13515d9;p=thirdparty%2Fipxe.git [image] Use list_first_entry() to clarify logic in main() Signed-off-by: Michael Brown --- diff --git a/src/core/main.c b/src/core/main.c index 35f31c2c1..7d411d6a5 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -88,11 +88,8 @@ __asmcall int main ( void ) { * booting fails for any reason, offer a second chance * to enter the shell for diagnostics. */ - if ( have_images() ) { - for_each_image ( image ) { - image_exec ( image ); - break; - } + if ( ( image = first_image() ) != NULL ) { + image_exec ( image ); } else { autoboot(); } diff --git a/src/include/ipxe/image.h b/src/include/ipxe/image.h index 2865ea057..96466ee40 100644 --- a/src/include/ipxe/image.h +++ b/src/include/ipxe/image.h @@ -124,6 +124,15 @@ static inline int have_images ( void ) { return ( ! list_empty ( &images ) ); } +/** + * Retrieve first image + * + * @ret image Image, or NULL + */ +static inline struct image * first_image ( void ) { + return list_first_entry ( &images, struct image, list ); +} + extern struct image * alloc_image ( void ); extern void image_set_uri ( struct image *image, struct uri *uri ); extern int image_set_cmdline ( struct image *image, const char *cmdline );