[syslinux] [PATCH 3/6] chain/partiter: adjust error reporting

Michal Soltys soltys at ziu.info
Sun Jun 29 12:41:40 PDT 2014


Use <0 for errors, 0 for normal state, and >0 for clean completion.

In future this would be necessary if it's decided to make partiter
a generic lib (similar to disklib) - though it has to be quieted first
and provide strerr()-like functionality in place of its verbosity.

diff --git a/com32/chain/chain.c b/com32/chain/chain.c
index ae95d45..c08ec6e 100644
--- a/com32/chain/chain.c
+++ b/com32/chain/chain.c
@@ -352,7 +352,7 @@ int find_dp(struct part_iter **_iter)
 	    } while (!pi_next(iter));
 	    /* broken part structure or other problems */
 	    if (iter->status) {
-		error("Can't find myself on the drive I booted from.");
+		error("Unable to find partition with syslinux (fs).");
 		goto bail;
 	    }
 	}
@@ -372,7 +372,7 @@ int find_dp(struct part_iter **_iter)
 		break;
 	} while (!pi_next(iter));
 	if (iter->status) {
-	    error("Requested disk / partition combination not found.");
+	    error("Unable to find requested disk / partition combination.");
 	    goto bail;
 	}
     }
diff --git a/com32/chain/mangle.c b/com32/chain/mangle.c
index ffdaab8..6963574 100644
--- a/com32/chain/mangle.c
+++ b/com32/chain/mangle.c
@@ -562,7 +562,7 @@ int manglepe_hide(struct part_iter *miter)
 	}
     }
 
-    if (pi_errored(iter))
+    if (iter->status < 0)
 	goto bail;
 
     /* last update */
@@ -663,7 +663,7 @@ int manglepe_fixchs(struct part_iter *miter)
 	}
     }
 
-    if (pi_errored(iter))
+    if (iter->status < 0)
 	goto bail;
 
     /* last update */
diff --git a/com32/chain/partiter.h b/com32/chain/partiter.h
index 13dec84..d01a650 100644
--- a/com32/chain/partiter.h
+++ b/com32/chain/partiter.h
@@ -42,7 +42,7 @@
 
 /* status */
 
-enum {PI_OK, PI_DONE, PI_INSANE, PI_ERRLOAD};
+enum {PI_ERRLOAD = -31, PI_INSANE, PI_OK = 0, PI_DONE};
 
 /* flags */
 
@@ -103,11 +103,6 @@ extern const struct itertype * const typeraw;
 struct part_iter *pi_begin(const struct disk_info *, int flags);
 void pi_del(struct part_iter **);
 
-static inline int pi_errored(struct part_iter *iter)
-{
-    return iter->status > PI_DONE;
-}
-
 /* inline virtuals */
 static inline int pi_next(struct part_iter *iter)
 {
-- 
1.7.10.4



More information about the Syslinux mailing list