Fixed some warnings reported by clang.

This commit is contained in:
Juan RP 2014-04-20 10:02:54 +02:00
parent ada3483acc
commit dacbb2f22f
8 changed files with 23 additions and 14 deletions

View File

@ -275,7 +275,7 @@ rcv_load_file(rcv_t *rcv, const char *fname)
static char * static char *
rcv_refs(rcv_t *rcv, const char *s, size_t len) rcv_refs(rcv_t *rcv, const char *s, size_t len)
{ {
map_item_t item = map_new_item(); map_item_t item;
size_t i = 0, j = 0, k = 0, count = len*3; size_t i = 0, j = 0, k = 0, count = len*3;
char *ref = calloc(count, sizeof(char)); char *ref = calloc(count, sizeof(char));
char *buf = calloc(count, sizeof(char)); char *buf = calloc(count, sizeof(char));

View File

@ -283,7 +283,7 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
} }
xbps_dbg_printf(xhp, "Empty transaction dictionary: %s\n", xbps_dbg_printf(xhp, "Empty transaction dictionary: %s\n",
strerror(errno)); strerror(errno));
return rv; goto out;
} }
xbps_dbg_printf(xhp, "Dictionary before transaction happens:\n"); xbps_dbg_printf(xhp, "Dictionary before transaction happens:\n");
xbps_dbg_printf_append(xhp, "%s", xbps_dbg_printf_append(xhp, "%s",

View File

@ -47,7 +47,8 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
struct xbps_repo *repo; struct xbps_repo *repo;
struct stat st; struct stat st;
const char *arch; const char *arch;
char *sha256, *pkgver, *opkgver, *oarch, *pkgname, *tmprepodir, *repodir; char *sha256, *pkgver, *opkgver, *oarch, *pkgname;
char *tmprepodir = NULL, *repodir = NULL;
int rv = 0, ret = 0; int rv = 0, ret = 0;
bool flush = false, found = false; bool flush = false, found = false;
@ -256,7 +257,7 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
if (!repodata_flush(xhp, repodir, idx, idxfiles, idxmeta)) { if (!repodata_flush(xhp, repodir, idx, idxfiles, idxmeta)) {
fprintf(stderr, "%s: failed to write repodata: %s\n", fprintf(stderr, "%s: failed to write repodata: %s\n",
_XBPS_RINDEX, strerror(errno)); _XBPS_RINDEX, strerror(errno));
return -1; goto out;
} }
} }
printf("index: %u packages registered.\n", xbps_dictionary_count(idx)); printf("index: %u packages registered.\n", xbps_dictionary_count(idx));
@ -264,6 +265,11 @@ index_add(struct xbps_handle *xhp, int argc, char **argv, bool force)
out: out:
index_unlock(il); index_unlock(il);
if (tmprepodir) {
free(tmprepodir);
}
if (repodir) {
free(repodir);
}
return rv; return rv;
} }

View File

