mirror of
https://github.com/void-linux/void-packages.git
synced 2025-09-01 09:32:57 +02:00
Add assertions where appropiate.
--HG-- extra : convert_revision : 3c7a6f556b1dfdf110f8759375a171a571717b22
This commit is contained in:
parent
613c9f25dd
commit
4f3c798f7a
3 changed files with 24 additions and 6 deletions
|
@ -271,6 +271,8 @@ xbps_unpack_binary_pkg(prop_dictionary_t repo, prop_dictionary_t pkg,
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
assert(pkg != NULL);
|
assert(pkg != NULL);
|
||||||
|
assert(repo != NULL);
|
||||||
|
assert(cb != NULL);
|
||||||
|
|
||||||
/* Append filename to the full path for binary pkg */
|
/* Append filename to the full path for binary pkg */
|
||||||
filename = prop_dictionary_get(pkg, "filename");
|
filename = prop_dictionary_get(pkg, "filename");
|
||||||
|
|
24
lib/plist.c
24
lib/plist.c
|
@ -42,7 +42,9 @@ bool
|
||||||
xbps_add_obj_to_dict(prop_dictionary_t dict, prop_object_t obj,
|
xbps_add_obj_to_dict(prop_dictionary_t dict, prop_object_t obj,
|
||||||
const char *key)
|
const char *key)
|
||||||
{
|
{
|
||||||
assert(dict != NULL || obj != NULL || key != NULL);
|
assert(dict != NULL);
|
||||||
|
assert(obj != NULL);
|
||||||
|
assert(key != NULL);
|
||||||
|
|
||||||
if (!prop_dictionary_set(dict, key, obj)) {
|
if (!prop_dictionary_set(dict, key, obj)) {
|
||||||
prop_object_release(dict);
|
prop_object_release(dict);
|
||||||
|
@ -56,7 +58,8 @@ xbps_add_obj_to_dict(prop_dictionary_t dict, prop_object_t obj,
|
||||||
bool
|
bool
|
||||||
xbps_add_obj_to_array(prop_array_t array, prop_object_t obj)
|
xbps_add_obj_to_array(prop_array_t array, prop_object_t obj)
|
||||||
{
|
{
|
||||||
assert(array != NULL || obj != NULL);
|
assert(array != NULL);
|
||||||
|
assert(obj != NULL);
|
||||||
|
|
||||||
if (!prop_array_add(array, obj)) {
|
if (!prop_array_add(array, obj)) {
|
||||||
prop_object_release(array);
|
prop_object_release(array);
|
||||||
|
@ -77,6 +80,10 @@ xbps_callback_array_iter_in_dict(prop_dictionary_t dict, const char *key,
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
bool run, cbloop_done;
|
bool run, cbloop_done;
|
||||||
|
|
||||||
|
assert(dict != NULL);
|
||||||
|
assert(key != NULL);
|
||||||
|
assert(func != NULL);
|
||||||
|
|
||||||
run = cbloop_done = false;
|
run = cbloop_done = false;
|
||||||
assert(func != NULL);
|
assert(func != NULL);
|
||||||
|
|
||||||
|
@ -129,6 +136,7 @@ xbps_find_pkg_in_dict(prop_dictionary_t dict, const char *pkgname)
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
const char *dpkgn;
|
const char *dpkgn;
|
||||||
|
|
||||||
|
assert(dict != NULL);
|
||||||
assert(pkgname != NULL);
|
assert(pkgname != NULL);
|
||||||
|
|
||||||
iter = xbps_get_array_iter_from_dict(dict, "packages");
|
iter = xbps_get_array_iter_from_dict(dict, "packages");
|
||||||
|
@ -151,7 +159,8 @@ xbps_find_string_in_array(prop_array_t array, const char *val)
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
|
|
||||||
assert(array != NULL || val != NULL);
|
assert(array != NULL);
|
||||||
|
assert(val != NULL);
|
||||||
|
|
||||||
iter = prop_array_iterator(array);
|
iter = prop_array_iterator(array);
|
||||||
if (iter == NULL)
|
if (iter == NULL)
|
||||||
|
@ -175,7 +184,8 @@ xbps_get_array_iter_from_dict(prop_dictionary_t dict, const char *key)
|
||||||
{
|
{
|
||||||
prop_array_t array;
|
prop_array_t array;
|
||||||
|
|
||||||
assert(dict != NULL || key != NULL);
|
assert(dict != NULL);
|
||||||
|
assert(key != NULL);
|
||||||
|
|
||||||
array = prop_dictionary_get(dict, key);
|
array = prop_dictionary_get(dict, key);
|
||||||
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY)
|
if (array == NULL || prop_object_type(array) != PROP_TYPE_ARRAY)
|
||||||
|
@ -194,6 +204,9 @@ xbps_remove_pkg_dict_from_file(const char *pkg, const char *plist)
|
||||||
const char *curpkg;
|
const char *curpkg;
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
|
||||||
|
assert(pkg != NULL);
|
||||||
|
assert(plist != NULL);
|
||||||
|
|
||||||
pdict = prop_dictionary_internalize_from_file(plist);
|
pdict = prop_dictionary_internalize_from_file(plist);
|
||||||
if (pdict == NULL)
|
if (pdict == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
@ -399,8 +412,7 @@ xbps_show_pkg_info(prop_dictionary_t dict)
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
assert(dict != NULL);
|
assert(dict != NULL);
|
||||||
if (prop_dictionary_count(dict) == 0)
|
assert(prop_dictionary_count(dict) != 0);
|
||||||
return;
|
|
||||||
|
|
||||||
obj = prop_dictionary_get(dict, "pkgname");
|
obj = prop_dictionary_get(dict, "pkgname");
|
||||||
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
if (obj && prop_object_type(obj) == PROP_TYPE_STRING)
|
||||||
|
|
|
@ -37,6 +37,8 @@ xbps_get_pkg_version(const char *pkg)
|
||||||
{
|
{
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
|
|
||||||
|
assert(pkg != NULL);
|
||||||
|
|
||||||
/* Get the required version */
|
/* Get the required version */
|
||||||
tmp = strrchr(pkg, '-');
|
tmp = strrchr(pkg, '-');
|
||||||
assert(tmp != NULL);
|
assert(tmp != NULL);
|
||||||
|
@ -50,6 +52,8 @@ xbps_get_pkg_name(const char *pkg)
|
||||||
char *pkgname;
|
char *pkgname;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
|
||||||
|
assert(pkg != NULL);
|
||||||
|
|
||||||
/* Get the required version */
|
/* Get the required version */
|
||||||
tmp = strrchr(pkg, '-');
|
tmp = strrchr(pkg, '-');
|
||||||
assert(tmp != NULL);
|
assert(tmp != NULL);
|
||||||
|
|
Loading…
Add table
Reference in a new issue