diff options
author | Frederic Bonnard <frediz@linux.vnet.ibm.com> | 2015-06-22 13:07:45 +0200 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-06-23 13:24:39 +1000 |
commit | 3cc125c0d9985b3dde430d7399b2c5021e112484 (patch) | |
tree | 47f596d40ae8de1a42f6a7114c2b15d7f649a697 /external | |
parent | 0914bb1b9106638378d5d4a3b4f39a4736c43c41 (diff) | |
download | talos-skiboot-3cc125c0d9985b3dde430d7399b2c5021e112484.tar.gz talos-skiboot-3cc125c0d9985b3dde430d7399b2c5021e112484.zip |
Fixes for compilation with -Werror
On Debian/Ubuntu, additionnal compilation flags are added such as -Werror which make
compilation fail. So :
- checking function return codes so that the compilation doesn't fail.
- moving 'largest' variable so that gcc always sees it with a value.
Signed-off-by: Frederic Bonnard <frediz@linux.vnet.ibm.com>
Acked-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/gard/gard.c | 4 | ||||
-rw-r--r-- | external/opal-prd/opal-prd.c | 32 | ||||
-rw-r--r-- | external/opal-prd/pnor.c | 14 |
3 files changed, 40 insertions, 10 deletions
diff --git a/external/gard/gard.c b/external/gard/gard.c index c43e05a0..93a1c07a 100644 --- a/external/gard/gard.c +++ b/external/gard/gard.c @@ -511,7 +511,7 @@ static int do_show(struct gard_ctx *ctx, int argc, char **argv) static int do_clear_i(struct gard_ctx *ctx, int pos, struct gard_record *gard, void *priv) { - int largest, rc = 0; + int largest = 0, rc = 0; char *buf; struct gard_record null_gard; @@ -533,8 +533,6 @@ static int do_clear_i(struct gard_ctx *ctx, int pos, struct gard_record *gard, v return rc; } printf("done\n"); - - largest = 0; } else if (be32toh(gard->record_id) == *(uint32_t *)priv) { largest = get_largest_pos(ctx); if (largest < 0 || pos > largest) { diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c index bf8f2ae5..9f686c5d 100644 --- a/external/opal-prd/opal-prd.c +++ b/external/opal-prd/opal-prd.c @@ -707,7 +707,12 @@ static void dump_hbrt_map(struct opal_prd_ctx *ctx) return; } - ftruncate(fd, 0); + rc = ftruncate(fd, 0); + if (rc < 0) { + pr_log(LOG_NOTICE, "IMAGE: couldn't truncate image %s for writing", + dump_name); + return; + } rc = write(fd, ctx->code_addr, ctx->code_size); close(fd); @@ -772,8 +777,18 @@ static int prd_init_one_range(struct opal_prd_ctx *ctx, const char *path, __be64 *reg; void *buf; - asprintf(&label_path, "%s/%s/ibm,prd-label", path, dirent->d_name); - asprintf(®_path, "%s/%s/reg", path, dirent->d_name); + rc = asprintf(&label_path, "%s/%s/ibm,prd-label", path, dirent->d_name); + if (rc < 0) { + pr_log(LOG_ERR, "FW: error creating 'ibm,prd-label' path " + "node: %m"); + return -1; + } + rc = asprintf(®_path, "%s/%s/reg", path, dirent->d_name); + if (rc < 0) { + pr_log(LOG_ERR, "FW: error creating 'reg' path " + " node: %m"); + return -1; + } reg = NULL; label = NULL; @@ -823,9 +838,16 @@ static int prd_init_ranges(struct opal_prd_ctx *ctx) struct dirent *dirent; char *path; DIR *dir; - int rc = -1; + int rc; - asprintf(&path, "%s/reserved-memory", devicetree_base); + rc = asprintf(&path, "%s/reserved-memory", devicetree_base); + if (rc < 0) { + pr_log(LOG_ERR, "FW: error creating 'reserved-memory' path " + "node: %m"); + return -1; + } + + rc = -1; dir = opendir(path); if (!dir) { diff --git a/external/opal-prd/pnor.c b/external/opal-prd/pnor.c index 95a4aa5e..43814ab8 100644 --- a/external/opal-prd/pnor.c +++ b/external/opal-prd/pnor.c @@ -139,7 +139,12 @@ static int mtd_write(struct pnor *pnor, int fd, void *data, uint64_t offset, goto out; } - read(fd, buf, pnor->erasesize); + rc = read(fd, buf, pnor->erasesize); + if (rc < 0) { + pr_log(LOG_ERR, "PNOR: read(0x%x bytes) failed: %m", + pnor->erasesize); + goto out; + } } if (end_waste) { @@ -154,7 +159,12 @@ static int mtd_write(struct pnor *pnor, int fd, void *data, uint64_t offset, goto out; } - read(fd, buf + write_len - pnor->erasesize, pnor->erasesize); + rc = read(fd, buf + write_len - pnor->erasesize, pnor->erasesize); + if (rc < 0) { + pr_log(LOG_ERR, "PNOR: read(0x%x bytes) failed: %m", + pnor->erasesize); + goto out; + } } /* Put data in the correct spot */ |