@ -160,7 +160,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
pthread_mutex_init(&cbd.mtx, NULL); pthread_mutex_init(&cbd.mtx, NULL);
allkeys = xbps_dictionary_all_keys(idx); allkeys = xbps_dictionary_all_keys(idx);
rv = xbps_array_foreach_cb_multi(xhp, allkeys, idx, idx_cleaner_cb, &cbd); (void)xbps_array_foreach_cb_multi(xhp, allkeys, idx, idx_cleaner_cb, &cbd);
for (unsigned int x = 0; x < xbps_array_count(cbd.result); x++) { for (unsigned int x = 0; x < xbps_array_count(cbd.result); x++) {
xbps_array_get_cstring(cbd.result, x, &keyname); xbps_array_get_cstring(cbd.result, x, &keyname);
printf("index-files: removed entry %s\n", keyname); printf("index-files: removed entry %s\n", keyname);
@ -180,7 +180,7 @@ index_clean(struct xbps_handle *xhp, const char *repodir)
cbd.idx = idx; cbd.idx = idx;
cbd.result = xbps_array_create(); cbd.result = xbps_array_create();
allkeys = xbps_dictionary_all_keys(idxfiles); allkeys = xbps_dictionary_all_keys(idxfiles);
rv = xbps_array_foreach_cb_multi(xhp, allkeys, idxfiles, idxfiles_cleaner_cb, &cbd); (void)xbps_array_foreach_cb_multi(xhp, allkeys, idxfiles, idxfiles_cleaner_cb, &cbd);
for (unsigned int x = 0; x < xbps_array_count(cbd.result); x++) { for (unsigned int x = 0; x < xbps_array_count(cbd.result); x++) {
xbps_array_get_cstring(cbd.result, x, &keyname); xbps_array_get_cstring(cbd.result, x, &keyname);
printf("index-files: removed entry %s\n", keyname); printf("index-files: removed entry %s\n", keyname);

View File

@ -56,11 +56,13 @@ index_lock(struct xbps_handle *xhp)
if (il->sem == SEM_FAILED) { if (il->sem == SEM_FAILED) {
fprintf(stderr, "%s: failed to create/open named " fprintf(stderr, "%s: failed to create/open named "
"semaphore: %s\n", _XBPS_RINDEX, strerror(errno)); "semaphore: %s\n", _XBPS_RINDEX, strerror(errno));
free(il);
return NULL; return NULL;
} }
if (sem_wait(il->sem) == -1) { if (sem_wait(il->sem) == -1) {
fprintf(stderr, "%s: failed to lock named semaphore: %s\n", fprintf(stderr, "%s: failed to lock named semaphore: %s\n",
_XBPS_RINDEX, strerror(errno)); _XBPS_RINDEX, strerror(errno));
free(il);
return NULL; return NULL;
} }

View File

@ -235,6 +235,7 @@ sign_repo(struct xbps_handle *xhp, const char *repodir,
binpkg_sig_fd = creat(binpkg_sig, 0644); binpkg_sig_fd = creat(binpkg_sig, 0644);
if (binpkg_sig_fd == -1) { if (binpkg_sig_fd == -1) {
fprintf(stderr, "failed to create %s: %s\n", binpkg_sig, strerror(errno)); fprintf(stderr, "failed to create %s: %s\n", binpkg_sig, strerror(errno));
free(sig);
free(binpkg_sig); free(binpkg_sig);
continue; continue;
} }
@ -248,7 +249,6 @@ sign_repo(struct xbps_handle *xhp, const char *repodir,
free(sig); free(sig);
free(binpkg_sig); free(binpkg_sig);
close(binpkg_sig_fd); close(binpkg_sig_fd);
binpkg_fd = binpkg_sig_fd = -1;
printf("signed successfully %s\n", pkgver); printf("signed successfully %s\n", pkgver);
} }
xbps_object_iterator_release(iter); xbps_object_iterator_release(iter);
@ -290,8 +290,7 @@ sign_repo(struct xbps_handle *xhp, const char *repodir,
if (!repodata_flush(xhp, repodir, repo->idx, repo->idxfiles, meta)) { if (!repodata_flush(xhp, repodir, repo->idx, repo->idxfiles, meta)) {
fprintf(stderr, "failed to write repodata: %s\n", strerror(errno)); fprintf(stderr, "failed to write repodata: %s\n", strerror(errno));
RSA_free(rsa); goto out;
return -1;
} }
printf("Signed repository (%u package%s)\n", printf("Signed repository (%u package%s)\n",
xbps_dictionary_count(repo->idx), xbps_dictionary_count(repo->idx),
@ -300,12 +299,15 @@ sign_repo(struct xbps_handle *xhp, const char *repodir,
out: out:
index_unlock(il); index_unlock(il);
if (defprivkey) {
free(defprivkey);
}
if (rsa) { if (rsa) {
RSA_free(rsa); RSA_free(rsa);
rsa = NULL; rsa = NULL;
} }
if (repo) if (repo) {
xbps_repo_close(repo); xbps_repo_close(repo);
}
return rv ? -1 : 0; return rv ? -1 : 0;
} }

View File

@ -280,7 +280,6 @@ xbps_init(struct xbps_handle *xhp)
xbps_dbg_printf(xhp, "failed to read configuration file %s: %s\n", xbps_dbg_printf(xhp, "failed to read configuration file %s: %s\n",
xhp->conffile, strerror(rv)); xhp->conffile, strerror(rv));
xbps_dbg_printf(xhp, "Using built-in defaults\n"); xbps_dbg_printf(xhp, "Using built-in defaults\n");
rv = 0;
} }
/* Set rootdir */ /* Set rootdir */
if (xhp->rootdir[0] == '\0') { if (xhp->rootdir[0] == '\0') {

View File

@ -124,7 +124,7 @@ xbps_pubkey2fp(struct xbps_handle *xhp, xbps_data_t pubkey)
memcpy(pEncoding, pSshHeader, 11); memcpy(pEncoding, pSshHeader, 11);
index = SshEncodeBuffer(&pEncoding[11], eLen, eBytes); index = SshEncodeBuffer(&pEncoding[11], eLen, eBytes);
index = SshEncodeBuffer(&pEncoding[11 + index], nLen, nBytes); (void)SshEncodeBuffer(&pEncoding[11 + index], nLen, nBytes);
/* /*
* Compute the RSA fingerprint (MD5). * Compute the RSA fingerprint (MD5).