xbps-*: do not pass a NULL pointer to xbps_end().
This commit is contained in:
parent
2857214afa
commit
4aa06921ff
@ -44,9 +44,11 @@ struct list_pkgver_cb {
|
||||
};
|
||||
|
||||
static void __attribute__((noreturn))
|
||||
usage(void)
|
||||
usage(struct xbps_handle *xhp)
|
||||
{
|
||||
xbps_end(xbps_handle_get());
|
||||
if (xhp != NULL)
|
||||
xbps_end(xhp);
|
||||
|
||||
fprintf(stderr,
|
||||
"Usage: xbps-bin [options] [target] [arguments]\n"
|
||||
"See xbps-bin(8) for more information.\n");
|
||||
@ -240,7 +242,7 @@ main(int argc, char **argv)
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
usage(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,7 +250,7 @@ main(int argc, char **argv)
|
||||
argv += optind;
|
||||
|
||||
if (argc < 1)
|
||||
usage();
|
||||
usage(NULL);
|
||||
|
||||
/* Specifying -A and -M is illegal */
|
||||
if (install_manual && install_auto) {
|
||||
@ -299,7 +301,7 @@ main(int argc, char **argv)
|
||||
if (strcasecmp(argv[0], "list") == 0) {
|
||||
/* Lists packages currently registered in database. */
|
||||
if (argc < 1 || argc > 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
if (xhp->regpkgdb_dictionary == NULL) {
|
||||
printf("No packages currently installed.\n");
|
||||
@ -336,7 +338,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "install") == 0) {
|
||||
/* Installs a binary package and required deps. */
|
||||
if (argc < 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if ((rv = install_new_pkg(argv[i])) != 0)
|
||||
@ -347,7 +349,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "update") == 0) {
|
||||
/* Update an installed package. */
|
||||
if (argc < 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
if ((rv = update_pkg(argv[i])) != 0)
|
||||
@ -358,7 +360,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "remove") == 0) {
|
||||
/* Removes a binary package. */
|
||||
if (argc < 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = remove_installed_pkgs(argc, argv, yes, purge,
|
||||
force_rm_with_deps, recursive_rm);
|
||||
@ -366,7 +368,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show") == 0) {
|
||||
/* Shows info about an installed binary package. */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = show_pkg_info_from_metadir(argv[1]);
|
||||
if (rv != 0) {
|
||||
@ -377,7 +379,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show-files") == 0) {
|
||||
/* Shows files installed by a binary package. */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = show_pkg_files_from_metadir(argv[1]);
|
||||
if (rv != 0) {
|
||||
@ -388,7 +390,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "check") == 0) {
|
||||
/* Checks the integrity of an installed package. */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
if (strcasecmp(argv[1], "all") == 0)
|
||||
rv = check_pkg_integrity_all();
|
||||
@ -400,7 +402,7 @@ main(int argc, char **argv)
|
||||
* To update all packages currently installed.
|
||||
*/
|
||||
if (argc != 1)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = autoupdate_pkgs(yes, show_download_pkglist_url);
|
||||
|
||||
@ -410,7 +412,7 @@ main(int argc, char **argv)
|
||||
* orphans.
|
||||
*/
|
||||
if (argc != 1)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = show_orphans();
|
||||
|
||||
@ -421,7 +423,7 @@ main(int argc, char **argv)
|
||||
* on it currently.
|
||||
*/
|
||||
if (argc != 1)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = autoremove_pkgs(yes, purge);
|
||||
|
||||
@ -430,7 +432,7 @@ main(int argc, char **argv)
|
||||
* Purge a package completely.
|
||||
*/
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
if (strcasecmp(argv[1], "all") == 0)
|
||||
rv = xbps_purge_packages();
|
||||
@ -442,7 +444,7 @@ main(int argc, char **argv)
|
||||
* Reconfigure a package.
|
||||
*/
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
if (strcasecmp(argv[1], "all") == 0)
|
||||
rv = xbps_configure_packages();
|
||||
@ -454,7 +456,7 @@ main(int argc, char **argv)
|
||||
* Show dependencies for a package.
|
||||
*/
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = show_pkg_deps(argv[1]);
|
||||
|
||||
@ -464,7 +466,7 @@ main(int argc, char **argv)
|
||||
* dependencies.
|
||||
*/
|
||||
if (argc != 1)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = xbps_callback_array_iter_in_dict(xhp->regpkgdb_dictionary,
|
||||
"packages", list_manual_packages, NULL);
|
||||
@ -474,7 +476,7 @@ main(int argc, char **argv)
|
||||
* Show reverse dependencies for a package.
|
||||
*/
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = show_pkg_reverse_deps(argv[1]);
|
||||
|
||||
@ -484,12 +486,12 @@ main(int argc, char **argv)
|
||||
* packages.
|
||||
*/
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = find_files_in_packages(argv[1]);
|
||||
|
||||
} else {
|
||||
usage();
|
||||
usage(xhp);
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -39,11 +39,11 @@
|
||||
#include "../xbps-bin/defs.h"
|
||||
|
||||
static void __attribute__((noreturn))
|
||||
usage(void)
|
||||
usage(struct xbps_handle *xhp)
|
||||
{
|
||||
struct xbps_handle *xhp = xbps_handle_get();
|
||||
|
||||
if (xhp != NULL)
|
||||
xbps_end(xhp);
|
||||
|
||||
fprintf(stderr,
|
||||
"Usage: xbps-repo [options] [action] [arguments]\n"
|
||||
"See xbps-repo(8) for more information.\n");
|
||||
@ -116,7 +116,7 @@ main(int argc, char **argv)
|
||||
exit(EXIT_SUCCESS);
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
usage(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ main(int argc, char **argv)
|
||||
argv += optind;
|
||||
|
||||
if (argc < 1)
|
||||
usage();
|
||||
usage(NULL);
|
||||
|
||||
/*
|
||||
* Initialize XBPS subsystems.
|
||||
@ -152,7 +152,7 @@ main(int argc, char **argv)
|
||||
if (strcasecmp(argv[0], "list") == 0) {
|
||||
/* Lists all repositories registered in pool. */
|
||||
if (argc != 1)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = xbps_repository_pool_foreach(repo_list_uri_cb, NULL);
|
||||
if (rv == ENOTSUP)
|
||||
@ -168,7 +168,7 @@ main(int argc, char **argv)
|
||||
* by using shell style match patterns (fnmatch(3)).
|
||||
*/
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = xbps_repository_pool_foreach(repo_search_pkgs_cb, argv[1]);
|
||||
if (rv == ENOTSUP)
|
||||
@ -181,7 +181,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show") == 0) {
|
||||
/* Shows info about a binary package. */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = show_pkg_info_from_repolist(argv[1]);
|
||||
if (rv == ENOENT) {
|
||||
@ -198,7 +198,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show-deps") == 0) {
|
||||
/* Shows the required run dependencies for a package. */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = show_pkg_deps_from_repolist(argv[1]);
|
||||
if (rv == ENOENT) {
|
||||
@ -215,7 +215,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "show-files") == 0) {
|
||||
/* Shows the package files in a binary package */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
pkgd = xbps_repository_pool_dictionary_metadata_plist(argv[1],
|
||||
XBPS_PKGFILES);
|
||||
@ -240,7 +240,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "find-files") == 0) {
|
||||
/* Finds files by patterns, exact matches and components. */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = repo_find_files_in_packages(argv[1]);
|
||||
if (rv == ENOTSUP) {
|
||||
@ -251,14 +251,14 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "genindex") == 0) {
|
||||
/* Generates a package repository index plist file. */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = repo_genindex(argv[1]);
|
||||
|
||||
} else if (strcasecmp(argv[0], "sync") == 0) {
|
||||
/* Syncs the pkg index for all registered remote repos */
|
||||
if (argc != 1)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
rv = repository_sync();
|
||||
if (rv == ENOTSUP) {
|
||||
@ -267,7 +267,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
} else {
|
||||
usage();
|
||||
usage(xhp);
|
||||
}
|
||||
|
||||
out:
|
||||
|
@ -58,9 +58,10 @@ write_plist_file(prop_dictionary_t dict, const char *file)
|
||||
}
|
||||
|
||||
static void __attribute__((noreturn))
|
||||
usage(void)
|
||||
usage(struct xbps_handle *xhp)
|
||||
{
|
||||
xbps_end(xbps_handle_get());
|
||||
if (xhp != NULL)
|
||||
xbps_end(xhp);
|
||||
|
||||
fprintf(stderr,
|
||||
"usage: xbps-uhelper [options] [action] [args]\n"
|
||||
@ -134,7 +135,7 @@ main(int argc, char **argv)
|
||||
exit(EXIT_SUCCESS);
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
usage(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -142,7 +143,7 @@ main(int argc, char **argv)
|
||||
argv += optind;
|
||||
|
||||
if (argc < 1)
|
||||
usage();
|
||||
usage(NULL);
|
||||
|
||||
/*
|
||||
* Initialize the callbacks and debug in libxbps.
|
||||
@ -178,7 +179,7 @@ main(int argc, char **argv)
|
||||
if (strcasecmp(argv[0], "register") == 0) {
|
||||
/* Registers a package into the database */
|
||||
if (argc != 4)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
dict = prop_dictionary_create();
|
||||
if (dict == NULL)
|
||||
@ -218,7 +219,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "unregister") == 0) {
|
||||
/* Unregisters a package from the database */
|
||||
if (argc != 3)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
if (!xbps_remove_pkg_dict_from_plist_by_name(argv[1], plist)) {
|
||||
if (errno == ENOENT)
|
||||
@ -239,7 +240,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "version") == 0) {
|
||||
/* Prints version of an installed package */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
dict = xbps_find_pkg_dict_from_plist_by_name(plist,
|
||||
"packages", argv[1]);
|
||||
@ -253,7 +254,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "sanitize-plist") == 0) {
|
||||
/* Sanitize a plist file (properly indent the file) */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
dict = prop_dictionary_internalize_from_zfile(argv[1]);
|
||||
if (dict == NULL) {
|
||||
@ -267,7 +268,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgversion") == 0) {
|
||||
/* Returns the version of a pkg string */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
version = xbps_pkg_version(argv[1]);
|
||||
if (version == NULL) {
|
||||
@ -280,7 +281,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgname") == 0) {
|
||||
/* Returns the name of a pkg string */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
pkgname = xbps_pkg_name(argv[1]);
|
||||
if (pkgname == NULL) {
|
||||
@ -294,7 +295,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgrevision") == 0) {
|
||||
/* Returns the revision of a pkg string */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
version = xbps_pkg_revision(argv[1]);
|
||||
if (version == NULL)
|
||||
@ -305,7 +306,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgdepname") == 0) {
|
||||
/* Returns the pkgname of a dependency */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
pkgname = xbps_pkgpattern_name(argv[1]);
|
||||
if (pkgname == NULL)
|
||||
@ -316,7 +317,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "getpkgdepversion") == 0) {
|
||||
/* returns the version of a package pattern dependency */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
version = xbps_pkgpattern_version(argv[1]);
|
||||
if (version == NULL)
|
||||
@ -327,21 +328,21 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "pkgmatch") == 0) {
|
||||
/* Matches a pkg with a pattern */
|
||||
if (argc != 3)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
exit(xbps_pkgpattern_match(argv[1], argv[2]));
|
||||
|
||||
} else if (strcasecmp(argv[0], "cmpver") == 0) {
|
||||
/* Compare two version strings, installed vs required */
|
||||
if (argc != 3)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
exit(xbps_cmpver(argv[1], argv[2]));
|
||||
|
||||
} else if (strcasecmp(argv[0], "digest") == 0) {
|
||||
/* Prints SHA256 hashes for specified files */
|
||||
if (argc < 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
hash = xbps_file_hash(argv[i]);
|
||||
@ -358,7 +359,7 @@ main(int argc, char **argv)
|
||||
} else if (strcasecmp(argv[0], "fetch") == 0) {
|
||||
/* Fetch a file from specified URL */
|
||||
if (argc != 2)
|
||||
usage();
|
||||
usage(xhp);
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
rv = xbps_fetch_file(argv[i], ".", false, "v");
|
||||
@ -373,7 +374,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
} else {
|
||||
usage();
|
||||
usage(xhp);
|
||||
}
|
||||
|
||||
xbps_end(xhp);
|
||||
|
Loading…
Reference in New Issue
Block a user