/*
- * Copyright 2019 EfficiOS Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * SPDX-License-Identifier: MIT
*
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Copyright 2019 EfficiOS Inc.
*/
#include "param-validation.h"
#include <babeltrace2/babeltrace.h>
#include <glib.h>
#include <inttypes.h>
+#include <stdbool.h>
#include "common/common.h"
g_string_append_printf(str, "[%" PRIu64 "]", elem->array_index);
break;
default:
- abort();
+ bt_common_abort();
}
}
g_string_assign(str, "Error validating parameter `");
- append_scope_to_string(str, &g_array_index(ctx->scope_stack,
+ append_scope_to_string(str, &bt_g_array_index(ctx->scope_stack,
struct validate_ctx_stack_element, 0), true);
for (i = 1; i < ctx->scope_stack->len; i++) {
append_scope_to_string(str,
- &g_array_index(ctx->scope_stack,
+ &bt_g_array_index(ctx->scope_stack,
struct validate_ctx_stack_element, i), false);
}
struct bt_param_validation_context *ctx);
static
-bt_bool validate_map_value_entry(const char *key,
- const bt_value *value, void *v_data)
+bt_value_map_foreach_entry_const_func_status validate_map_value_entry(
+ const char *key, const bt_value *value, void *v_data)
{
struct validate_map_value_data *data = v_data;
const struct bt_param_validation_map_value_entry_descr *entry = NULL;
}
/* Continue iterating if everything is good so far. */
- return data->status == BT_PARAM_VALIDATION_STATUS_OK;
+ return data->status == BT_PARAM_VALIDATION_STATUS_OK ?
+ BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_OK :
+ BT_VALUE_MAP_FOREACH_ENTRY_CONST_FUNC_STATUS_INTERRUPT;
}
static
struct bt_param_validation_map_value_descr map_value_descr;
enum bt_param_validation_status status;
- ctx.error = NULL;
+ memset(&ctx, '\0', sizeof(ctx));
+
ctx.scope_stack = g_array_new(FALSE, FALSE,
sizeof(struct validate_ctx_stack_element));
- g_ptr_array_new_with_free_func(g_free);
if (!ctx.scope_stack) {
status = BT_PARAM_VALIDATION_STATUS_MEMORY_ERROR;
goto end;
*error = ctx.error;
ctx.error = NULL;
+ if (ctx.scope_stack) {
+ g_array_free(ctx.scope_stack, TRUE);
+ }
+
return status;
}