فهرست منبع

pkgmaker: improve error message on missing package category

This patch bores up fatal_error(), so that it now takes arguments in
printf-style, but without changing the basic semantics (i.e., messages
prefixed by "Fatal error. " and trailing newline automatically
appended).

Signed-off-by: Phil Sutter <phil@nwl.cc>
Phil Sutter 14 سال پیش
والد
کامیت
846440bfa5
1فایلهای تغییر یافته به همراه8 افزوده شده و 6 حذف شده
  1. 8 6
      tools/adk/pkgmaker.c

+ 8 - 6
tools/adk/pkgmaker.c

@@ -37,10 +37,11 @@
 
 static int nobinpkgs;
 
-static void fatal_error(const char *message) {
-
-	fprintf(stderr, "Fatal error. %s\n", message);
-	exit(1);
+#define fatal_error(...) { \
+	fprintf(stderr, "Fatal error. "); \
+	fprintf(stderr, __VA_ARGS__); \
+	fprintf(stderr, "\n"); \
+	exit(1); \
 }
 
 static int parse_var_hash(char *buf, const char *varname, StrMap *strmap) {
@@ -304,7 +305,8 @@ int main() {
 						fclose(section);
 					}
 				} else
-					fatal_error("Can not find section description for package.");
+					fatal_error("Can not find section description for package %s.",
+							pkgdirp->d_name);
 				
 				fclose(pkg);
 				continue;
@@ -501,7 +503,7 @@ int main() {
 						fclose(section);
 					}
 				} else
-					fatal_error("Can not find section description for package");
+					fatal_error("Can not find section description for package %s.", pkgdirp->d_name);
 
 				unlink(path);
 				cfg = fopen(path, "w");