xbps_xasprintf: do not return NULL anymore; remove checks for this.
This commit is contained in:
@@ -124,10 +124,6 @@ xbps_fetch_file(struct xbps_handle *xhp,
|
||||
* Compute destination file path.
|
||||
*/
|
||||
destfile = xbps_xasprintf("%s/%s", outputdir, filename);
|
||||
if (destfile == NULL) {
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Check if we have to resume a transfer.
|
||||
*/
|
||||
|
||||
@@ -145,7 +145,6 @@ xbps_init(struct xbps_handle *xhp)
|
||||
|
||||
buf = xbps_xasprintf("repositories = { %s }",
|
||||
xhp->repository);
|
||||
assert(buf);
|
||||
if ((rv = cfg_parse_buf(xhp->cfg, buf)) != 0)
|
||||
return rv;
|
||||
free(buf);
|
||||
|
||||
@@ -105,11 +105,6 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
|
||||
prop_dictionary_get_cstring_nocopy(obj2,
|
||||
"file", &cffile);
|
||||
buf = xbps_xasprintf(".%s", cffile);
|
||||
if (buf == NULL) {
|
||||
prop_object_iterator_release(iter2);
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
if (strcmp(entry_pname, buf) == 0) {
|
||||
prop_dictionary_get_cstring(obj2, "sha256",
|
||||
&sha256_orig);
|
||||
@@ -138,10 +133,6 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "file", &cffile);
|
||||
buf = xbps_xasprintf(".%s", cffile);
|
||||
if (buf == NULL) {
|
||||
prop_object_iterator_release(iter);
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(entry_pname, buf)) {
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
@@ -232,10 +223,6 @@ xbps_entry_install_conf_file(struct xbps_handle *xhp,
|
||||
(strcmp(sha256_orig, sha256_new))) {
|
||||
buf = xbps_xasprintf(".%s.new-%s",
|
||||
cffile, version);
|
||||
if (buf == NULL) {
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIG_FILE,
|
||||
0, pkgname, version,
|
||||
"Installing new configuration file to "
|
||||
|
||||
@@ -113,9 +113,6 @@ xbps_configure_pkg(struct xbps_handle *xhp,
|
||||
|
||||
buf = xbps_xasprintf("%s/metadata/%s/INSTALL",
|
||||
XBPS_META_PATH, pkgname);
|
||||
if (buf == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
if (chdir(xhp->rootdir) == -1) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_CONFIGURE_FAIL,
|
||||
errno, pkgname, version,
|
||||
|
||||
@@ -57,7 +57,6 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
"pkgver", &pkgver);
|
||||
buf = xbps_xasprintf("%s conflicts with "
|
||||
"installed pkg %s", repopkgver, pkgver);
|
||||
assert(buf != NULL);
|
||||
prop_array_add_cstring(trans_cflicts, buf);
|
||||
free(buf);
|
||||
continue;
|
||||
@@ -72,7 +71,6 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
"pkgver", &pkgver);
|
||||
buf = xbps_xasprintf("%s conflicts with "
|
||||
"%s in transaction", repopkgver, pkgver);
|
||||
assert(buf != NULL);
|
||||
prop_array_add_cstring(trans_cflicts, buf);
|
||||
free(buf);
|
||||
continue;
|
||||
|
||||
@@ -88,9 +88,6 @@ remove_pkg_metadata(struct xbps_handle *xhp,
|
||||
|
||||
metadir = xbps_xasprintf("%s/%s/metadata/%s", xhp->rootdir,
|
||||
XBPS_META_PATH, pkgname);
|
||||
if (metadir == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
dirp = opendir(metadir);
|
||||
if (dirp == NULL) {
|
||||
free(metadir);
|
||||
@@ -103,12 +100,6 @@ remove_pkg_metadata(struct xbps_handle *xhp,
|
||||
continue;
|
||||
|
||||
path = xbps_xasprintf("%s/%s", metadir, dp->d_name);
|
||||
if (path == NULL) {
|
||||
(void)closedir(dirp);
|
||||
free(metadir);
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
if (unlink(path) == -1) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_PURGE_FAIL,
|
||||
errno, pkgname, version,
|
||||
@@ -168,10 +159,6 @@ xbps_remove_pkg_files(struct xbps_handle *xhp,
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "file", &file);
|
||||
path = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||
if (path == NULL) {
|
||||
rv = ENOMEM;
|
||||
break;
|
||||
}
|
||||
|
||||
if ((strcmp(key, "files") == 0) ||
|
||||
(strcmp(key, "conf_files") == 0)) {
|
||||
@@ -282,16 +269,8 @@ xbps_remove_pkg(struct xbps_handle *xhp,
|
||||
|
||||
buf = xbps_xasprintf("%s/metadata/%s/REMOVE",
|
||||
XBPS_META_PATH, pkgname);
|
||||
if (buf == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
pkgver = xbps_xasprintf("%s-%s", pkgname, version);
|
||||
if (pkgver == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((rv = xbps_pkg_state_installed(xhp, pkgname, &state)) != 0)
|
||||
goto out;
|
||||
|
||||
@@ -71,7 +71,6 @@ again:
|
||||
|
||||
file = xbps_xasprintf(".%s",
|
||||
prop_string_cstring_nocopy(oldstr));
|
||||
assert(file);
|
||||
|
||||
if ((strcmp(array_str, "files") == 0) ||
|
||||
(strcmp(array_str, "conf_files") == 0)) {
|
||||
|
||||
@@ -71,10 +71,6 @@ extract_metafile(struct xbps_handle *xhp,
|
||||
}
|
||||
buf = xbps_xasprintf("%s/metadata/%s/%s",
|
||||
XBPS_META_PATH, pkgname, file);
|
||||
if (buf == NULL) {
|
||||
free(pkgname);
|
||||
return ENOMEM;
|
||||
}
|
||||
archive_entry_set_pathname(entry, buf);
|
||||
dirc = strdup(buf);
|
||||
if (dirc == NULL) {
|
||||
@@ -133,10 +129,6 @@ remove_metafile(struct xbps_handle *xhp,
|
||||
}
|
||||
buf = xbps_xasprintf("%s/metadata/%s/%s",
|
||||
XBPS_META_PATH, pkgname, file);
|
||||
if (buf == NULL) {
|
||||
free(pkgname);
|
||||
return ENOMEM;
|
||||
}
|
||||
if (unlink(buf) == -1) {
|
||||
if (errno && errno != ENOENT) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
@@ -291,10 +283,6 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
*/
|
||||
buf = xbps_xasprintf("%s/metadata/%s/INSTALL",
|
||||
XBPS_META_PATH, pkgname);
|
||||
if (buf == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
rv = extract_metafile(xhp, ar, entry,
|
||||
"INSTALL", pkgver, true, flags);
|
||||
if (rv != 0)
|
||||
@@ -470,7 +458,6 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
assert(buf2);
|
||||
dname = dirname(buf2);
|
||||
p2 = xbps_xasprintf("%s/%s", dname, tgtlnk);
|
||||
assert(p2);
|
||||
free(buf2);
|
||||
} else {
|
||||
p2 = strdup(tgtlnk);
|
||||
@@ -539,7 +526,6 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
* file but renaming it to <file>.old.
|
||||
*/
|
||||
buf = xbps_xasprintf("%s.old", entry_pname);
|
||||
assert(buf);
|
||||
(void)rename(entry_pname, buf);
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
@@ -593,10 +579,6 @@ unpack_archive(struct xbps_handle *xhp,
|
||||
*/
|
||||
pkgfilesd = xbps_xasprintf("%s/metadata/%s/%s",
|
||||
XBPS_META_PATH, pkgname, XBPS_PKGFILES);
|
||||
if (pkgfilesd == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
if (skip_obsoletes || preserve || (!softreplace && !update))
|
||||
goto out1;
|
||||
/*
|
||||
@@ -631,10 +613,6 @@ out1:
|
||||
* Create pkg metadata directory if doesn't exist.
|
||||
*/
|
||||
buf = xbps_xasprintf("%s/metadata/%s", XBPS_META_PATH, pkgname);
|
||||
if (buf == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
if (access(buf, R_OK|X_OK) == -1) {
|
||||
if (xbps_mkpath(buf, 0755) == -1) {
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
@@ -661,10 +639,6 @@ out1:
|
||||
}
|
||||
pkgpropsd = xbps_xasprintf("%s/metadata/%s/%s",
|
||||
XBPS_META_PATH, pkgname, XBPS_PKGPROPS);
|
||||
if (pkgpropsd == NULL) {
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
if (!prop_dictionary_externalize_to_file(propsd, pkgpropsd)) {
|
||||
rv = errno;
|
||||
xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL,
|
||||
|
||||
@@ -88,8 +88,6 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
|
||||
return cached_rv;
|
||||
|
||||
plist = xbps_xasprintf("%s/%s", xhp->metadir, XBPS_PKGDB);
|
||||
assert(plist);
|
||||
|
||||
if (xhp->pkgdb && flush) {
|
||||
pkgdb_storage = prop_array_internalize_from_zfile(plist);
|
||||
if (pkgdb_storage == NULL ||
|
||||
|
||||
@@ -280,8 +280,6 @@ xbps_dictionary_from_metadata_plist(struct xbps_handle *xhp,
|
||||
savedpkgname = pkgname;
|
||||
plistf = xbps_xasprintf("%s/metadata/%s/%s", xhp->metadir,
|
||||
savedpkgname, plist);
|
||||
if (plistf == NULL)
|
||||
return NULL;
|
||||
|
||||
if (access(plistf, R_OK) == -1) {
|
||||
pkgd = xbps_find_virtualpkg_dict_installed(xhp, pkgname, false);
|
||||
@@ -294,8 +292,6 @@ xbps_dictionary_from_metadata_plist(struct xbps_handle *xhp,
|
||||
"pkgname", &savedpkgname);
|
||||
plistf = xbps_xasprintf("%s/metadata/%s/%s",
|
||||
xhp->metadir, savedpkgname, plist);
|
||||
if (plistf == NULL)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -195,7 +195,6 @@ find_virtualpkg_user_in_conf(struct xbps_handle *xhp,
|
||||
vpkgver = cfg_getnstr(sec, "targets", j);
|
||||
if (strchr(vpkgver, '_') == NULL) {
|
||||
tmp = xbps_xasprintf("%s_1", vpkgver);
|
||||
assert(tmp != NULL);
|
||||
vpkgname = xbps_pkg_name(tmp);
|
||||
free(tmp);
|
||||
} else {
|
||||
|
||||
@@ -71,7 +71,6 @@ xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
|
||||
prop_array_get_cstring_nocopy(provides, i, &vpkgver);
|
||||
if (strchr(vpkgver, '_') == NULL) {
|
||||
tmp = xbps_xasprintf("%s_1", vpkgver);
|
||||
assert(tmp != NULL);
|
||||
vpkgver = tmp;
|
||||
}
|
||||
for (x = 0; x < prop_array_count(rundeps); x++) {
|
||||
@@ -117,7 +116,6 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
|
||||
pkgdep = prop_string_cstring_nocopy(obj);
|
||||
if (strchr(pkgdep, '_') == NULL) {
|
||||
tmp = xbps_xasprintf("%s_1", pkgdep);
|
||||
assert(tmp != NULL);
|
||||
curpkgname = xbps_pkg_name(tmp);
|
||||
free(tmp);
|
||||
} else {
|
||||
@@ -136,7 +134,6 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
|
||||
pkgdep = prop_string_cstring_nocopy(obj);
|
||||
if (strchr(pkgdep, '_') == NULL) {
|
||||
tmp = xbps_xasprintf("%s_1", pkgdep);
|
||||
assert(tmp != NULL);
|
||||
pkgdep = tmp;
|
||||
}
|
||||
if (xbps_pkgpattern_match(pkgdep, str)) {
|
||||
@@ -153,7 +150,6 @@ match_string_in_array(prop_array_t array, const char *str, int mode)
|
||||
pkgdep = prop_string_cstring_nocopy(obj);
|
||||
if (strchr(pkgdep, '_') == NULL) {
|
||||
tmp = xbps_xasprintf("%s_1", pkgdep);
|
||||
assert(tmp != NULL);
|
||||
pkgdep = tmp;
|
||||
}
|
||||
if (xbps_pkgpattern_match(str, pkgdep)) {
|
||||
|
||||
@@ -70,9 +70,6 @@ xbps_get_remote_repo_string(const char *uri)
|
||||
url->host, url->doc);
|
||||
|
||||
fetchFreeURL(url);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < strlen(p); i++) {
|
||||
if (p[i] == '.' || p[i] == '/' || p[i] == ':')
|
||||
p[i] = '_';
|
||||
@@ -128,28 +125,16 @@ xbps_repository_sync_pkg_index(struct xbps_handle *xhp,
|
||||
* Remote repository plist index full URL.
|
||||
*/
|
||||
rpidx = xbps_xasprintf("%s/%s", uri, plistf);
|
||||
if (rpidx == NULL) {
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Save temporary file in metadir, and rename if it
|
||||
* was downloaded successfully.
|
||||
*/
|
||||
tmp_metafile = xbps_xasprintf("%s/%s", xhp->metadir, plistf);
|
||||
if (tmp_metafile == NULL) {
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Full path to repository directory to store the plist
|
||||
* index file.
|
||||
*/
|
||||
lrepodir = xbps_xasprintf("%s/%s", xhp->metadir, uri_fixedp);
|
||||
if (lrepodir == NULL) {
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* If directory exists probably the plist index file
|
||||
* was downloaded previously...
|
||||
@@ -195,10 +180,6 @@ xbps_repository_sync_pkg_index(struct xbps_handle *xhp,
|
||||
prop_object_release(array);
|
||||
|
||||
lrepofile = xbps_xasprintf("%s/%s", lrepodir, plistf);
|
||||
if (lrepofile == NULL) {
|
||||
rv = -1;
|
||||
goto out;
|
||||
}
|
||||
/*
|
||||
* Create local repodir to store plist index file.
|
||||
*/
|
||||
|
||||
@@ -163,14 +163,12 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||
buf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
||||
xhp->rootdir, XBPS_META_PATH, curpkgname,
|
||||
XBPS_PKGFILES);
|
||||
assert(buf != NULL);
|
||||
filesd = prop_dictionary_internalize_from_zfile(buf);
|
||||
free(buf);
|
||||
assert(filesd != NULL);
|
||||
buf = xbps_xasprintf("%s/%s/metadata/%s/%s",
|
||||
xhp->rootdir, XBPS_META_PATH, pkgname,
|
||||
XBPS_PKGFILES);
|
||||
assert(buf != NULL);
|
||||
dirc = strdup(buf);
|
||||
assert(dirc != NULL);
|
||||
dname = dirname(dirc);
|
||||
|
||||
@@ -346,7 +346,6 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
j, &vpkgdep);
|
||||
if (strchr(vpkgdep, '_') == NULL) {
|
||||
vpkg = xbps_xasprintf("%s_1", vpkgdep);
|
||||
assert(vpkg);
|
||||
vpkgname = xbps_pkg_name(vpkg);
|
||||
free(vpkg);
|
||||
} else {
|
||||
|
||||
@@ -245,9 +245,6 @@ xbps_path_from_repository_uri(struct xbps_handle *xhp,
|
||||
* First check if binpkg is available in cachedir.
|
||||
*/
|
||||
lbinpkg = xbps_xasprintf("%s/%s", xhp->cachedir, filen);
|
||||
if (lbinpkg == NULL)
|
||||
return NULL;
|
||||
|
||||
if (access(lbinpkg, R_OK) == 0)
|
||||
return lbinpkg;
|
||||
|
||||
@@ -294,14 +291,15 @@ char *
|
||||
xbps_xasprintf(const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char *buf;
|
||||
char *buf = NULL;
|
||||
|
||||
va_start(ap, fmt);
|
||||
if (vasprintf(&buf, fmt, ap) == -1) {
|
||||
va_end(ap);
|
||||
return NULL;
|
||||
assert(buf);
|
||||
}
|
||||
va_end(ap);
|
||||
assert(buf);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -196,7 +196,6 @@ xbps_file_hash_check_dictionary(struct xbps_handle *xhp,
|
||||
rv = xbps_file_hash_check(file, sha256d);
|
||||
} else {
|
||||
buf = xbps_xasprintf("%s/%s", xhp->rootdir, file);
|
||||
assert(buf != NULL);
|
||||
rv = xbps_file_hash_check(buf, sha256d);
|
||||
free(buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user