Skip to content

Commit

Permalink
[UR] Check for unused parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Petr Vesely committed Sep 15, 2023
1 parent bcf2b2a commit 3e1d0d8
Show file tree
Hide file tree
Showing 16 changed files with 654 additions and 526 deletions.
1 change: 1 addition & 0 deletions cmake/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function(add_ur_target_compile_options name)
-Wall
-Wpedantic
-Wempty-body
-Wunused-parameter
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=always>
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-fcolor-diagnostics>
)
Expand Down
2 changes: 1 addition & 1 deletion examples/hello_world/hello_world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "ur_api.h"

//////////////////////////////////////////////////////////////////////////
int main(int argc, char *argv[]) {
int main([[maybe_unused]] int argc, [[maybe_unused]] char *argv[]) {
ur_result_t status;

// Initialize the platform
Expand Down
4 changes: 2 additions & 2 deletions scripts/templates/params.hpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ template <typename T> inline void serializeTagged(std::ostream &os, const void *
%if re.match(r"enum", obj['type']):
inline std::ostream &operator<<(std::ostream &os, enum ${th.make_enum_name(n, tags, obj)} value);
%elif re.match(r"struct", obj['type']):
inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make_type_name(n, tags, obj)} params);
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ${obj['type']} ${th.make_type_name(n, tags, obj)} params);
%endif
%endfor # obj in spec['objects']
%endfor
Expand Down Expand Up @@ -353,7 +353,7 @@ for item in obj['members']:
%for tbl in th.get_pfncbtables(specs, meta, n, tags):
%for obj in tbl['functions']:

inline std::ostream &operator<<(std::ostream &os, const struct ${th.make_pfncb_param_type(n, tags, obj)} *params) {
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ${th.make_pfncb_param_type(n, tags, obj)} *params) {
<%
params_dict = dict()
for item in obj['params']:
Expand Down
35 changes: 18 additions & 17 deletions source/adapters/null/ur_null.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ context_t::context_t() {
return UR_RESULT_SUCCESS;
};
//////////////////////////////////////////////////////////////////////////
urDdiTable.Platform.pfnGet = [](ur_adapter_handle_t *phAdapters,
uint32_t NumAdapters, uint32_t NumEntries,
ur_platform_handle_t *phPlatforms,
uint32_t *pNumPlatforms) {
if (phPlatforms != nullptr && NumEntries != 1) {
return UR_RESULT_ERROR_INVALID_SIZE;
}
if (pNumPlatforms != nullptr) {
*pNumPlatforms = 1;
}
if (nullptr != phPlatforms) {
*reinterpret_cast<void **>(phPlatforms) = d_context.get();
}
return UR_RESULT_SUCCESS;
};
urDdiTable.Platform.pfnGet =
[]([[maybe_unused]] ur_adapter_handle_t *phAdapters,
[[maybe_unused]] uint32_t NumAdapters, uint32_t NumEntries,
ur_platform_handle_t *phPlatforms, uint32_t *pNumPlatforms) {
if (phPlatforms != nullptr && NumEntries != 1) {
return UR_RESULT_ERROR_INVALID_SIZE;
}
if (pNumPlatforms != nullptr) {
*pNumPlatforms = 1;
}
if (nullptr != phPlatforms) {
*reinterpret_cast<void **>(phPlatforms) = d_context.get();
}
return UR_RESULT_SUCCESS;
};

//////////////////////////////////////////////////////////////////////////
urDdiTable.Platform.pfnGetApiVersion = [](ur_platform_handle_t,
Expand Down Expand Up @@ -122,8 +122,9 @@ context_t::context_t() {

//////////////////////////////////////////////////////////////////////////
urDdiTable.Device.pfnGetInfo =
[](ur_device_handle_t hDevice, ur_device_info_t infoType,
size_t propSize, void *pDeviceInfo, size_t *pPropSizeRet) {
[]([[maybe_unused]] ur_device_handle_t hDevice,
ur_device_info_t infoType, size_t propSize, void *pDeviceInfo,
size_t *pPropSizeRet) {
switch (infoType) {
case UR_DEVICE_INFO_TYPE:
if (pDeviceInfo && propSize != sizeof(ur_device_type_t)) {
Expand Down
10 changes: 8 additions & 2 deletions source/common/unified_malloc_framework/src/memory_pool_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,15 @@ void umfPoolDestroy(umf_memory_pool_handle_t hPool) {
free(hPool);
}

enum umf_result_t umfFree(void *ptr) { return UMF_RESULT_ERROR_NOT_SUPPORTED; }
enum umf_result_t umfFree(void *ptr) {
(void)ptr;
return UMF_RESULT_ERROR_NOT_SUPPORTED;
}

umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) { return NULL; }
umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) {
(void)ptr;
return NULL;
}

enum umf_result_t
umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

#if defined(UMF_SHARED_LIBRARY)
critnib *TRACKER = NULL;
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
BOOL APIENTRY DllMain([[maybe_unused]] HINSTANCE hinstDLL, DWORD fdwReason,
LPVOID lpvReserved) {
if (fdwReason == DLL_PROCESS_DETACH) {
critnib_delete(TRACKER);
} else if (fdwReason == DLL_PROCESS_ATTACH) {
Expand Down
Loading

0 comments on commit 3e1d0d8

Please sign in to comment.