Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cl_khr_semaphore: fix -Wformat warnings #2124

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct GetInfoInvalidValue : public SemaphoreTestBase

// make sure that first test provides too small param size
if (size != sizeof(sema_props))
test_fail("Error: expected size %d, returned %d",
test_fail("Error: expected size %zu, returned %zu",
sizeof(sema_props), size);

// first test with non-zero property size but not enough
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
// limitations under the License.
//

#include <cinttypes>
#include "semaphore_base.h"

#define FLUSH_DELAY_S 5

#define SEMAPHORE_PARAM_TEST(param_name, param_type, expected) \
#define SEMAPHORE_PARAM_TEST(param_name, param_type, format, expected) \
do \
{ \
param_type value; \
Expand All @@ -28,9 +29,10 @@
test_error(error, "Unable to get " #param_name " from semaphore"); \
if (value != expected) \
{ \
test_fail("ERROR: Parameter %s did not validate! (expected %d, " \
"got %d)\n", \
#param_name, expected, value); \
test_fail( \
"ERROR: Parameter %s did not validate! (expected " format ", " \
"got " format ")\n", \
#param_name, expected, value); \
} \
if (size != sizeof(value)) \
{ \
Expand Down Expand Up @@ -96,39 +98,44 @@ struct SemaphoreWithDeviceListQueries : public SemaphoreTestBase

// Confirm that querying CL_SEMAPHORE_TYPE_KHR returns
// CL_SEMAPHORE_TYPE_BINARY_KHR
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_TYPE_KHR, cl_semaphore_type_khr,
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_TYPE_KHR, cl_semaphore_type_khr, "%d",
CL_SEMAPHORE_TYPE_BINARY_KHR);

// Confirm that querying CL_SEMAPHORE_CONTEXT_KHR returns the right
// context
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_CONTEXT_KHR, cl_context, context);
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_CONTEXT_KHR, cl_context, "%p",
context);

// Confirm that querying CL_SEMAPHORE_REFERENCE_COUNT_KHR returns
// the right value
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 1);
// Confirm that querying CL_SEMAPHORE_REFERENCE_COUNT_KHR returns the
// right value
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, "%u",
1);

err = clRetainSemaphoreKHR(semaphore);
test_error(err, "Could not retain semaphore");
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 2);
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, "%u",
2);

err = clReleaseSemaphoreKHR(semaphore);
test_error(err, "Could not release semaphore");
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, 1);
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_REFERENCE_COUNT_KHR, cl_uint, "%u",
1);

// Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns
// the same device id the semaphore was created with
// Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns the
// same device id the semaphore was created with
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id,
device);
"%p", device);

// Confirm that querying CL_SEMAPHORE_PROPERTIES_KHR returns the
// same properties the semaphore was created with
// Confirm that querying CL_SEMAPHORE_PROPERTIES_KHR returns the same
// properties the semaphore was created with
SEMAPHORE_PARAM_TEST_ARRAY(CL_SEMAPHORE_PROPERTIES_KHR,
cl_semaphore_properties_khr, 6, sema_props);

// Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the
// unsignaled state
// Confirm that querying CL_SEMAPHORE_PAYLOAD_KHR returns the unsignaled
// state
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_PAYLOAD_KHR, cl_semaphore_payload_khr,
0);
"%" PRIu64,
static_cast<cl_semaphore_payload_khr>(0));

return TEST_PASS;
}
Expand Down Expand Up @@ -162,7 +169,7 @@ struct SemaphoreNoDeviceListQueries : public SemaphoreTestBase
// Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns
// device id the semaphore was created with
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id,
device);
"%p", device);

return TEST_PASS;
}
Expand Down Expand Up @@ -239,7 +246,7 @@ struct SemaphoreMultiDeviceContextQueries : public SemaphoreTestBase
// Confirm that querying CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR returns
// the same device id the semaphore was created with
SEMAPHORE_PARAM_TEST(CL_SEMAPHORE_DEVICE_HANDLE_LIST_KHR, cl_device_id,
scope_guard.sub_devices[0]);
"%p", scope_guard.sub_devices[0]);

return TEST_PASS;
}
Expand Down
Loading