Skip to content

Commit

Permalink
Annotate execution context API's with _Must_inspect_result_ (microsof…
Browse files Browse the repository at this point in the history
…t#1568)

* Annotate execution context API's with _Must_inspect_result_

Signed-off-by: Alan Jowett <[email protected]>

* PR feedback

Signed-off-by: Alan Jowett <[email protected]>

* Fix rebase

Signed-off-by: Alan Jowett <[email protected]>

* Code analysis failure

Signed-off-by: Alan Jowett <[email protected]>

Signed-off-by: Alan Jowett <[email protected]>
Signed-off-by: Alan Jowett <[email protected]>
Co-authored-by: Alan Jowett <[email protected]>
Co-authored-by: Dave Thaler <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2022
1 parent 8f4180d commit 850f6d2
Show file tree
Hide file tree
Showing 15 changed files with 173 additions and 137 deletions.
29 changes: 18 additions & 11 deletions libs/execution_context/ebpf_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ ebpf_general_helper_function_provider_detach_client(_Inout_ void* provider_bindi
return STATUS_SUCCESS;
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_initiate()
{
ebpf_result_t return_value;
Expand Down Expand Up @@ -251,7 +251,7 @@ ebpf_core_terminate()
ebpf_platform_terminate();
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_load_code(
ebpf_handle_t program_handle,
ebpf_code_type_t code_type,
Expand Down Expand Up @@ -317,7 +317,7 @@ _ebpf_core_protocol_load_code(_In_ const ebpf_operation_load_code_request_t* req
EBPF_RETURN_RESULT(retval);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_resolve_helper(
ebpf_handle_t program_handle,
const size_t count_of_helpers,
Expand Down Expand Up @@ -390,7 +390,7 @@ _ebpf_core_protocol_resolve_helper(
EBPF_RETURN_RESULT(return_value);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_resolve_maps(
ebpf_handle_t program_handle,
uint32_t count_of_maps,
Expand Down Expand Up @@ -464,7 +464,7 @@ _ebpf_core_protocol_resolve_map(
EBPF_RETURN_RESULT(return_value);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_create_map(
_In_ const ebpf_utf8_string_t* map_name,
_In_ const ebpf_map_definition_in_memory_t* ebpf_map_definition,
Expand Down Expand Up @@ -684,7 +684,14 @@ _ebpf_core_protocol_load_native_programs(
// If this call failed, stop the native driver. ebpfapi will create a
// new service for the driver in the next attempt.
if (result != EBPF_SUCCESS) {
ebpf_native_unload(&request->module_id);
ebpf_result_t native_unload_result = ebpf_native_unload(&request->module_id);
if (native_unload_result != EBPF_SUCCESS) {
EBPF_LOG_MESSAGE_GUID(
EBPF_TRACELOG_LEVEL_ERROR,
EBPF_TRACELOG_KEYWORD_NATIVE,
"Failed to unload native driver",
request->module_id);
}
}

EBPF_RETURN_RESULT(result);
Expand Down Expand Up @@ -921,7 +928,7 @@ _ebpf_core_protocol_query_program_info(
EBPF_RETURN_RESULT(retval);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_update_pinning(const ebpf_handle_t handle, _In_ const ebpf_utf8_string_t* path)
{
EBPF_LOG_ENTRY();
Expand Down Expand Up @@ -967,7 +974,7 @@ _ebpf_core_protocol_update_pinning(_In_ const struct _ebpf_operation_update_map_
EBPF_RETURN_RESULT(retval);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_get_pinned_object(_In_ const ebpf_utf8_string_t* path, _Out_ ebpf_handle_t* handle)
{
EBPF_LOG_ENTRY();
Expand Down Expand Up @@ -1370,7 +1377,7 @@ _ebpf_core_protocol_get_pinned_map_info(
EBPF_RETURN_RESULT(result);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_get_handle_by_id(ebpf_object_type_t type, ebpf_id_t id, _Out_ ebpf_handle_t* handle)
{
EBPF_LOG_ENTRY();
Expand Down Expand Up @@ -2018,7 +2025,7 @@ static ebpf_protocol_handler_t _ebpf_protocol_handlers[] = {
DECLARE_PROTOCOL_HANDLER_FIXED_REQUEST_VARIABLE_REPLY(load_native_programs, data, PROTOCOL_NATIVE_MODE),
};

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_get_protocol_handler_properties(
ebpf_operation_id_t operation_id,
_Out_ size_t* minimum_request_size,
Expand Down Expand Up @@ -2070,7 +2077,7 @@ ebpf_core_get_protocol_handler_properties(
return EBPF_SUCCESS;
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_invoke_protocol_handler(
ebpf_operation_id_t operation_id,
_In_reads_bytes_(input_buffer_length) const void* input_buffer,
Expand Down
20 changes: 10 additions & 10 deletions libs/execution_context/ebpf_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ extern "C"
* @retval EBPF_NO_MEMORY Unable to allocate resources for this
* operation.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_initiate();

/**
Expand All @@ -55,7 +55,7 @@ extern "C"
* @retval EBPF_NO_MEMORY Unable to allocate resources for this
* operation.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_invoke_protocol_handler(
ebpf_operation_id_t operation_id,
_In_reads_bytes_(input_buffer_length) const void* input_buffer,
Expand All @@ -76,7 +76,7 @@ extern "C"
* @retval EBPF_SUCCESS The operation was successful.
* @retval EBPF_NOT_SUPPORTED The operation id is not valid.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_get_protocol_handler_properties(
ebpf_operation_id_t operation_id,
_Out_ size_t* minimum_request_size,
Expand Down Expand Up @@ -123,7 +123,7 @@ extern "C"
* @retval EBPF_SUCCESS The operation was successful.
* @retval EBPF_NOT_FOUND No object was pinned to the provided path.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_get_pinned_object(_In_ const ebpf_utf8_string_t* path, _Out_ ebpf_handle_t* handle);

/**
Expand All @@ -138,7 +138,7 @@ extern "C"
* @retval EBPF_NO_MEMORY Unable to allocate resources for this operation.
* @retval EBPF_NOT_FOUND No object was pinned to the provided path.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_update_pinning(const ebpf_handle_t handle, _In_ const ebpf_utf8_string_t* path);

/**
Expand All @@ -152,7 +152,7 @@ extern "C"
* @retval EBPF_SUCCESS The operation was successful.
* @retval EBPF_NO_MEMORY Unable to allocate resources for this operation.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_create_map(
_In_ const ebpf_utf8_string_t* map_name,
_In_ const ebpf_map_definition_in_memory_t* ebpf_map_definition,
Expand All @@ -171,7 +171,7 @@ extern "C"
* @retval EBPF_SUCCESS The operation was successful.
* @retval EBPF_NO_MEMORY Unable to allocate resources for this operation.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_load_code(
ebpf_handle_t program_handle,
ebpf_code_type_t code_type,
Expand All @@ -191,7 +191,7 @@ extern "C"
* @retval EBPF_NO_MEMORY Unable to allocate resources for this
* operation.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_get_handle_by_id(ebpf_object_type_t type, ebpf_id_t id, _Out_ ebpf_handle_t* handle);

/**
Expand All @@ -209,7 +209,7 @@ extern "C"
* @retval EBPF_INVALID_FD The program is incompatible with the map.
* @retval EBPF_NO_MEMORY Unable to allocate resources for this operation.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_resolve_maps(
ebpf_handle_t program_handle,
uint32_t count_of_maps,
Expand All @@ -230,7 +230,7 @@ extern "C"
* @retval EBPF_INVALID_ARGUMENT An invalid argument was supplied.
* @retval EBPF_NO_MEMORY Unable to allocate resources for this operation.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_core_resolve_helper(
ebpf_handle_t program_handle,
const size_t count_of_helpers,
Expand Down
8 changes: 4 additions & 4 deletions libs/execution_context/ebpf_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ _ebpf_link_free(ebpf_core_object_t* object)
ebpf_epoch_free(link);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_link_create(ebpf_link_t** link)
{
EBPF_LOG_ENTRY();
Expand All @@ -63,7 +63,7 @@ ebpf_link_create(ebpf_link_t** link)
EBPF_RETURN_RESULT(EBPF_SUCCESS);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_link_initialize(
ebpf_link_t* link, ebpf_attach_type_t attach_type, const uint8_t* context_data, size_t context_data_length)
{
Expand Down Expand Up @@ -127,7 +127,7 @@ ebpf_link_initialize(
EBPF_RETURN_RESULT(return_value);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_link_attach_program(ebpf_link_t* link, ebpf_program_t* program)
{
EBPF_LOG_ENTRY();
Expand Down Expand Up @@ -210,7 +210,7 @@ _ebpf_link_instance_invoke(
EBPF_RETURN_RESULT(return_value);
}

ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_link_get_info(
_In_ const ebpf_link_t* link, _Out_writes_to_(*info_size, *info_size) uint8_t* buffer, _Inout_ uint16_t* info_size)
{
Expand Down
8 changes: 4 additions & 4 deletions libs/execution_context/ebpf_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C"
* link object.
* @retval EBPF_SUCCESS The operation was successful.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_link_create(ebpf_link_t** link);

/**
Expand All @@ -37,7 +37,7 @@ extern "C"
* provider.
* @retval EBPF_SUCCESS The operation was successful.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_link_initialize(
ebpf_link_t* link, ebpf_attach_type_t attach_type, const uint8_t* context_data, size_t context_data_length);

Expand All @@ -50,7 +50,7 @@ extern "C"
* @retval EBPF_INVALID_ARGUMENT Hook instance has not been
* initialized.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_link_attach_program(ebpf_link_t* link, ebpf_program_t* program);

/**
Expand All @@ -72,7 +72,7 @@ extern "C"
* @retval EBPF_SUCCESS The operation was successful.
* @retval EBPF_INSUFFICIENT_BUFFER The buffer was too small to hold bpf_link_info.
*/
ebpf_result_t
_Must_inspect_result_ ebpf_result_t
ebpf_link_get_info(
_In_ const ebpf_link_t* link,
_Out_writes_to_(*info_size, *info_size) uint8_t* buffer,
Expand Down
Loading

0 comments on commit 850f6d2

Please sign in to comment.