Negative data or parity args are invalid
While we're at it, tighten up some test_create_backend_invalid_args assertions. Change-Id: Id6c70cdb2d86580280ededc3ec6ec648c6cb7d57
This commit is contained in:
parent
dd31ac647b
commit
082e4799d8
|
@ -273,6 +273,8 @@ int liberasurecode_instance_create(const ec_backend_id_t id,
|
|||
if (id >= EC_BACKENDS_MAX)
|
||||
return -EBACKENDNOTSUPP;
|
||||
|
||||
if (args->k < 0 || args->m < 0)
|
||||
return -EINVALIDPARAMS;
|
||||
if ((args->k + args->m) > EC_MAX_FRAGMENTS) {
|
||||
log_error("Total number of fragments (k + m) must be less than %d\n",
|
||||
EC_MAX_FRAGMENTS);
|
||||
|
|
|
@ -518,32 +518,30 @@ static void test_backend_available_invalid_args()
|
|||
static void test_create_backend_invalid_args()
|
||||
{
|
||||
int desc = liberasurecode_instance_create(-1, &null_args);
|
||||
if (-EBACKENDNOTAVAIL == desc) {
|
||||
fprintf (stderr, "Backend library not available!\n");
|
||||
return;
|
||||
}
|
||||
assert(desc < 0);
|
||||
assert(-EBACKENDNOTSUPP == desc);
|
||||
|
||||
desc = liberasurecode_instance_create(EC_BACKENDS_MAX, &null_args);
|
||||
if (-EBACKENDNOTAVAIL == desc) {
|
||||
fprintf (stderr, "Backend library not available!\n");
|
||||
return;
|
||||
}
|
||||
assert(desc < 0);
|
||||
assert(-EBACKENDNOTSUPP == desc);
|
||||
|
||||
desc = liberasurecode_instance_create(EC_BACKEND_NULL, NULL);
|
||||
if (-EBACKENDNOTAVAIL == desc) {
|
||||
fprintf (stderr, "Backend library not available!\n");
|
||||
return;
|
||||
}
|
||||
assert(-EINVALIDPARAMS == desc);
|
||||
|
||||
struct ec_args invalid_args = {
|
||||
.k = 100,
|
||||
.m = 100,
|
||||
};
|
||||
desc = liberasurecode_instance_create(EC_BACKEND_NULL, &invalid_args);
|
||||
if (-EBACKENDNOTAVAIL == desc) {
|
||||
fprintf (stderr, "Backend library not available!\n");
|
||||
return;
|
||||
}
|
||||
assert(desc < 0);
|
||||
assert(-EINVALIDPARAMS == desc);
|
||||
|
||||
invalid_args.k = -1;
|
||||
invalid_args.m = 4;
|
||||
desc = liberasurecode_instance_create(EC_BACKEND_NULL, &invalid_args);
|
||||
assert(-EINVALIDPARAMS == desc);
|
||||
|
||||
invalid_args.k = 10;
|
||||
invalid_args.m = -1;
|
||||
desc = liberasurecode_instance_create(EC_BACKEND_NULL, &invalid_args);
|
||||
assert(-EINVALIDPARAMS == desc);
|
||||
}
|
||||
|
||||
static void test_destroy_backend_invalid_args()
|
||||
|
|
Loading…
Reference in New Issue