libfdisk: cleanup assert() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
e97c021472
commit
1c3c92cd8d
|
@ -1065,8 +1065,6 @@ int fdisk_missing_geometry(struct fdisk_context *cxt)
|
|||
{
|
||||
int rc;
|
||||
|
||||
assert(cxt);
|
||||
|
||||
if (!cxt || !cxt->label)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -121,12 +121,10 @@ int fdisk_label_get_fields_ids(
|
|||
size_t i, n;
|
||||
int *c;
|
||||
|
||||
assert(cxt);
|
||||
|
||||
if (!lb)
|
||||
lb = cxt->label;
|
||||
if (!lb)
|
||||
if (!cxt || (!lb && !cxt->label))
|
||||
return -EINVAL;
|
||||
|
||||
lb = cxt->label;
|
||||
if (!lb->fields || !lb->nfields)
|
||||
return -ENOSYS;
|
||||
c = calloc(lb->nfields, sizeof(int));
|
||||
|
@ -175,12 +173,10 @@ int fdisk_label_get_fields_ids_all(
|
|||
size_t i, n;
|
||||
int *c;
|
||||
|
||||
assert(cxt);
|
||||
|
||||
if (!lb)
|
||||
lb = cxt->label;
|
||||
if (!lb)
|
||||
if (!cxt || (!lb && !cxt->label))
|
||||
return -EINVAL;
|
||||
|
||||
lb = cxt->label;
|
||||
if (!lb->fields || !lb->nfields)
|
||||
return -ENOSYS;
|
||||
c = calloc(lb->nfields, sizeof(int));
|
||||
|
|
|
@ -695,8 +695,8 @@ int fdisk_partition_next_partno(
|
|||
struct fdisk_context *cxt,
|
||||
size_t *n)
|
||||
{
|
||||
assert(cxt);
|
||||
assert(n);
|
||||
if (!cxt || !n)
|
||||
return -EINVAL;
|
||||
|
||||
if (pa && pa->partno_follow_default) {
|
||||
size_t i;
|
||||
|
@ -1171,9 +1171,6 @@ int fdisk_add_partition(struct fdisk_context *cxt,
|
|||
{
|
||||
int rc;
|
||||
|
||||
assert(cxt);
|
||||
assert(cxt->label);
|
||||
|
||||
if (!cxt || !cxt->label)
|
||||
return -EINVAL;
|
||||
if (!cxt->label->op->add_part)
|
||||
|
|
|
@ -264,13 +264,9 @@ int fdisk_script_set_header(struct fdisk_script *dp,
|
|||
{
|
||||
struct fdisk_scriptheader *fi;
|
||||
|
||||
assert(dp);
|
||||
assert(name);
|
||||
|
||||
if (!dp || !name)
|
||||
return -EINVAL;
|
||||
|
||||
|
||||
fi = script_get_header(dp, name);
|
||||
if (!fi && !data)
|
||||
return 0; /* want to remove header that does not exist, success */
|
||||
|
@ -373,14 +369,12 @@ int fdisk_script_read_context(struct fdisk_script *dp, struct fdisk_context *cxt
|
|||
int rc;
|
||||
char *p = NULL;
|
||||
|
||||
assert(dp);
|
||||
if (!dp || (!cxt && !dp->cxt))
|
||||
return -EINVAL;
|
||||
|
||||
if (!cxt)
|
||||
cxt = dp->cxt;
|
||||
|
||||
if (!dp || !cxt)
|
||||
return -EINVAL;
|
||||
|
||||
DBG(SCRIPT, ul_debugobj(dp, "reading context into script"));
|
||||
fdisk_reset_script(dp);
|
||||
|
||||
|
|
|
@ -140,10 +140,6 @@ int fdisk_table_next_partition(
|
|||
{
|
||||
int rc = 1;
|
||||
|
||||
assert(tb);
|
||||
assert(itr);
|
||||
assert(pa);
|
||||
|
||||
if (!tb || !itr || !pa)
|
||||
return -EINVAL;
|
||||
*pa = NULL;
|
||||
|
@ -226,9 +222,6 @@ struct fdisk_partition *fdisk_table_get_partition_by_partno(
|
|||
*/
|
||||
int fdisk_table_add_partition(struct fdisk_table *tb, struct fdisk_partition *pa)
|
||||
{
|
||||
assert(tb);
|
||||
assert(pa);
|
||||
|
||||
if (!tb || !pa)
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -288,9 +281,6 @@ static int table_insert_partition(
|
|||
*/
|
||||
int fdisk_table_remove_partition(struct fdisk_table *tb, struct fdisk_partition *pa)
|
||||
{
|
||||
assert(tb);
|
||||
assert(pa);
|
||||
|
||||
if (!tb || !pa)
|
||||
return -EINVAL;
|
||||
|
||||
|
|
Loading…
Reference in New Issue