diff --git a/lib/download.c b/lib/download.c index a7522419..48352331 100644 --- a/lib/download.c +++ b/lib/download.c @@ -211,14 +211,12 @@ xbps_fetch_file(const char *uri, const char *outputdir, bool refetch, struct url_stat url_st; struct fetchIO *fio = NULL; struct timeval tv[2]; - ssize_t bytes_read, bytes_written; + ssize_t bytes_read = -1, bytes_written; off_t bytes_dld = -1; - char buf[4096], *filename, *destfile; + char buf[4096], *filename, *destfile = NULL; int fd = -1, rv = 0; bool restart = false; - filename = destfile = NULL; - bytes_read = bytes_written = -1; fetchLastErrCode = 0; /* diff --git a/lib/plist.c b/lib/plist.c index 030d8cd1..73f1003d 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -472,7 +472,7 @@ prop_dictionary_t xbps_read_dict_from_archive_entry(struct archive *ar, struct archive_entry *entry) { - prop_dictionary_t d; + prop_dictionary_t d = NULL; size_t buflen = 0; ssize_t nbytes = -1; char *buf, *uncomp_buf; diff --git a/lib/purge.c b/lib/purge.c index db983218..00a07f99 100644 --- a/lib/purge.c +++ b/lib/purge.c @@ -83,7 +83,7 @@ remove_pkg_metadata(const char *pkgname) return -1; } - if ((rv = unlink(path)) == -1) { + if (unlink(path) == -1) { if (flags & XBPS_FLAG_VERBOSE) printf("WARNING: can't remove %s (%s)\n", pkgname, strerror(errno)); diff --git a/lib/remove_obsoletes.c b/lib/remove_obsoletes.c index fcc90fe5..262bffe7 100644 --- a/lib/remove_obsoletes.c +++ b/lib/remove_obsoletes.c @@ -34,18 +34,14 @@ int HIDDEN xbps_remove_obsoletes(prop_dictionary_t oldd, prop_dictionary_t newd) { - prop_object_iterator_t iter, iter2; - prop_object_t obj, obj2; - prop_string_t oldstr, newstr; + prop_object_iterator_t iter, iter2 = NULL; + prop_object_t obj, obj2 = NULL; + prop_string_t oldstr = NULL, newstr = NULL; const char *array_str = "files"; char *buf = NULL; int rv = 0; bool found, dolinks = false; - iter = iter2 = NULL; - obj = obj2 = NULL; - oldstr = newstr = NULL; - again: iter = xbps_get_array_iter_from_dict(oldd, array_str); if (iter == NULL) @@ -110,7 +106,7 @@ again: array_str = "links"; prop_object_iterator_release(iter2); prop_object_iterator_release(iter); - iter = iter2 = NULL; + iter2 = NULL; goto again; } diff --git a/lib/repository_findpkg.c b/lib/repository_findpkg.c index 79ebefc9..70626df0 100644 --- a/lib/repository_findpkg.c +++ b/lib/repository_findpkg.c @@ -314,7 +314,7 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg) if (pkgrd == NULL) { if (errno && errno != ENOENT) { rv = errno; - break; + goto out; } DPRINTF(("Package %s not found in repo %s.\n", pkgname, rpool->rp_uri)); @@ -326,12 +326,12 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg) if (!prop_dictionary_get_cstring_nocopy(instpkg, "version", &instver)) { rv = errno; - break; + goto out; } if (!prop_dictionary_get_cstring_nocopy(pkgrd, "version", &repover)) { rv = errno; - break; + goto out; } if (xbps_cmpver(repover, instver) > 0) { DPRINTF(("Found %s-%s in repo %s.\n", diff --git a/lib/repository_sync_index.c b/lib/repository_sync_index.c index a9af4c3b..e9e05d06 100644 --- a/lib/repository_sync_index.c +++ b/lib/repository_sync_index.c @@ -92,8 +92,7 @@ xbps_repository_sync_pkg_index(const char *uri) int rv = 0; bool only_sync = false; - rpidx = lrepodir = uri_fixedp = NULL; - metadir = tmp_metafile = lrepofile = NULL; + tmp_metafile = rpidx = lrepodir = lrepofile = NULL; if (uname(&un) == -1) return -1; diff --git a/lib/sha256.c b/lib/sha256.c index e474c68f..dfa4f52a 100644 --- a/lib/sha256.c +++ b/lib/sha256.c @@ -295,9 +295,6 @@ SHA256_Transform(SHA256_CTX *context, const uint32_t *data) context->state[5] += f; context->state[6] += g; context->state[7] += h; - - /* Clean up */ - a = b = c = d = e = f = g = h = T1 = T2 = 0; } #endif /* SHA2_UNROLL_TRANSFORM */ @@ -331,8 +328,6 @@ XBPS_SHA256_Update(SHA256_CTX *context, const uint8_t *data, size_t len) /* The buffer is not yet full */ memcpy(&context->buffer[usedspace], data, len); context->bitcount += len << 3; - /* Clean up: */ - usedspace = freespace = 0; return 1; } } @@ -366,9 +361,6 @@ XBPS_SHA256_Update(SHA256_CTX *context, const uint8_t *data, size_t len) memcpy(context->buffer, data, len); context->bitcount += len << 3; } - /* Clean up: */ - usedspace = freespace = 0; - return 1; } @@ -428,7 +420,6 @@ SHA224_256_Final(uint8_t digest[], SHA256_CTX *context, size_t len) /* Clean up state data: */ memset(context, 0, sizeof(*context)); - usedspace = 0; return 1; } diff --git a/lib/unpack.c b/lib/unpack.c index 631a18b9..46ed73b9 100644 --- a/lib/unpack.c +++ b/lib/unpack.c @@ -97,14 +97,14 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg) size_t entry_idx = 0; const char *pkgname, *version, *rootdir, *entry_str, *transact; char *buf; - int rv = 0, flags, lflags; - bool preserve, actgt, skip_entry, update; + int rv, flags, lflags; + bool preserve, skip_entry, update; bool props_plist_found, files_plist_found; assert(ar != NULL); assert(pkg != NULL); - preserve = actgt = skip_entry = update = false; + preserve = skip_entry = update = false; props_plist_found = files_plist_found = false; rootdir = xbps_get_rootdir(); flags = xbps_get_flags(); @@ -173,7 +173,6 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg) if (buf == NULL) return errno; - actgt = true; archive_entry_set_pathname(entry, buf); archive_entry_set_mode(entry, 0750); @@ -298,7 +297,6 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg) "path: %s\n", archive_entry_pathname(entry)); } - rv = 0; continue; } }