GHashTableIter iter;
void *data;
- if (!table || !cb)
+ if (!table || !cb) {
+ printf("Invalid parameter\n");
return;
+ }
g_hash_table_iter_init(&iter, table);
while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &data))
{
hash_hal_key key;
- if (!hal_table || !hal)
+ if (!hal_table || !hal) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
key = HASH_HAL_KEY_RAW(hal, HALCC_HASH_COMPARE_TYPE_EXACT_MINOR_VERSION);
- if (g_hash_table_lookup_extended(hal_table, &key, NULL, NULL))
+ if (g_hash_table_lookup_extended(hal_table, &key, NULL, NULL)) {
+ printf("Failed to insert hal, duplicate key: hal-name=%s", key.hal.name);
return -EALREADY;
+ }
g_hash_table_insert(hal_table, hal, hal);
{
hash_hal_key key;
- if (!hal_table || !name)
+ if (!hal_table || !name) {
+ printf("Invalid parameter\n");
return NULL;
+ }
key = HASH_HAL_KEY(name, major, minor, type);
hash_hal_key key;
halcc_hal *hal = NULL;
- if (!hal_table || !name)
+ if (!hal_table || !name) {
+ printf("Invalid parameter\n");
return NULL;
+ }
key = HASH_HAL_KEY(name, major, minor, HALCC_HASH_COMPARE_TYPE_EXACT_MINOR_VERSION);
{
hash_hal_key key;
- if (!hal_table || !name)
+ if (!hal_table || !name) {
+ printf("Invalid parameter\n");
return;
+ }
key = HASH_HAL_KEY(name, major, minor, HALCC_HASH_COMPARE_TYPE_EXACT_MINOR_VERSION);
{
halcc_interface key;
- if (!interface_table || !name)
+ if (!interface_table || !name) {
+ printf("Invalid parameter\n");
return NULL;
+ }
key = (halcc_interface) {
.name = (char *) name,
{
halcc_interface key;
- if (!interface_table || !name)
+ if (!interface_table || !name) {
+ printf("Invalid parameter\n");
return;
+ }
key = (halcc_interface) {
.name = (char *) name,
{
halcc_manifest *m;
- if (!manifest)
+ if (!manifest) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
m = calloc(1, sizeof(halcc_manifest));
- if (!m)
+ if (!m) {
+ printf("Failed to allocate halcc_manifest\n");
return -ENOMEM;
+ }
*m = (halcc_manifest) {
.manifest_type = HALCC_UNINITIALIZED_INT,
void halcc_manifest_free(halcc_manifest *manifest)
{
- if (!manifest)
+ if (!manifest) {
+ printf("Invalid parameter\n");
return;
+ }
g_hash_table_destroy(g_steal_pointer(&manifest->hals));
int halcc_manifest_set_type(halcc_manifest *manifest, halcc_manifest_type_e type)
{
- if (!manifest)
+ if (!manifest) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
- if (type < HALCC_MANIFEST_TYPE_HAL_API || type > HALCC_MANIFEST_TYPE_HAL_BACKEND)
+ if (type < HALCC_MANIFEST_TYPE_HAL_API || type > HALCC_MANIFEST_TYPE_HAL_BACKEND) {
+ printf("Invalid parameter of type=%d\n", type);
return -EINVAL;
+ }
return halcc_util_set_int_once(&manifest->manifest_type, type, "manifest.type");
int halcc_manifest_get_type(halcc_manifest *manifest, halcc_manifest_type_e *type)
{
- if (!manifest || !type)
+ if (!manifest || !type) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
*type = manifest->manifest_type;
{
int ret;
- if (!manifest)
+ if (!manifest) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
- if (major < 0 || minor < 0)
+ if (major < 0 || minor < 0) {
+ printf("Invalid parameter of version, major=%d, minor=%d\n", major, minor);
return -EINVAL;
+ }
ret = halcc_util_set_int_once(&manifest->version.major, major, "manifest.version.major");
- if (ret != 0)
+ if (ret != 0) {
+ printf("Failed to set major version=%d\n", major);
return ret;
+ }
ret = halcc_util_set_int_once(&manifest->version.minor, minor, "manifest.version.minor");
- if (ret != 0)
+ if (ret != 0) {
+ printf("Failed to set minor version=%d\n", minor);
return ret;
+ }
return 0;
}
int halcc_manifest_get_version(halcc_manifest *manifest, int *major, int *minor)
{
- if (!manifest || !major || !minor)
+ if (!manifest || !major || !minor) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
*major = manifest->version.major;
*minor = manifest->version.minor;
int halcc_manifest_set_level(halcc_manifest *manifest, int level)
{
- if (!manifest)
+ if (!manifest) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
return halcc_util_set_int_once(&manifest->level, level, "manifest.level");
}
int halcc_manifest_get_level(halcc_manifest *manifest, int *level)
{
- if (!manifest || !level)
+ if (!manifest || !level) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
*level = manifest->level;
int halcc_manifest_add_hal(halcc_manifest *manifest, halcc_hal *hal)
{
- if (!manifest || !hal)
+ if (!manifest || !hal) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
assert(manifest->hals);
- if (!hal->name)
+ if (!hal->name) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
return hashtable_hal_insert(manifest->hals, hal);
}
{
halcc_hal *h;
- if (!manifest || !hal_name)
+ if (!manifest || !hal_name) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
h = hashtable_hal_lookup(manifest->hals,
hal_name, major, minor, HALCC_HASH_COMPARE_TYPE_EXACT_MINOR_VERSION);
- if (!h)
+ if (!h) {
+ printf("Failed to find hal=%s@%d.%d\n", hal_name, major, minor);
return -ENOTSUP;
+ }
if (hal)
*hal = g_steal_pointer(&h);
{
halcc_hal *h;
- if (!manifest || !hal_name)
+ if (!manifest || !hal_name) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
h = hashtable_hal_lookup(manifest->hals,
hal_name, major, minor, HALCC_HASH_COMPARE_TYPE_BACKWARD_MINOR_VERSION);
- if (!h)
+ if (!h) {
+ printf("Failed to find backward compatible to hal=%s@%d.%d\n", hal_name, major, minor);
return -ENOTSUP;
+ }
if (hal)
*hal = g_steal_pointer(&h);
{
halcc_hal *h;
- if (!manifest || !hal_name)
+ if (!manifest || !hal_name) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
h = hashtable_hal_lookup(manifest->hals,
hal_name, major, minor, HALCC_HASH_COMPARE_TYPE_FORWARD_MINOR_VERSION);
- if (!h)
+ if (!h) {
+ printf("Failed to find forward compatible to hal=%s@%d.%d\n", hal_name, major, minor);
return -ENOTSUP;
+ }
if (hal)
*hal = g_steal_pointer(&h);
{
halcc_hal *h = NULL;
- if (!manifest || !hal_name)
+ if (!manifest || !hal_name) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
h = hashtable_hal_steal(manifest->hals, hal_name, major, minor);
- if (!h)
+ if (!h) {
+ printf("Failed to find hal=%s@%d.%d\n", hal_name, major, minor);
return -ENOTSUP;
+ }
if (hal)
*hal = g_steal_pointer(&h);
void halcc_manifest_remove_hal(halcc_manifest *manifest,
const char *hal_name, int major, int minor)
{
- if (!manifest || !hal_name)
+ if (!manifest || !hal_name) {
+ printf("Invalid parameter\n");
return;
+ }
hashtable_hal_remove(manifest->hals, hal_name, major, minor);
}
void halcc_manifest_foreach_hal(halcc_manifest *manifest,
halcc_iter_cb cb, void *user_data)
{
- if (!manifest || !manifest->hals || !cb)
+ if (!manifest || !manifest->hals || !cb) {
+ printf("Invalid parameter\n");
return;
+ }
hashtable_foreach(manifest->hals, cb, user_data);
}
*/
void halcc_manifest_validate_hal_dependency(halcc_manifest *manifest)
{
- if (!manifest)
+ if (!manifest) {
+ printf("Invalid parameter\n");
return;
+ }
/* Reset all */
halcc_manifest_foreach_hal(manifest, reset_hal_dependency_state, NULL);
{
halcc_hal *h;
- if (!hal)
+ if (!hal) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
h = calloc(1, sizeof(halcc_hal));
- if (!h)
+ if (!h) {
+ printf("Failed to allocate halcc_hal\n");
return -ENOMEM;
+ }
h->transport = HALCC_TRANSPORT_DEFAULT;
h->dependency_state = HALCC_DEPENDENCY_STATE_NONE;
void halcc_hal_free(halcc_hal *hal)
{
- if (!hal)
+ if (!hal) {
+ printf("Invalid parameter\n");
return;
+ }
free(g_steal_pointer(&hal->name));
g_hash_table_destroy(g_steal_pointer(&hal->dependencies));
{
char *n;
- if (!hal)
+ if (!hal) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
if (hal->name)
free(g_steal_pointer(&hal->name));
return 0;
n = strndup(hal_name, HALCC_NAME_MAX);
- if (!n)
+ if (!n) {
+ printf("Failed to allocate hal_name\n");
return -ENOMEM;
+ }
hal->name = g_steal_pointer(&n);
int halcc_hal_get_name(halcc_hal *hal, const char **hal_name)
{
- if (!hal || !hal_name)
+ if (!hal || !hal_name) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
*hal_name = hal->name;
int halcc_hal_set_version(halcc_hal *hal, int major, int min_minor, int max_minor)
{
- if (!hal)
+ if (!hal) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
hal->version.major = major;
hal->version.min_minor = min_minor;
int halcc_hal_get_version(halcc_hal *hal, int *major, int *min_minor, int *max_minor)
{
- if (!hal || !major || !min_minor)
+ if (!hal || !major || !min_minor) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
*major = hal->version.major;
*min_minor = hal->version.min_minor;
int halcc_hal_set_transport(halcc_hal *hal, halcc_transport_e transport)
{
- if (!hal)
+ if (!hal) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
hal->transport = transport;
int halcc_hal_get_transport(halcc_hal *hal, halcc_transport_e *transport)
{
- if (!hal || !transport)
+ if (!hal || !transport) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
assert(hal->transport >= HALCC_TRANSPORT_PASSTHROUGH);
assert(hal->transport <= HALCC_TRANSPORT_IPC);
int halcc_hal_add_dependency(halcc_hal *hal, halcc_hal *dependency)
{
- if (!hal || !dependency)
+ if (!hal || !dependency) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
return hashtable_hal_insert(hal->dependencies, dependency);
}
void halcc_hal_remove_dependency(halcc_hal *hal,
const char *dependency_hal_name, int major, int minor)
{
- if (!hal || !dependency_hal_name)
+ if (!hal || !dependency_hal_name) {
+ printf("Invalid parameter\n");
return;
+ }
hashtable_hal_remove(hal->dependencies, dependency_hal_name, major, minor);
}
void halcc_hal_foreach_dependency(halcc_hal *hal, halcc_iter_cb cb, void *user_data)
{
- if (!hal || !hal->dependencies || !cb)
+ if (!hal || !hal->dependencies || !cb) {
+ printf("Invalid parameter\n");
return;
+ }
hashtable_foreach(hal->dependencies, cb, user_data);
}
int halcc_hal_add_interface(halcc_hal *hal, halcc_interface *interface)
{
- if (!hal || !interface)
+ if (!hal || !interface) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
return hashtable_interface_insert(hal->interfaces, interface);
}
void halcc_hal_remove_interface(halcc_hal *hal,
const char *interface_name, const char *instance_id)
{
- if (!hal || !interface_name)
+ if (!hal || !interface_name) {
+ printf("Invalid parameter\n");
return;
+ }
hashtable_interface_remove(hal->interfaces, interface_name, instance_id);
}
void halcc_hal_foreach_interface(halcc_hal *hal, halcc_iter_cb cb, void *user_data)
{
- if (!hal || !hal->interfaces || !cb)
+ if (!hal || !hal->interfaces || !cb) {
+ printf("Invalid parameter\n");
return;
+ }
hashtable_foreach(hal->interfaces, cb, user_data);
}
int halcc_hal_set_dependency_state(halcc_hal *hal, halcc_dependency_state_e dependency_state)
{
- if (!hal)
+ if (!hal) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
hal->dependency_state = dependency_state;
int halcc_hal_get_dependency_state(halcc_hal *hal, halcc_dependency_state_e *dependency_state)
{
- if (!hal || !dependency_state)
+ if (!hal || !dependency_state) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
*dependency_state = hal->dependency_state;
{
halcc_interface *iface;
- if (!interface)
+ if (!interface) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
iface = calloc(1, sizeof(halcc_interface));
- if (!iface)
+ if (!iface) {
+ printf("Failed to allocate halcc_interface\n");
return -ENOMEM;
+ }
*interface = g_steal_pointer(&iface);
void halcc_interface_free(halcc_interface *interface)
{
- if (!interface)
+ if (!interface) {
+ printf("Invalid parameter\n");
return;
+ }
free(g_steal_pointer(&interface->name));
free(g_steal_pointer(&interface->instance_id));
{
char *n;
- if (!interface || !interface_name)
+ if (!interface || !interface_name) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
n = strndup(interface_name, HALCC_NAME_MAX);
- if (!n)
+ if (!n) {
+ printf("Failed to allocate interface_name\n");
return -ENOMEM;
+ }
interface->name = g_steal_pointer(&n);
int halcc_interface_get_name(halcc_interface *interface, const char **interface_name)
{
- if (!interface || !interface_name)
+ if (!interface || !interface_name) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
*interface_name = interface->name;
{
char *id = NULL;
- if (!interface || !instance_id)
+ if (!interface || !instance_id) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
id = strndup(instance_id, HALCC_NAME_MAX);
- if (!id)
+ if (!id) {
+ printf("Failed to allocate instance_id\n");
return -ENOMEM;
+ }
interface->instance_id = g_steal_pointer(&id);
int halcc_interface_get_instance_id(halcc_interface *interface, const char **instance_id)
{
- if (!interface || !instance_id)
+ if (!interface || !instance_id) {
+ printf("Invalid parameter\n");
return -EINVAL;
+ }
*instance_id = interface->instance_id;