summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@simtec.co.uk>2011-08-23 09:15:13 +0100
committerDaniel Silverstone <dsilvers@simtec.co.uk>2011-08-23 09:15:13 +0100
commit1d95afa7c513ca1aadc757925d9ed42e0335f179 (patch)
tree3de205b93cd11a84977f641bb88e960a00b64554
parent5ff2ae36fe0e94b64b2440d188d23342586bbf0d (diff)
downloadtbdiff-1d95afa7c513ca1aadc757925d9ed42e0335f179.tar.gz
CFLAGS: Add -Werror and make the code warning-clean
-rw-r--r--Makefile2
-rw-r--r--create.c12
-rw-r--r--otap_apply.c8
-rw-r--r--stat.c2
4 files changed, 17 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index d340c1d..f7b2c98 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ CC := gcc
OPT ?= -O2
CFLAGS ?=
-CFLAGS += -Wall -Wextra $(OPT)
+CFLAGS += -Wall -Wextra -Werror $(OPT)
SHARED_SRC := otap.c stat.c
DEPLOY_SRC := deploy.c otap_apply.c
diff --git a/create.c b/create.c
index ee8b362..d231491 100644
--- a/create.c
+++ b/create.c
@@ -26,14 +26,22 @@ int main(int argc, char** argv) {
fprintf(stderr, "Error: Unable to stat '%s'.\n", argv[1]);
return EXIT_FAILURE;
}
- chdir(cwd_buff);
+
+ if (chdir(cwd_buff) != 0) {
+ fprintf(stderr, "Error: Unable to return to '%s'.\n", cwd_buff);
+ return EXIT_FAILURE;
+ }
tstat[1] = otap_stat(argv[2]);
if(tstat[1] == NULL) {
fprintf(stderr, "Error: Unable to stat '%s'.\n", argv[2]);
return EXIT_FAILURE;
}
- chdir(cwd_buff);
+
+ if (chdir(cwd_buff) != 0) {
+ fprintf(stderr, "Error: Unable to return to '%s'.\n", cwd_buff);
+ return EXIT_FAILURE;
+ }
FILE* fp = fopen("patch.otap", "wb");
if(fp == NULL) {
diff --git a/otap_apply.c b/otap_apply.c
index d501924..a0b392f 100644
--- a/otap_apply.c
+++ b/otap_apply.c
@@ -124,7 +124,7 @@ static int _otap_apply_cmd_file_create(FILE* stream) {
if(fread(&fsize, 4, 1, stream) != 1)
otap_error(otap_error_unable_to_read_stream);
- printf("cmd_file_create %s:%"PRIuPTR"\n", fname, fsize);
+ printf("cmd_file_create %s:%"PRId32"\n", fname, fsize);
FILE* fp = fopen(fname, "rb");
if(fp != NULL) {
@@ -262,13 +262,15 @@ static int __otap_apply_cmd_entity_delete(const char* name) {
int err;
if((err = __otap_apply_cmd_entity_delete(entry->d_name)) != 0) {
closedir(dp);
- chdir("..");
+ if (chdir("..") != 0)
+ otap_error(otap_error_unable_to_change_dir);
return err;
}
}
closedir(dp);
- chdir("..");
+ if (chdir("..") != 0)
+ otap_error(otap_error_unable_to_change_dir);
if(remove(name) != 0)
otap_error(otap_error_unable_to_remove_file);
return 0;
diff --git a/stat.c b/stat.c
index 111812f..c076da0 100644
--- a/stat.c
+++ b/stat.c
@@ -84,7 +84,7 @@ void otap_stat_free(otap_stat_t* file) {
}
void otap_stat_print(otap_stat_t* file) {
-
+ (void)file;
}
otap_stat_t* otap_stat_entry(otap_stat_t* file, uint32_t entry) {