Misc cleanups: use __attribute__((__unused__)); remove dead code.

This commit is contained in:
Juan RP
2013-08-29 10:45:30 +02:00
parent efcb373f96
commit a039330f3c
15 changed files with 56 additions and 111 deletions

View File

@ -175,15 +175,13 @@ entry_is_conf_file(const char *file)
} }
static int static int
ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf) ftw_cb(const char *fpath, const struct stat *sb, int type, struct FTW *ftwbuf _unused)
{ {
struct xentry *xe = NULL; struct xentry *xe = NULL;
const char *filep = NULL; const char *filep = NULL;
char *buf, *p, *p2, *dname; char *buf, *p, *p2, *dname;
ssize_t r; ssize_t r;
(void)ftwbuf;
/* Ignore metadata files generated by xbps-src and destdir */ /* Ignore metadata files generated by xbps-src and destdir */
if ((strcmp(fpath, ".") == 0) || if ((strcmp(fpath, ".") == 0) ||
(strcmp(fpath, "./props.plist") == 0) || (strcmp(fpath, "./props.plist") == 0) ||

View File

@ -63,10 +63,8 @@ usage(bool fail)
} }
static void static void
unpack_progress_cb(struct xbps_unpack_cb_data *xpd, void *cbdata) unpack_progress_cb(struct xbps_unpack_cb_data *xpd, void *cbdata _unused)
{ {
(void)cbdata;
if (xpd->entry == NULL || xpd->entry_total_count <= 0) if (xpd->entry == NULL || xpd->entry_total_count <= 0)
return; return;

View File

@ -32,15 +32,13 @@
#include "defs.h" #include "defs.h"
void void
state_cb(struct xbps_state_cb_data *xscd, void *cbdata) state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused)
{ {
xbps_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *instver, *newver; const char *instver, *newver;
char *pkgname; char *pkgname;
bool syslog_enabled = false; bool syslog_enabled = false;
(void)cbdata;
if (xscd->xhp->flags & XBPS_FLAG_SYSLOG) { if (xscd->xhp->flags & XBPS_FLAG_SYSLOG) {
syslog_enabled = true; syslog_enabled = true;
openlog("xbps-install", LOG_CONS, LOG_USER); openlog("xbps-install", LOG_CONS, LOG_USER);

View File

@ -36,16 +36,16 @@
#include "defs.h" #include "defs.h"
static int static int
pkgdb_cb(struct xbps_handle *xhp, xbps_object_t obj, const char *key, void *arg, bool *done) pkgdb_cb(struct xbps_handle *xhp _unused,
xbps_object_t obj,
const char *key _unused,
void *arg _unused,
bool *done _unused)
{ {
const char *pkgver; const char *pkgver;
char *pkgname; char *pkgname;
int rv; int rv;
(void)key;
(void)arg;
(void)done;
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
if (xhp->flags & XBPS_FLAG_VERBOSE) if (xhp->flags & XBPS_FLAG_VERBOSE)
printf("Checking %s ...\n", pkgver); printf("Checking %s ...\n", pkgver);

View File

@ -43,13 +43,10 @@
* and remove them if that was true. * and remove them if that was true.
*/ */
int int
check_pkg_unneeded(struct xbps_handle *xhp, const char *pkgname, void *arg) check_pkg_unneeded(struct xbps_handle *xhp _unused, const char *pkgname _unused, void *arg)
{ {
xbps_dictionary_t pkgd = arg; xbps_dictionary_t pkgd = arg;
(void)xhp;
(void)pkgname;
if (xbps_dictionary_get(pkgd, "remove-and-update")) if (xbps_dictionary_get(pkgd, "remove-and-update"))
xbps_dictionary_remove(pkgd, "remove-and-update"); xbps_dictionary_remove(pkgd, "remove-and-update");

View File

@ -39,11 +39,11 @@ struct list_pkgver_cb {
}; };
int int
list_pkgs_in_dict(struct xbps_handle *xhp, list_pkgs_in_dict(struct xbps_handle *xhp _unused,
xbps_object_t obj, xbps_object_t obj,
const char *key, const char *key _unused,
void *arg, void *arg,
bool *loop_done) bool *loop_done _unused)
{ {
struct list_pkgver_cb *lpc = arg; struct list_pkgver_cb *lpc = arg;
const char *pkgver, *short_desc, *state_str; const char *pkgver, *short_desc, *state_str;
@ -51,10 +51,6 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
int i, len = 0; int i, len = 0;
pkg_state_t state; pkg_state_t state;
(void)xhp;
(void)key;
(void)loop_done;
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc); xbps_dictionary_get_cstring_nocopy(obj, "short_desc", &short_desc);
if (!pkgver || !short_desc) if (!pkgver || !short_desc)
@ -93,20 +89,15 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
} }
int int
list_manual_pkgs(struct xbps_handle *xhp, list_manual_pkgs(struct xbps_handle *xhp _unused,
xbps_object_t obj, xbps_object_t obj,
const char *key, const char *key _unused,
void *arg, void *arg _unused,
bool *loop_done) bool *loop_done _unused)
{ {
const char *pkgver; const char *pkgver;
bool automatic = false; bool automatic = false;
(void)xhp;
(void)key;
(void)arg;
(void)loop_done;
xbps_dictionary_get_bool(obj, "automatic-install", &automatic); xbps_dictionary_get_bool(obj, "automatic-install", &automatic);
if (automatic == false) { if (automatic == false) {
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
@ -117,16 +108,14 @@ list_manual_pkgs(struct xbps_handle *xhp,
} }
int int
list_hold_pkgs(struct xbps_handle *xhp, xbps_object_t obj, list_hold_pkgs(struct xbps_handle *xhp _unused,
const char *key, void *arg, bool *loop_done) xbps_object_t obj,
const char *key _unused,
void *arg _unused,
bool *loop_done _unused)
{ {
const char *pkgver; const char *pkgver;
(void)xhp;
(void)key;
(void)arg;
(void)loop_done;
if (xbps_dictionary_get(obj, "hold")) { if (xbps_dictionary_get(obj, "hold")) {
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
printf("%s\n", pkgver); printf("%s\n", pkgver);
@ -166,11 +155,8 @@ list_pkgs_pkgdb(struct xbps_handle *xhp)
} }
static int static int
repo_list_uri_cb(struct xbps_repo *repo, void *arg, bool *done) repo_list_uri_cb(struct xbps_repo *repo, void *arg _unused, bool *done _unused)
{ {
(void)arg;
(void)done;
printf("%5zd %s\n", repo->idx ? (ssize_t)xbps_dictionary_count(repo->idx) : -1, repo->uri); printf("%5zd %s\n", repo->idx ? (ssize_t)xbps_dictionary_count(repo->idx) : -1, repo->uri);
return 0; return 0;
@ -196,20 +182,16 @@ struct fflongest {
}; };
static int static int
_find_longest_pkgver_cb(struct xbps_handle *xhp, _find_longest_pkgver_cb(struct xbps_handle *xhp _unused,
xbps_object_t obj, xbps_object_t obj,
const char *key, const char *key _unused,
void *arg, void *arg,
bool *loop_done) bool *loop_done _unused)
{ {
struct fflongest *ffl = arg; struct fflongest *ffl = arg;
const char *pkgver; const char *pkgver;
unsigned int len; unsigned int len;
(void)xhp;
(void)key;
(void)loop_done;
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
len = strlen(pkgver); len = strlen(pkgver);
if (ffl->len == 0 || len > ffl->len) if (ffl->len == 0 || len > ffl->len)

View File

@ -87,7 +87,11 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd,
} }
static int static int
ownedby_pkgdb_cb(struct xbps_handle *xhp, xbps_object_t obj, const char *obj_key, void *arg, bool *done) ownedby_pkgdb_cb(struct xbps_handle *xhp,
xbps_object_t obj,
const char *obj_key _unused,
void *arg,
bool *done _unused)
{ {
xbps_dictionary_t pkgmetad; xbps_dictionary_t pkgmetad;
xbps_array_t files_keys; xbps_array_t files_keys;
@ -138,16 +142,17 @@ ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
} }
static int static int
repo_match_cb(struct xbps_handle *xhp, xbps_object_t obj, const char *key, void *arg, bool *done) repo_match_cb(struct xbps_handle *xhp _unused,
xbps_object_t obj,
const char *key,
void *arg,
bool *done _unused)
{ {
struct ffdata *ffd = arg; struct ffdata *ffd = arg;
const char *filestr; const char *filestr;
unsigned int i; unsigned int i;
int x; int x;
(void)xhp;
(void)done;
for (i = 0; i < xbps_array_count(obj); i++) { for (i = 0; i < xbps_array_count(obj); i++) {
xbps_array_get_cstring_nocopy(obj, i, &filestr); xbps_array_get_cstring_nocopy(obj, i, &filestr);
for (x = 0; x < ffd->npatterns; x++) { for (x = 0; x < ffd->npatterns; x++) {
@ -162,15 +167,13 @@ repo_match_cb(struct xbps_handle *xhp, xbps_object_t obj, const char *key, void
} }
static int static int
repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done) repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done _unused)
{ {
xbps_array_t allkeys; xbps_array_t allkeys;
xbps_dictionary_t filesd; xbps_dictionary_t filesd;
struct ffdata *ffd = arg; struct ffdata *ffd = arg;
int rv; int rv;
(void)done;
filesd = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES); filesd = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES);
if (filesd == NULL) if (filesd == NULL)
return 0; return 0;

View File

@ -98,16 +98,16 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
} }
static int static int
search_array_cb(struct xbps_handle *xhp, xbps_object_t obj, const char *key, void *arg, bool *done) search_array_cb(struct xbps_handle *xhp _unused,
xbps_object_t obj,
const char *key _unused,
void *arg,
bool *done _unused)
{ {
struct search_data *sd = arg; struct search_data *sd = arg;
const char *pkgver, *desc; const char *pkgver, *desc;
int x; int x;
(void)xhp;
(void)key;
(void)done;
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(obj, "short_desc", &desc); xbps_dictionary_get_cstring_nocopy(obj, "short_desc", &desc);
@ -130,14 +130,12 @@ search_array_cb(struct xbps_handle *xhp, xbps_object_t obj, const char *key, voi
} }
static int static int
search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done) search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done _unused)
{ {
xbps_array_t allkeys; xbps_array_t allkeys;
struct search_data *sd = arg; struct search_data *sd = arg;
int rv; int rv;
(void)done;
if (repo->idx == NULL) if (repo->idx == NULL)
return 0; return 0;

View File

@ -51,12 +51,10 @@ usage(bool fail)
} }
static void static void
state_cb(struct xbps_state_cb_data *xscd, void *cbd) state_cb(struct xbps_state_cb_data *xscd, void *cbd _unused)
{ {
bool syslog_enabled = false; bool syslog_enabled = false;
(void)cbd;
if (xscd->xhp->flags & XBPS_FLAG_SYSLOG) { if (xscd->xhp->flags & XBPS_FLAG_SYSLOG) {
syslog_enabled = true; syslog_enabled = true;
openlog("xbps-reconfigure", LOG_CONS, LOG_USER); openlog("xbps-reconfigure", LOG_CONS, LOG_USER);

View File

@ -63,12 +63,10 @@ usage(bool fail)
} }
static void static void
state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata) state_cb_rm(struct xbps_state_cb_data *xscd, void *cbdata _unused)
{ {
bool syslog_enabled = false; bool syslog_enabled = false;
(void)cbdata;
if (xscd->xhp->flags & XBPS_FLAG_SYSLOG) { if (xscd->xhp->flags & XBPS_FLAG_SYSLOG) {
syslog_enabled = true; syslog_enabled = true;
openlog("xbps-remove", LOG_CONS, LOG_USER); openlog("xbps-remove", LOG_CONS, LOG_USER);

View File

@ -37,24 +37,11 @@
#include "defs.h" #include "defs.h"
static int static int
remove_pkg(const char *repodir, const char *arch, const char *file) remove_pkg(const char *repodir, const char *file)
{ {
char *filepath; char *filepath;
int rv; int rv;
filepath = xbps_xasprintf("%s/%s/%s", repodir, arch, file);
if (remove(filepath) == -1) {
if (errno != ENOENT) {
rv = errno;
fprintf(stderr, "xbps-rindex: failed to remove "
"package `%s': %s\n", file,
strerror(rv));
free(filepath);
return rv;
}
}
free(filepath);
filepath = xbps_xasprintf("%s/%s", repodir, file); filepath = xbps_xasprintf("%s/%s", repodir, file);
if (remove(filepath) == -1) { if (remove(filepath) == -1) {
if (errno != ENOENT) { if (errno != ENOENT) {
@ -72,20 +59,17 @@ remove_pkg(const char *repodir, const char *arch, const char *file)
} }
static int static int
cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj, const char *key, void *arg, bool *done) cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj, const char *key _unused, void *arg, bool *done _unused)
{ {
xbps_dictionary_t pkgd; xbps_dictionary_t pkgd;
struct xbps_repo *repo = arg; struct xbps_repo *repo = arg;
const char *binpkg, *pkgver, *arch; const char *binpkg, *pkgver, *arch;
int rv; int rv;
(void)key;
(void)done;
binpkg = xbps_string_cstring_nocopy(obj); binpkg = xbps_string_cstring_nocopy(obj);
pkgd = xbps_get_pkg_plist_from_binpkg(binpkg, "./props.plist"); pkgd = xbps_get_pkg_plist_from_binpkg(binpkg, "./props.plist");
if (pkgd == NULL) { if (pkgd == NULL) {
rv = remove_pkg(repo->uri, arch, binpkg); rv = remove_pkg(repo->uri, binpkg);
if (rv != 0) { if (rv != 0) {
xbps_object_release(pkgd); xbps_object_release(pkgd);
return 0; return 0;
@ -104,7 +88,7 @@ cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj, const char *key, void *ar
* If binpkg is not registered in index, remove binpkg. * If binpkg is not registered in index, remove binpkg.
*/ */
if (!xbps_repo_get_pkg(repo, pkgver)) { if (!xbps_repo_get_pkg(repo, pkgver)) {
rv = remove_pkg(repo->uri, arch, binpkg); rv = remove_pkg(repo->uri, binpkg);
if (rv != 0) { if (rv != 0) {
xbps_object_release(pkgd); xbps_object_release(pkgd);
return 0; return 0;

2
configure vendored
View File

@ -190,6 +190,8 @@ echo "CPPFLAGS = -I. -I\$(TOPDIR) -I\$(TOPDIR)/include" >>$CONFIG_MK
echo "CPPFLAGS += -DHAVE_CONFIG_H" >>$CONFIG_MK echo "CPPFLAGS += -DHAVE_CONFIG_H" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_SYSCONF_PATH=\\\"${ETCDIR}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK
echo "CPPFLAGS += -D_unused=\"__attribute__((__unused__))\"" >>$CONFIG_MK
if [ -d .git ]; then if [ -d .git ]; then
_gitrev=$(git rev-parse master) _gitrev=$(git rev-parse master)
echo "CPPFLAGS += -DXBPS_GIT=\\\"${_gitrev}\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_GIT=\\\"${_gitrev}\\\"" >>$CONFIG_MK

View File

@ -60,7 +60,7 @@
*/ */
xbps_array_t xbps_array_t
xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user) xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user _unused)
{ {
xbps_array_t rdeps, reqby, array = NULL; xbps_array_t rdeps, reqby, array = NULL;
xbps_dictionary_t pkgd, deppkgd; xbps_dictionary_t pkgd, deppkgd;
@ -70,8 +70,6 @@ xbps_find_pkg_orphans(struct xbps_handle *xhp, xbps_array_t orphans_user)
bool automatic = false; bool automatic = false;
unsigned int i, x, j, cnt, reqbycnt; unsigned int i, x, j, cnt, reqbycnt;
(void)orphans_user;
if (xbps_pkgdb_init(xhp) != 0) if (xbps_pkgdb_init(xhp) != 0)
return NULL; return NULL;
if ((array = xbps_array_create()) == NULL) if ((array = xbps_array_create()) == NULL)

View File

@ -46,12 +46,10 @@ struct fetch_archive {
}; };
static int static int
fetch_archive_open(struct archive *a, void *client_data) fetch_archive_open(struct archive *a _unused, void *client_data)
{ {
struct fetch_archive *f = client_data; struct fetch_archive *f = client_data;
(void)a;
f->fetch = fetchGet(f->url, NULL); f->fetch = fetchGet(f->url, NULL);
if (f->fetch == NULL) if (f->fetch == NULL)
return ENOENT; return ENOENT;
@ -60,23 +58,20 @@ fetch_archive_open(struct archive *a, void *client_data)
} }
static ssize_t static ssize_t
fetch_archive_read(struct archive *a, void *client_data, const void **buf) fetch_archive_read(struct archive *a _unused, void *client_data, const void **buf)
{ {
struct fetch_archive *f = client_data; struct fetch_archive *f = client_data;
(void)a;
*buf = f->buffer; *buf = f->buffer;
return fetchIO_read(f->fetch, f->buffer, sizeof(f->buffer)); return fetchIO_read(f->fetch, f->buffer, sizeof(f->buffer));
} }
static int static int
fetch_archive_close(struct archive *a, void *client_data) fetch_archive_close(struct archive *a _unused, void *client_data)
{ {
struct fetch_archive *f = client_data; struct fetch_archive *f = client_data;
(void)a;
if (f->fetch != NULL) if (f->fetch != NULL)
fetchIO_close(f->fetch); fetchIO_close(f->fetch);
free(f); free(f);

View File

@ -75,15 +75,13 @@ find_pkg_cb(struct xbps_repo *repo, void *arg, bool *done)
} }
static int static int
find_pkg_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done) find_pkg_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done _unused)
{ {
struct rpool_fpkg *rpf = arg; struct rpool_fpkg *rpf = arg;
xbps_array_t revdeps = NULL; xbps_array_t revdeps = NULL;
const char *pkgver; const char *pkgver;
unsigned int i; unsigned int i;
(void)done;
revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern); revdeps = xbps_repo_get_pkg_revdeps(repo, rpf->pattern);
if (xbps_array_count(revdeps)) { if (xbps_array_count(revdeps)) {
/* found */ /* found */
@ -99,14 +97,12 @@ find_pkg_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done)
} }
static int static int
find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done) find_best_pkg_cb(struct xbps_repo *repo, void *arg, bool *done _unused)
{ {
struct rpool_fpkg *rpf = arg; struct rpool_fpkg *rpf = arg;
xbps_dictionary_t pkgd; xbps_dictionary_t pkgd;
const char *repopkgver; const char *repopkgver;
(void)done;
pkgd = xbps_repo_get_pkg(repo, rpf->pattern); pkgd = xbps_repo_get_pkg(repo, rpf->pattern);
if (pkgd == NULL) { if (pkgd == NULL) {
if (errno && errno != ENOENT) if (errno && errno != ENOENT)