fix build on OpenBSD/sparc64 (gcc)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
diff --git a/got/got.c b/got/got.c
index 48602a4..7042801 100644
--- a/got/got.c
+++ b/got/got.c
@@ -1083,7 +1083,7 @@ static const struct got_error *
get_worktree_paths_from_argv(struct got_pathlist_head *paths, int argc,
char *argv[], struct got_worktree *worktree)
{
- const struct got_error *err;
+ const struct got_error *err = NULL;
char *path;
int i;
@@ -4647,6 +4647,8 @@ histedit_check_script(struct got_histedit_list *histedit_cmds,
if (TAILQ_EMPTY(histedit_cmds))
return got_error_msg(GOT_ERR_EMPTY_HISTEDIT,
"histedit script contains no commands");
+ if (SIMPLEQ_EMPTY(commits))
+ return got_error(GOT_ERR_EMPTY_HISTEDIT);
SIMPLEQ_FOREACH(qid, commits, entry) {
TAILQ_FOREACH(hle, histedit_cmds, entry) {
diff --git a/lib/blame.c b/lib/blame.c
index eda1af0..e00d1af 100644
--- a/lib/blame.c
+++ b/lib/blame.c
@@ -413,8 +413,10 @@ done:
static const struct got_error *
blame_line(struct got_object_id **id, struct got_blame *blame, int lineno)
{
- if (lineno < 1 || lineno > blame->nlines)
+ if (lineno < 1 || lineno > blame->nlines) {
+ *id = NULL;
return got_error(GOT_ERR_RANGE);
+ }
*id = &blame->lines[lineno - 1].id;
return NULL;
}
@@ -452,7 +454,7 @@ got_blame(const char *path, struct got_object_id *start_commit_id,
}
for (lineno = 1; lineno <= blame->nlines; lineno++) {
- struct got_object_id *id;
+ struct got_object_id *id = NULL;
char *line, *id_str;
line = parse_next_line(blame->f, NULL);
diff --git a/lib/object_cache.c b/lib/object_cache.c
index 0c1a60f..6d87621 100644
--- a/lib/object_cache.c
+++ b/lib/object_cache.c
@@ -157,6 +157,8 @@ got_object_cache_add(struct got_object_cache *cache, struct got_object_id *id, v
case GOT_OBJECT_CACHE_TYPE_TAG:
size = get_size_tag((struct got_tag_object *)item);
break;
+ default:
+ return got_error(GOT_ERR_OBJ_TYPE);
}
if (size > GOT_OBJECT_CACHE_MAX_ELEM_SIZE) {
diff --git a/lib/object_parse.c b/lib/object_parse.c
index bbf3289..a7eb8cd 100644
--- a/lib/object_parse.c
+++ b/lib/object_parse.c
@@ -608,6 +608,8 @@ parse_tree_entry(struct got_tree_entry **te, size_t *elen, char *buf,
char *p, *space;
const struct got_error *err = NULL;
+ *elen = 0;
+
*te = got_alloc_tree_entry_partial();
if (*te == NULL)
return got_error_from_errno("got_alloc_tree_entry_partial");
diff --git a/lib/pack.c b/lib/pack.c
index d9d0f11..06a6211 100644
--- a/lib/pack.c
+++ b/lib/pack.c
@@ -628,6 +628,7 @@ parse_negative_offset(int64_t *offset, size_t *len, struct got_pack *pack,
uint8_t offN;
int i = 0;
+ *offset = 0;
*len = 0;
do {
diff --git a/lib/worktree.c b/lib/worktree.c
index 58f47bc..d648267 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -2363,7 +2363,7 @@ read_ignores(struct got_pathlist_head *ignores, const char *path, FILE *f)
const struct got_error *err = NULL;
struct got_pathlist_entry *pe = NULL;
struct got_pathlist_head *ignorelist;
- char *line = NULL, *pattern, *dirpath;
+ char *line = NULL, *pattern, *dirpath = NULL;
size_t linesize = 0;
ssize_t linelen;
diff --git a/tog/tog.c b/tog/tog.c
index 210e39c..f6655ba 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -3980,6 +3980,8 @@ blame_tree_entry(struct tog_view **new_view, int begin_x,
char *path;
struct tog_view *blame_view;
+ *new_view = NULL;
+
err = tree_entry_path(&path, parents, te);
if (err)
return err;
@@ -4007,6 +4009,8 @@ log_tree_entry(struct tog_view **new_view, int begin_x,
const struct got_error *err = NULL;
char *path;
+ *new_view = NULL;
+
log_view = view_open(0, 0, 0, begin_x, TOG_VIEW_LOG);
if (log_view == NULL)
return got_error_from_errno("view_open");
@@ -4113,7 +4117,7 @@ static const struct got_error *
search_next_tree_view(struct tog_view *view)
{
struct tog_tree_view_state *s = &view->state.tree;
- struct got_tree_entry *entry, *te;
+ struct got_tree_entry *entry = NULL, *te;
if (!view->searching) {
view->search_next_done = 1;