Skip to content

Commit

Permalink
libflash/ipmi-hiomap: Use error codes rather than abort()
Browse files Browse the repository at this point in the history
Admittedly the situations are pretty dire, and usually indicate a
programming failure on the BMC's part, but abort() seems a bit over the
top. The technique was useful for development but shouldn't have made it
into production.

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
  • Loading branch information
amboar authored and stewartsmith committed Nov 2, 2018
1 parent f47fbc9 commit dbdfb0e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions libflash/ipmi-hiomap.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,16 @@ static void ipmi_hiomap_cmd_cb(struct ipmi_msg *msg)
if (msg->resp_size != 6) {
prerror("%u: Unexpected response size: %u\n", msg->data[0],
msg->resp_size);
abort();
res->cc = IPMI_ERR_UNSPECIFIED;
break;
}

ctx->version = msg->data[2];
if (ctx->version < 2) {
prerror("Failed to negotiate protocol v2 or higher: %d\n",
ctx->version);
abort();
res->cc = IPMI_ERR_UNSPECIFIED;
break;
}

parms = (struct hiomap_v2_info *)&msg->data[3];
Expand All @@ -159,7 +161,8 @@ static void ipmi_hiomap_cmd_cb(struct ipmi_msg *msg)
if (msg->resp_size != 6) {
prerror("%u: Unexpected response size: %u\n", msg->data[0],
msg->resp_size);
abort();
res->cc = IPMI_ERR_UNSPECIFIED;
break;
}

parms = (struct hiomap_v2_flash_info *)&msg->data[2];
Expand All @@ -177,7 +180,8 @@ static void ipmi_hiomap_cmd_cb(struct ipmi_msg *msg)
if (msg->resp_size != 8) {
prerror("%u: Unexpected response size: %u\n", msg->data[0],
msg->resp_size);
abort();
res->cc = IPMI_ERR_UNSPECIFIED;
break;
}

parms = (struct hiomap_v2_create_window *)&msg->data[2];
Expand Down Expand Up @@ -316,7 +320,7 @@ static bool hiomap_window_move(struct ipmi_hiomap *ctx, uint8_t command,
if (len != 0 && *size == 0) {
prerror("Invalid window properties: len: %llu, size: %llu\n",
len, *size);
abort();
return false;
}

prlog(PR_DEBUG, "Opened %s window from 0x%x for %u bytes at 0x%x\n",
Expand Down Expand Up @@ -806,7 +810,7 @@ static int ipmi_hiomap_get_flash_info(struct blocklevel_device *bl,
return rc;

if (!hiomap_get_flash_info(ctx)) {
abort();
return FLASH_ERR_DEVICE_GONE;
}

ctx->bl.erase_mask = ctx->erase_granule - 1;
Expand Down

0 comments on commit dbdfb0e

Please sign in to comment.