@@ -1691,7 +1691,6 @@ TEST_CASE("ebpf_type_conversion_apis", "[ebpf_api]")
16911691 const char * retrieved_name = ebpf_get_program_type_name (&program_type);
16921692 REQUIRE (retrieved_name != nullptr );
16931693 REQUIRE (std::string (retrieved_name) == " bind" );
1694- REQUIRE (strlen (retrieved_name) > 0 );
16951694}
16961695
16971696// Test path canonicalization API.
@@ -1744,9 +1743,7 @@ TEST_CASE("ebpf_enumerate_programs", "[ebpf_api]")
17441743 }
17451744
17461745 // Clean up error message if any.
1747- if (error_message != nullptr ) {
1748- ebpf_free_string (error_message);
1749- }
1746+ ebpf_free_string (error_message);
17501747 }
17511748
17521749 // Test with non-existent file - should fail gracefully.
@@ -1756,9 +1753,7 @@ TEST_CASE("ebpf_enumerate_programs", "[ebpf_api]")
17561753 REQUIRE (result != EBPF_SUCCESS);
17571754
17581755 // Clean up error message if any.
1759- if (error_message != nullptr ) {
1760- ebpf_free_string (error_message);
1761- }
1756+ ebpf_free_string (error_message);
17621757}
17631758
17641759// Test eBPF verification APIs.
@@ -1787,12 +1782,8 @@ TEST_CASE("ebpf_verification_apis", "[ebpf_api]")
17871782 REQUIRE (result == 0 );
17881783
17891784 // Clean up strings.
1790- if (report != nullptr ) {
1791- ebpf_free_string (report);
1792- }
1793- if (error_message != nullptr ) {
1794- ebpf_free_string (error_message);
1795- }
1785+ ebpf_free_string (report);
1786+ ebpf_free_string (error_message);
17961787 }
17971788
17981789 // Test disassembly APIs.
@@ -1814,12 +1805,8 @@ TEST_CASE("ebpf_verification_apis", "[ebpf_api]")
18141805 }
18151806
18161807 // Clean up strings.
1817- if (disassembly != nullptr ) {
1818- ebpf_free_string (disassembly);
1819- }
1820- if (error_message != nullptr ) {
1821- ebpf_free_string (error_message);
1822- }
1808+ ebpf_free_string (disassembly);
1809+ ebpf_free_string (error_message);
18231810 }
18241811}
18251812
@@ -2100,9 +2087,7 @@ TEST_CASE("ebpf_enumerate_sections_deprecated", "[ebpf_api]")
21002087 }
21012088
21022089 // Clean up error message if any.
2103- if (error_message != nullptr ) {
2104- ebpf_free_string (error_message);
2105- }
2090+ ebpf_free_string (error_message);
21062091}
21072092
21082093// Test deprecated ebpf_get_next_pinned_program_path API.
@@ -2144,25 +2129,17 @@ TEST_CASE("ebpf_verification_memory_apis", "[ebpf_api]")
21442129 REQUIRE (result != 0 ); // Not successful verification.
21452130
21462131 // Clean up strings.
2147- if (report != nullptr ) {
2148- ebpf_free_string (report);
2149- }
2150- if (error_message != nullptr ) {
2151- ebpf_free_string (error_message);
2152- }
2132+ ebpf_free_string (report);
2133+ ebpf_free_string (error_message);
21532134
21542135 // Test with null data - should fail gracefully.
21552136 result = ebpf_api_elf_verify_program_from_memory (
21562137 nullptr , 0 , nullptr , nullptr , nullptr , EBPF_VERIFICATION_VERBOSITY_NORMAL, &report, &error_message, &stats);
21572138 REQUIRE (result != 0 );
21582139
21592140 // Clean up strings.
2160- if (report != nullptr ) {
2161- ebpf_free_string (report);
2162- }
2163- if (error_message != nullptr ) {
2164- ebpf_free_string (error_message);
2165- }
2141+ ebpf_free_string (report);
2142+ ebpf_free_string (error_message);
21662143}
21672144
21682145// Test remaining deprecated eBPF verification APIs for completeness.
@@ -2183,12 +2160,8 @@ TEST_CASE("ebpf_deprecated_verification_apis", "[ebpf_api]")
21832160 }
21842161
21852162 // Clean up strings.
2186- if (disassembly != nullptr ) {
2187- ebpf_free_string (disassembly);
2188- }
2189- if (error_message != nullptr ) {
2190- ebpf_free_string (error_message);
2191- }
2163+ ebpf_free_string (disassembly);
2164+ ebpf_free_string (error_message);
21922165
21932166 // Test deprecated verify section from file API.
21942167 const char * report = nullptr ;
@@ -2207,12 +2180,8 @@ TEST_CASE("ebpf_deprecated_verification_apis", "[ebpf_api]")
22072180#pragma warning(pop)
22082181
22092182 // Clean up strings.
2210- if (report != nullptr ) {
2211- ebpf_free_string (report);
2212- }
2213- if (error_message != nullptr ) {
2214- ebpf_free_string (error_message);
2215- }
2183+ ebpf_free_string (report);
2184+ ebpf_free_string (error_message);
22162185
22172186 // Test deprecated verify section from memory API.
22182187 const char * test_data = " minimal_test_data" ;
@@ -2234,10 +2203,6 @@ TEST_CASE("ebpf_deprecated_verification_apis", "[ebpf_api]")
22342203 REQUIRE (result != 0 ); // Not successful verification.
22352204
22362205 // Clean up strings.
2237- if (report != nullptr ) {
2238- ebpf_free_string (report);
2239- }
2240- if (error_message != nullptr ) {
2241- ebpf_free_string (error_message);
2242- }
2206+ ebpf_free_string (report);
2207+ ebpf_free_string (error_message);
22432208}
0 commit comments