Commit 25783624d6d0848cf127e112e4b7648265a35ca4

Stefan Sperling 2018-03-12T13:59:29

use stricter CPPFLAGS from mpi

diff --git a/include/got_error.h b/include/got_error.h
index e8a9594..0d03e12 100644
--- a/include/got_error.h
+++ b/include/got_error.h
@@ -81,5 +81,5 @@ static const struct got_error {
 };
 
 const struct got_error * got_error(int code);
-const struct got_error *got_error_from_errno();
+const struct got_error *got_error_from_errno(void);
 const struct got_error *got_ferror(FILE *, int);
diff --git a/lib/diff.c b/lib/diff.c
index 1a90ea1..0cc4663 100644
--- a/lib/diff.c
+++ b/lib/diff.c
@@ -359,9 +359,7 @@ static const struct got_error *
 diff_entry_old_new(struct got_tree_entry *te1, struct got_tree_object *tree2,
     struct got_repository *repo, FILE *outfile)
 {
-	const struct got_error *err;
 	struct got_tree_entry *te2;
-	char hex[SHA1_DIGEST_STRING_LENGTH];
 
 	te2 = match_entry_by_name(te1, tree2);
 	if (te2 == NULL) {
@@ -387,7 +385,6 @@ static const struct got_error *
 diff_entry_new_old(struct got_tree_entry *te2, struct got_tree_object *tree1,
     struct got_repository *repo, FILE *outfile)
 {
-	const struct got_error *err;
 	struct got_tree_entry *te1;
 
 	te1 = match_entry_by_name(te2, tree1);
diff --git a/lib/object.c b/lib/object.c
index e7ec8e7..6190d26 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -154,10 +154,9 @@ read_object_header(struct got_object **obj, struct got_repository *repo,
 	const struct got_error *err;
 	struct got_zstream_buf zb;
 	char *buf;
-	size_t len;
 	const size_t zbsize = 64;
 	size_t outlen, totlen;
-	int i, ret;
+	int i;
 
 	buf = calloc(zbsize, sizeof(char));
 	if (buf == NULL)
@@ -298,26 +297,6 @@ got_object_close(struct got_object *obj)
 	free(obj);
 }
 
-static int
-commit_object_valid(struct got_commit_object *commit)
-{
-	int i;
-	int n;
-
-	if (commit == NULL)
-		return 0;
-
-	n = 0;
-	for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
-		if (commit->tree_id->sha1[i] == 0)
-			n++;
-	}
-	if (n == SHA1_DIGEST_LENGTH)
-		return 0;
-
-	return 1;
-}
-
 static const struct got_error *
 parse_commit_object(struct got_commit_object **commit, char *buf, size_t len)
 {
@@ -469,7 +448,6 @@ parse_tree_entry(struct got_tree_entry **te, size_t *elen, char *buf,
 {
 	char *p = buf, *space;
 	const struct got_error *err = NULL;
-	char hex[SHA1_DIGEST_STRING_LENGTH];
 
 	*te = calloc(1, sizeof(**te));
 	if (*te == NULL)
@@ -527,7 +505,6 @@ parse_tree_object(struct got_tree_object **tree, struct got_repository *repo,
 {
 	const struct got_error *err;
 	size_t remain = len;
-	int nentries;
 
 	*tree = calloc(1, sizeof(**tree));
 	if (*tree == NULL)
@@ -612,7 +589,6 @@ read_commit_object(struct got_commit_object **commit,
 	const struct got_error *err = NULL;
 	size_t len;
 	uint8_t *p;
-	int i, ret;
 
 	if (obj->flags & GOT_OBJ_FLAG_PACKED)
 		err = read_to_mem(&p, &len, f);
@@ -682,7 +658,6 @@ read_tree_object(struct got_tree_object **tree,
 	const struct got_error *err = NULL;
 	size_t len;
 	uint8_t *p;
-	int i, ret;
 
 	if (obj->flags & GOT_OBJ_FLAG_PACKED)
 		err = read_to_mem(&p, &len, f);
diff --git a/lib/pack.c b/lib/pack.c
index a10bec5..1c07f63 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -302,7 +302,6 @@ get_object_idx(struct got_packidx_v2_hdr *packidx, struct got_object_id *id)
 
 	while (i < totobj) {
 		struct got_object_id *oid = &packidx->sorted_ids[i];
-		uint32_t offset;
 		int cmp = got_object_id_cmp(id, oid);
 
 		if (cmp == 0)
@@ -368,7 +367,6 @@ err:
 static void
 cache_packidx(struct got_packidx_v2_hdr *packidx, struct got_repository *repo)
 {
-	struct got_packidx_v2_hdr *p;
 	int i;
 
 	for (i = 0; i < nitems(repo->packidx_cache); i++) {
@@ -463,9 +461,6 @@ get_packfile_path(char **path_packfile, struct got_repository *repo,
 	char *path_packdir;
 	char hex[SHA1_DIGEST_STRING_LENGTH];
 	char *sha1str;
-	char *path_packidx;
-
-	*path_packfile = NULL;
 
 	path_packdir = got_repo_get_path_objects_pack(repo);
 	if (path_packdir == NULL)
@@ -810,11 +805,7 @@ open_delta_object(struct got_object **obj, struct got_repository *repo,
     int delta_type, size_t delta_size)
 {
 	const struct got_error *err = NULL;
-	struct got_object_id base_id;
-	uint8_t base_type;
 	int resolved_type;
-	uint64_t base_size;
-	size_t base_tslen;
 
 	*obj = calloc(1, sizeof(**obj));
 	if (*obj == NULL)
diff --git a/lib/path.c b/lib/path.c
index 9f0d700..2359a13 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -66,7 +66,6 @@ got_path_normalize(const char *path)
 const struct got_error *
 got_path_segment_count(int *count, const char *path)
 {
-	int n = 0;
 	char *s = strdup(path), *p;
 
 	*count = 0;
@@ -111,7 +110,7 @@ const struct got_error *
 got_opentemp_named(char **path, FILE **outfile, const char *basepath)
 {
 	const struct got_error *err = NULL;
-	int fd, ret;
+	int fd;
 
 	if (asprintf(path, "%s-XXXXXX", basepath) == -1) {
 		*path = NULL;
diff --git a/lib/refs.c b/lib/refs.c
index 3064e1c..4a5ef20 100644
--- a/lib/refs.c
+++ b/lib/refs.c
@@ -159,7 +159,6 @@ got_ref_open(struct got_reference **ref, struct got_repository *repo,
 	const struct got_error *err = NULL;
 	char *path_ref = NULL;
 	char *normpath = NULL;
-	const char *parent_dir;
 	char *path_refs = get_refs_dir_path(repo, refname);
 
 	if (path_refs == NULL) {
@@ -202,8 +201,6 @@ struct got_reference *
 got_ref_dup(struct got_reference *ref)
 {
 	struct got_reference *ret;
-	char *name = NULL;
-	char *symref = NULL;
 
 	ret = calloc(1, sizeof(*ret));
 	if (ret == NULL)
diff --git a/lib/zbuf.c b/lib/zbuf.c
index c752076..dcdf5a7 100644
--- a/lib/zbuf.c
+++ b/lib/zbuf.c
@@ -152,7 +152,6 @@ got_inflate_to_file(size_t *outlen, FILE *infile, FILE *outfile)
 	const struct got_error *err;
 	size_t avail;
 	struct got_zstream_buf zb;
-	void *newbuf;
 
 	err = got_inflate_init(&zb, 8192);
 	if (err)
diff --git a/regress/delta/Makefile b/regress/delta/Makefile
index dd45424..0967da5 100644
--- a/regress/delta/Makefile
+++ b/regress/delta/Makefile
@@ -6,7 +6,7 @@ SRCS = delta.c error.c path.c zbuf.c delta_test.c
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lz
 DEBUG = -O0 -g
-CFLAGS += -Werror
+CFLAGS = -Werror -Wall -Wstrict-prototypes -Wunused-variable
 
 NOMAN = yes
 
diff --git a/regress/repository/Makefile b/regress/repository/Makefile
index bba0a30..c54c110 100644
--- a/regress/repository/Makefile
+++ b/regress/repository/Makefile
@@ -7,7 +7,7 @@ SRCS = path.c repository.c error.c refs.c object.c sha1.c diff.c \
 CPPFLAGS = -I${.CURDIR}/../../include
 LDADD = -lutil -lz
 DEBUG = -O0 -g
-CFLAGS += -Werror
+CFLAGS = -Werror -Wall -Wstrict-prototypes -Wunused-variable
 
 NOMAN = yes
 
diff --git a/regress/repository/repository_test.c b/regress/repository/repository_test.c
index 475cdbc..1d2959d 100644
--- a/regress/repository/repository_test.c
+++ b/regress/repository/repository_test.c
@@ -182,7 +182,6 @@ repo_read_log(const char *repo_path)
 	struct got_object_id *id;
 	struct got_object *obj;
 	char *buf;
-	int ret;
 
 	err = got_repo_open(&repo, repo_path);
 	if (err != NULL || repo == NULL)
@@ -221,8 +220,6 @@ repo_read_tree(const char *repo_path)
 	const struct got_error *err;
 	struct got_repository *repo;
 	struct got_object *obj;
-	int i;
-	size_t len;
 
 	err = got_repo_open(&repo, repo_path);
 	if (err != NULL || repo == NULL)
@@ -292,8 +289,6 @@ repo_diff_blob(const char *repo_path)
 	struct got_object *obj2;
 	struct got_blob_object *blob1;
 	struct got_blob_object *blob2;
-	int i;
-	size_t len;
 	FILE *outfile;
 
 	err = got_repo_open(&repo, repo_path);
@@ -348,8 +343,6 @@ repo_diff_tree(const char *repo_path)
 	struct got_object *obj2;
 	struct got_tree_object *tree1;
 	struct got_tree_object *tree2;
-	int i;
-	size_t len;
 	FILE *outfile;
 
 	err = got_repo_open(&repo, repo_path);
@@ -411,7 +404,6 @@ main(int argc, char *argv[])
 	int test_ok = 0, failure = 0;
 	const char *repo_path;
 	int ch;
-	int vflag = 0;
 
 	while ((ch = getopt(argc, argv, "v")) != -1) {
 		switch (ch) {
diff --git a/regress/worktree/Makefile b/regress/worktree/Makefile
index cb4b123..75af81c 100644
--- a/regress/worktree/Makefile
+++ b/regress/worktree/Makefile
@@ -7,7 +7,7 @@ SRCS = worktree.c repository.c object.c path.c error.c refs.c sha1.c pack.c \
 CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
 LDADD = -lutil -lz
 DEBUG = -O0 -g
-CFLAGS += -Werror
+CFLAGS = -Werror -Wall -Wstrict-prototypes -Wunused-variable
 
 NOMAN = yes