diff mbox series

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

Message ID 20171130053129.22642-7-oohall@gmail.com
State Accepted
Headers show
Series [1/8] gard: Allow records with an ID of 0xffffffff | expand

Commit Message

Oliver O'Halloran Nov. 30, 2017, 5:31 a.m. UTC
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@gmail.com>
---
 external/gard/gard.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

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,