Skip to content

Commit e40a321

Browse files
authored
Merge pull request #861 from veselypeta/petr/add-unused-parameter-checks
[UR] Check for unused parameters
2 parents 099fe5e + 88c7f8f commit e40a321

File tree

18 files changed

+670
-553
lines changed

18 files changed

+670
-553
lines changed

cmake/helpers.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function(add_ur_target_compile_options name)
6464
-Wall
6565
-Wpedantic
6666
-Wempty-body
67+
-Wunused-parameter
6768
$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color=always>
6869
$<$<CXX_COMPILER_ID:Clang,AppleClang>:-fcolor-diagnostics>
6970
)

examples/collector/collector.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ static std::unordered_map<
8282
* On begin, it prints the function declaration with the call arguments specified,
8383
* and on end it prints the function name with the result of the call.
8484
*/
85-
XPTI_CALLBACK_API void trace_cb(uint16_t trace_type,
86-
xpti::trace_event_data_t *parent,
87-
xpti::trace_event_data_t *event,
88-
uint64_t instance, const void *user_data) {
85+
XPTI_CALLBACK_API void trace_cb(uint16_t trace_type, xpti::trace_event_data_t *,
86+
xpti::trace_event_data_t *, uint64_t instance,
87+
const void *user_data) {
8988
auto *args = static_cast<const xpti::function_with_args_t *>(user_data);
9089
std::ostringstream out;
9190
if (trace_type == TRACE_FN_BEGIN) {
@@ -119,8 +118,7 @@ XPTI_CALLBACK_API void trace_cb(uint16_t trace_type,
119118
* selected trace types.
120119
*/
121120
XPTI_CALLBACK_API void xptiTraceInit(unsigned int major_version,
122-
unsigned int minor_version,
123-
const char *version_str,
121+
unsigned int minor_version, const char *,
124122
const char *stream_name) {
125123
if (stream_name == nullptr) {
126124
std::cout << "Stream name not provided. Aborting." << std::endl;
@@ -158,5 +156,5 @@ XPTI_CALLBACK_API void xptiTraceInit(unsigned int major_version,
158156
*
159157
* Can be used to cleanup state or resources.
160158
*/
161-
XPTI_CALLBACK_API void xptiTraceFinish(const char *stream_name) { /* noop */
159+
XPTI_CALLBACK_API void xptiTraceFinish(const char *) { /* noop */
162160
}

examples/hello_world/hello_world.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "ur_api.h"
1616

1717
//////////////////////////////////////////////////////////////////////////
18-
int main(int argc, char *argv[]) {
18+
int main(int, char *[]) {
1919
ur_result_t status;
2020

2121
// Initialize the platform

scripts/templates/params.hpp.mako

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ template <typename T> inline void serializeTagged(std::ostream &os, const void *
144144
%if re.match(r"enum", obj['type']):
145145
inline std::ostream &operator<<(std::ostream &os, enum ${th.make_enum_name(n, tags, obj)} value);
146146
%elif re.match(r"struct", obj['type']):
147-
inline std::ostream &operator<<(std::ostream &os, const ${obj['type']} ${th.make_type_name(n, tags, obj)} params);
147+
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const ${obj['type']} ${th.make_type_name(n, tags, obj)} params);
148148
%endif
149149
%endfor # obj in spec['objects']
150150
%endfor
@@ -353,7 +353,7 @@ for item in obj['members']:
353353
%for tbl in th.get_pfncbtables(specs, meta, n, tags):
354354
%for obj in tbl['functions']:
355355

356-
inline std::ostream &operator<<(std::ostream &os, const struct ${th.make_pfncb_param_type(n, tags, obj)} *params) {
356+
inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ${th.make_pfncb_param_type(n, tags, obj)} *params) {
357357
<%
358358
params_dict = dict()
359359
for item in obj['params']:

source/adapters/null/ur_null.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,20 @@ context_t::context_t() {
3838
return UR_RESULT_SUCCESS;
3939
};
4040
//////////////////////////////////////////////////////////////////////////
41-
urDdiTable.Platform.pfnGet = [](ur_adapter_handle_t *phAdapters,
42-
uint32_t NumAdapters, uint32_t NumEntries,
43-
ur_platform_handle_t *phPlatforms,
44-
uint32_t *pNumPlatforms) {
45-
if (phPlatforms != nullptr && NumEntries != 1) {
46-
return UR_RESULT_ERROR_INVALID_SIZE;
47-
}
48-
if (pNumPlatforms != nullptr) {
49-
*pNumPlatforms = 1;
50-
}
51-
if (nullptr != phPlatforms) {
52-
*reinterpret_cast<void **>(phPlatforms) = d_context.get();
53-
}
54-
return UR_RESULT_SUCCESS;
55-
};
41+
urDdiTable.Platform.pfnGet =
42+
[](ur_adapter_handle_t *, uint32_t, uint32_t NumEntries,
43+
ur_platform_handle_t *phPlatforms, uint32_t *pNumPlatforms) {
44+
if (phPlatforms != nullptr && NumEntries != 1) {
45+
return UR_RESULT_ERROR_INVALID_SIZE;
46+
}
47+
if (pNumPlatforms != nullptr) {
48+
*pNumPlatforms = 1;
49+
}
50+
if (nullptr != phPlatforms) {
51+
*reinterpret_cast<void **>(phPlatforms) = d_context.get();
52+
}
53+
return UR_RESULT_SUCCESS;
54+
};
5655

5756
//////////////////////////////////////////////////////////////////////////
5857
urDdiTable.Platform.pfnGetApiVersion = [](ur_platform_handle_t,
@@ -122,8 +121,8 @@ context_t::context_t() {
122121

123122
//////////////////////////////////////////////////////////////////////////
124123
urDdiTable.Device.pfnGetInfo =
125-
[](ur_device_handle_t hDevice, ur_device_info_t infoType,
126-
size_t propSize, void *pDeviceInfo, size_t *pPropSizeRet) {
124+
[](ur_device_handle_t, ur_device_info_t infoType, size_t propSize,
125+
void *pDeviceInfo, size_t *pPropSizeRet) {
127126
switch (infoType) {
128127
case UR_DEVICE_INFO_TYPE:
129128
if (pDeviceInfo && propSize != sizeof(ur_device_type_t)) {

source/common/unified_malloc_framework/src/memory_pool_default.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,15 @@ void umfPoolDestroy(umf_memory_pool_handle_t hPool) {
6969
free(hPool);
7070
}
7171

72-
enum umf_result_t umfFree(void *ptr) { return UMF_RESULT_ERROR_NOT_SUPPORTED; }
72+
enum umf_result_t umfFree(void *ptr) {
73+
(void)ptr;
74+
return UMF_RESULT_ERROR_NOT_SUPPORTED;
75+
}
7376

74-
umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) { return NULL; }
77+
umf_memory_pool_handle_t umfPoolByPtr(const void *ptr) {
78+
(void)ptr;
79+
return NULL;
80+
}
7581

7682
enum umf_result_t
7783
umfPoolGetMemoryProviders(umf_memory_pool_handle_t hPool, size_t numProviders,

source/common/unified_malloc_framework/src/memory_tracker_windows.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
#include "memory_tracker.h"
1313

1414
#include <windows.h>
15-
1615
#if defined(UMF_SHARED_LIBRARY)
1716
critnib *TRACKER = NULL;
18-
BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
17+
BOOL APIENTRY DllMain(HINSTANCE, DWORD fdwReason, LPVOID lpvReserved) {
1918
if (fdwReason == DLL_PROCESS_DETACH) {
2019
critnib_delete(TRACKER);
2120
} else if (fdwReason == DLL_PROCESS_ATTACH) {

0 commit comments

Comments
 (0)