st/oxr: Avoid using strncpy

This commit is contained in:
Jakob Bornecrantz 2022-05-01 14:02:53 +01:00
parent c6208482b8
commit 545ad5c1bf
2 changed files with 3 additions and 3 deletions

View file

@ -288,7 +288,7 @@ oxr_xrStructureTypeToString(XrInstance instance, XrStructureType value, char buf
OXR_VERIFY_INSTANCE_AND_INIT_LOG(&log, instance, inst, "xrStructureTypeToString");
#define MAKE_TYPE_CASE(VAL, _) \
case VAL: strncpy(buffer, #VAL, XR_MAX_RESULT_STRING_SIZE); break;
case VAL: snprintf(buffer, XR_MAX_RESULT_STRING_SIZE, #VAL); break;
switch (value) {
XR_LIST_ENUM_XrStructureType(MAKE_TYPE_CASE);
default: snprintf(buffer, XR_MAX_RESULT_STRING_SIZE, "XR_UNKNOWN_STRUCTURE_TYPE_%d", value);

View file

@ -267,7 +267,7 @@ oxr_action_set_create(struct oxr_logger *log,
return oxr_error(log, XR_ERROR_RUNTIME_FAILURE, "Failed to create loc_store hashset");
}
strncpy(act_set_ref->name, createInfo->actionSetName, sizeof(act_set_ref->name));
snprintf(act_set_ref->name, sizeof(act_set_ref->name), "%s", createInfo->actionSetName);
u_hashset_create_and_insert_str_c(inst->action_sets.name_store, createInfo->actionSetName, &act_set->name_item);
u_hashset_create_and_insert_str_c(inst->action_sets.loc_store, createInfo->localizedActionSetName,
@ -351,7 +351,7 @@ oxr_action_create(struct oxr_logger *log,
act_ref->subaction_paths = subaction_paths;
act_ref->action_type = createInfo->actionType;
strncpy(act_ref->name, createInfo->actionName, sizeof(act_ref->name));
snprintf(act_ref->name, sizeof(act_ref->name), "%s", createInfo->actionName);
u_hashset_create_and_insert_str_c(act_set->data->actions.name_store, createInfo->actionName, &act->name_item);
u_hashset_create_and_insert_str_c(act_set->data->actions.loc_store, createInfo->localizedActionName,