]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[image] Use list_first_entry() to clarify logic in main()
authorMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2011 17:10:24 +0000 (17:10 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2011 19:53:58 +0000 (19:53 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/main.c
src/include/ipxe/image.h

index 35f31c2c10ccf428dbe11b596fc81851f70abd4b..7d411d6a5b495544651324302dc484adb50ffb23 100644 (file)
@@ -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();
                }
index 2865ea057bf2d14ed6ccf5a126060e56307d68d1..96466ee40d857cf48bcb4fcb73046ee45f5d8324 100644 (file)
@@ -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 );