diff options
author | Andy Green <andy.green@linaro.org> | 2012-10-19 08:03:36 +0800 |
---|---|---|
committer | Andy Green <andy.green@linaro.org> | 2012-10-19 08:03:36 +0800 |
commit | 11e80db556dfece23e313a327bb95cb4efbef869 (patch) | |
tree | 443667507513f5879c4de6d66f06a0786c52e402 | |
parent | 78f353909176a92632af496626eb968fc0892954 (diff) |
fix compile warnings under ubuntu
These aren't reported by default in Fedora Rawhide gcc
Reported-by: Nicolas Dechesne <n-dechesne@ti.com>
Signed-off-by: Andy Green <andy.green@linaro.org>
-rw-r--r-- | libarmep/configuration.c | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/libarmep/configuration.c b/libarmep/configuration.c index 67752ca..829ba09 100644 --- a/libarmep/configuration.c +++ b/libarmep/configuration.c @@ -134,6 +134,7 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_ char temp_config[1024]; char linebuf[1024]; int no_copy = 0; + int ret = 0; if (wch) { strncpy(temp_config, config_filepath, sizeof temp_config - 2); @@ -177,7 +178,10 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_ entry_parser = parser; if (!no_copy && wfd > 0) - write(wfd, &c, 1); + if (write(wfd, &c, 1) < 1) { + fprintf(stderr, "Unable to write config file\n"); + goto bail; + } switch (parser) { case ACPP_FIRST: @@ -290,7 +294,10 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_ if (aep->aep_context->verbose) fprintf(stderr, "Updating config " "with \"%s\"\n", linebuf); - write(wfd, linebuf, strlen(linebuf)); + if (write(wfd, linebuf, strlen(linebuf)) < 0) { + fprintf(stderr, "Unable to write config file\n"); + goto bail; + } } ch++; @@ -361,20 +368,24 @@ int configure(struct aep_context *aep_context, struct aep *aep, const char *dev_ } c = buf[pos++]; - write(wfd, &c, 1); + if (write(wfd, &c, 1) < 0) { + fprintf(stderr, "Unable to write config file\n"); + goto bail; + } } - - close(wfd); } - +bail: close(fd); if (wfd > 0) { - unlink(config_filepath); - rename(temp_config, config_filepath); + close(wfd); + if (!ret) { + unlink(config_filepath); + rename(temp_config, config_filepath); + } } - return 0; + return ret; } |