Kaynağa Gözat

[image] Use list_first_entry() to clarify logic in main()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 13 yıl önce
ebeveyn
işleme
7752541bb7
2 değiştirilmiş dosya ile 11 ekleme ve 5 silme
  1. 2
    5
      src/core/main.c
  2. 9
    0
      src/include/ipxe/image.h

+ 2
- 5
src/core/main.c Dosyayı Görüntüle

@@ -88,11 +88,8 @@ __asmcall int main ( void ) {
88 88
 		 * booting fails for any reason, offer a second chance
89 89
 		 * to enter the shell for diagnostics.
90 90
 		 */
91
-		if ( have_images() ) {
92
-			for_each_image ( image ) {
93
-				image_exec ( image );
94
-				break;
95
-			}
91
+		if ( ( image = first_image() ) != NULL ) {
92
+			image_exec ( image );
96 93
 		} else {
97 94
 			autoboot();
98 95
 		}

+ 9
- 0
src/include/ipxe/image.h Dosyayı Görüntüle

@@ -124,6 +124,15 @@ static inline int have_images ( void ) {
124 124
 	return ( ! list_empty ( &images ) );
125 125
 }
126 126
 
127
+/**
128
+ * Retrieve first image
129
+ *
130
+ * @ret image		Image, or NULL
131
+ */
132
+static inline struct image * first_image ( void ) {
133
+	return list_first_entry ( &images, struct image, list );
134
+}
135
+
127 136
 extern struct image * alloc_image ( void );
128 137
 extern void image_set_uri ( struct image *image, struct uri *uri );
129 138
 extern int image_set_cmdline ( struct image *image, const char *cmdline );

Loading…
İptal
Kaydet