[Skiboot] [PATCH 7/8] gard: Fix up do_create return values

Oliver O'Halloran oohall at gmail.com
Thu Nov 30 16:31:28 AEDT 2017


The return value of a subcommand is interpreted as a libflash error code
when it's positive or some subcommand specific error when negative.
Currently the create subcommand always returns zero when exiting (even
for errors) so fix that.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 external/gard/gard.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/external/gard/gard.c b/external/gard/gard.c
index f73b2dc78ec0..86fcbe80d247 100644
--- a/external/gard/gard.c
+++ b/external/gard/gard.c
@@ -668,12 +668,12 @@ static int do_create(struct gard_ctx *ctx, int argc, char **argv)
 		fprintf(stderr, "e.g.\n");
 		fprintf(stderr, "     /Sys0/Node0/Proc0\n");
 		fprintf(stderr, "     /Sys0/Node0/DIMM15\n");
-		return 0;
+		return -1;
 	}
 
 	if (parse_path(argv[1], &path)) {
 		fprintf(stderr, "Unable to parse path\n");
-		return 0;
+		return -1;
 	}
 
 	/* check if we already have a gard record applied to this path */
@@ -682,7 +682,7 @@ static int do_create(struct gard_ctx *ctx, int argc, char **argv)
 			fprintf(stderr,
 				"Unit %s is already GARDed by record %#08x\n",
 				argv[1], be32toh(gard.record_id));
-			return 0;
+			return -1;
 		}
 
 		/*
@@ -709,7 +709,7 @@ static int do_create(struct gard_ctx *ctx, int argc, char **argv)
 
 		if (offset > ctx->gard_data_len - sizeof(gard)) {
 			fprintf(stderr, "No space in GUARD for a new record\n");
-			return 0;
+			return -1;
 		}
 
 		rc = blocklevel_smart_write(ctx->bl,
-- 
2.9.5



More information about the Skiboot mailing list