Skip to content

Commit 50193da

Browse files
authored
Merge pull request #611 from aarongreig/aaron/deadCodeInVal
Fix Coverity issue: logically dead code generated in validation layer.
2 parents bffad0c + 5aa8aa5 commit 50193da

File tree

9 files changed

+48
-63
lines changed

9 files changed

+48
-63
lines changed

include/ur_api.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,25 +2924,24 @@ typedef enum ur_usm_pool_info_t {
29242924
/// + `NULL == hPool`
29252925
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
29262926
/// + `::UR_USM_POOL_INFO_CONTEXT < propName`
2927-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
2928-
/// + `NULL == pPropValue`
2929-
/// + `NULL == pPropSizeRet`
2930-
/// + `propSize != 0 && pPropValue == NULL`
2931-
/// + `pPropValue == NULL && pPropSizeRet == NULL`
29322927
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
29332928
/// + If `propName` is not supported by the adapter.
29342929
/// - ::UR_RESULT_ERROR_INVALID_SIZE
29352930
/// + `propSize == 0 && pPropValue != NULL`
29362931
/// + If `propSize` is less than the real number of bytes needed to return the info.
2932+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
2933+
/// + `propSize != 0 && pPropValue == NULL`
2934+
/// + `pPropValue == NULL && pPropSizeRet == NULL`
29372935
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
29382936
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
29392937
UR_APIEXPORT ur_result_t UR_APICALL
29402938
urUSMPoolGetInfo(
29412939
ur_usm_pool_handle_t hPool, ///< [in] handle of the USM memory pool
29422940
ur_usm_pool_info_t propName, ///< [in] name of the pool property to query
29432941
size_t propSize, ///< [in] size in bytes of the pool property value provided
2944-
void *pPropValue, ///< [out][typename(propName, propSize)] value of the pool property
2945-
size_t *pPropSizeRet ///< [out] size in bytes returned in pool property value
2942+
void *pPropValue, ///< [out][optional][typename(propName, propSize)] value of the pool
2943+
///< property
2944+
size_t *pPropSizeRet ///< [out][optional] size in bytes returned in pool property value
29462945
);
29472946

29482947
#if !defined(__GNUC__)
@@ -5645,10 +5644,9 @@ urEnqueueMemUnmap(
56455644
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
56465645
/// - ::UR_RESULT_ERROR_INVALID_EVENT
56475646
/// - ::UR_RESULT_ERROR_INVALID_SIZE
5648-
/// + `patternSize == 0`
5647+
/// + `patternSize == 0 || size == 0`
56495648
/// + `patternSize > size`
5650-
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
5651-
/// + `size == 0`
5649+
/// + `(patternSize & (patternSize - 1)) != 0`
56525650
/// + `size % patternSize != 0`
56535651
/// + If `size` is higher than the allocation size of `ptr`
56545652
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST

scripts/core/enqueue.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,10 +1012,9 @@ returns:
10121012
- $X_RESULT_ERROR_INVALID_QUEUE
10131013
- $X_RESULT_ERROR_INVALID_EVENT
10141014
- $X_RESULT_ERROR_INVALID_SIZE:
1015-
- "`patternSize == 0`"
1015+
- "`patternSize == 0 || size == 0`"
10161016
- "`patternSize > size`"
1017-
- "`patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`"
1018-
- "`size == 0`"
1017+
- "`(patternSize & (patternSize - 1)) != 0`"
10191018
- "`size % patternSize != 0`"
10201019
- "If `size` is higher than the allocation size of `ptr`"
10211020
- $X_RESULT_ERROR_INVALID_EVENT_WAIT_LIST:

scripts/core/usm.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,10 @@ params:
458458
desc: "[in] size in bytes of the pool property value provided"
459459
- type: "void*"
460460
name: pPropValue
461-
desc: "[out][typename(propName, propSize)] value of the pool property"
461+
desc: "[out][optional][typename(propName, propSize)] value of the pool property"
462462
- type: "size_t*"
463463
name: pPropSizeRet
464-
desc: "[out] size in bytes returned in pool property value"
464+
desc: "[out][optional] size in bytes returned in pool property value"
465465
returns:
466466
- $X_RESULT_ERROR_UNSUPPORTED_ENUMERATION:
467467
- "If `propName` is not supported by the adapter."

source/adapters/null/ur_nullddi.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,9 +1302,10 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo(
13021302
ur_usm_pool_info_t propName, ///< [in] name of the pool property to query
13031303
size_t propSize, ///< [in] size in bytes of the pool property value provided
13041304
void *
1305-
pPropValue, ///< [out][typename(propName, propSize)] value of the pool property
1306-
size_t
1307-
*pPropSizeRet ///< [out] size in bytes returned in pool property value
1305+
pPropValue, ///< [out][optional][typename(propName, propSize)] value of the pool
1306+
///< property
1307+
size_t *
1308+
pPropSizeRet ///< [out][optional] size in bytes returned in pool property value
13081309
) try {
13091310
ur_result_t result = UR_RESULT_SUCCESS;
13101311

source/loader/layers/tracing/ur_trcddi.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,9 +1476,10 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo(
14761476
ur_usm_pool_info_t propName, ///< [in] name of the pool property to query
14771477
size_t propSize, ///< [in] size in bytes of the pool property value provided
14781478
void *
1479-
pPropValue, ///< [out][typename(propName, propSize)] value of the pool property
1480-
size_t
1481-
*pPropSizeRet ///< [out] size in bytes returned in pool property value
1479+
pPropValue, ///< [out][optional][typename(propName, propSize)] value of the pool
1480+
///< property
1481+
size_t *
1482+
pPropSizeRet ///< [out][optional] size in bytes returned in pool property value
14821483
) {
14831484
auto pfnPoolGetInfo = context.urDdiTable.USM.pfnPoolGetInfo;
14841485

source/loader/layers/validation/ur_valddi.cpp

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,9 +1801,10 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo(
18011801
ur_usm_pool_info_t propName, ///< [in] name of the pool property to query
18021802
size_t propSize, ///< [in] size in bytes of the pool property value provided
18031803
void *
1804-
pPropValue, ///< [out][typename(propName, propSize)] value of the pool property
1805-
size_t
1806-
*pPropSizeRet ///< [out] size in bytes returned in pool property value
1804+
pPropValue, ///< [out][optional][typename(propName, propSize)] value of the pool
1805+
///< property
1806+
size_t *
1807+
pPropSizeRet ///< [out][optional] size in bytes returned in pool property value
18071808
) {
18081809
auto pfnPoolGetInfo = context.urDdiTable.USM.pfnPoolGetInfo;
18091810

@@ -1816,14 +1817,6 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo(
18161817
return UR_RESULT_ERROR_INVALID_NULL_HANDLE;
18171818
}
18181819

1819-
if (NULL == pPropValue) {
1820-
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
1821-
}
1822-
1823-
if (NULL == pPropSizeRet) {
1824-
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
1825-
}
1826-
18271820
if (propSize != 0 && pPropValue == NULL) {
18281821
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
18291822
}
@@ -4407,19 +4400,15 @@ __urdlllocal ur_result_t UR_APICALL urEnqueueUSMFill(
44074400
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
44084401
}
44094402

4410-
if (patternSize == 0) {
4403+
if (patternSize == 0 || size == 0) {
44114404
return UR_RESULT_ERROR_INVALID_SIZE;
44124405
}
44134406

44144407
if (patternSize > size) {
44154408
return UR_RESULT_ERROR_INVALID_SIZE;
44164409
}
44174410

4418-
if (patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)) {
4419-
return UR_RESULT_ERROR_INVALID_SIZE;
4420-
}
4421-
4422-
if (size == 0) {
4411+
if ((patternSize & (patternSize - 1)) != 0) {
44234412
return UR_RESULT_ERROR_INVALID_SIZE;
44244413
}
44254414

source/loader/ur_ldrddi.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,9 +1742,10 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo(
17421742
ur_usm_pool_info_t propName, ///< [in] name of the pool property to query
17431743
size_t propSize, ///< [in] size in bytes of the pool property value provided
17441744
void *
1745-
pPropValue, ///< [out][typename(propName, propSize)] value of the pool property
1746-
size_t
1747-
*pPropSizeRet ///< [out] size in bytes returned in pool property value
1745+
pPropValue, ///< [out][optional][typename(propName, propSize)] value of the pool
1746+
///< property
1747+
size_t *
1748+
pPropSizeRet ///< [out][optional] size in bytes returned in pool property value
17481749
) {
17491750
ur_result_t result = UR_RESULT_SUCCESS;
17501751

source/loader/ur_libapi.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,26 +2022,25 @@ ur_result_t UR_APICALL urUSMPoolRelease(
20222022
/// + `NULL == hPool`
20232023
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
20242024
/// + `::UR_USM_POOL_INFO_CONTEXT < propName`
2025-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
2026-
/// + `NULL == pPropValue`
2027-
/// + `NULL == pPropSizeRet`
2028-
/// + `propSize != 0 && pPropValue == NULL`
2029-
/// + `pPropValue == NULL && pPropSizeRet == NULL`
20302025
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
20312026
/// + If `propName` is not supported by the adapter.
20322027
/// - ::UR_RESULT_ERROR_INVALID_SIZE
20332028
/// + `propSize == 0 && pPropValue != NULL`
20342029
/// + If `propSize` is less than the real number of bytes needed to return the info.
2030+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
2031+
/// + `propSize != 0 && pPropValue == NULL`
2032+
/// + `pPropValue == NULL && pPropSizeRet == NULL`
20352033
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
20362034
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
20372035
ur_result_t UR_APICALL urUSMPoolGetInfo(
20382036
ur_usm_pool_handle_t hPool, ///< [in] handle of the USM memory pool
20392037
ur_usm_pool_info_t propName, ///< [in] name of the pool property to query
20402038
size_t propSize, ///< [in] size in bytes of the pool property value provided
20412039
void *
2042-
pPropValue, ///< [out][typename(propName, propSize)] value of the pool property
2043-
size_t
2044-
*pPropSizeRet ///< [out] size in bytes returned in pool property value
2040+
pPropValue, ///< [out][optional][typename(propName, propSize)] value of the pool
2041+
///< property
2042+
size_t *
2043+
pPropSizeRet ///< [out][optional] size in bytes returned in pool property value
20452044
) try {
20462045
auto pfnPoolGetInfo = ur_lib::context->urDdiTable.USM.pfnPoolGetInfo;
20472046
if (nullptr == pfnPoolGetInfo) {
@@ -4746,10 +4745,9 @@ ur_result_t UR_APICALL urEnqueueMemUnmap(
47464745
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
47474746
/// - ::UR_RESULT_ERROR_INVALID_EVENT
47484747
/// - ::UR_RESULT_ERROR_INVALID_SIZE
4749-
/// + `patternSize == 0`
4748+
/// + `patternSize == 0 || size == 0`
47504749
/// + `patternSize > size`
4751-
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
4752-
/// + `size == 0`
4750+
/// + `(patternSize & (patternSize - 1)) != 0`
47534751
/// + `size % patternSize != 0`
47544752
/// + If `size` is higher than the allocation size of `ptr`
47554753
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST

source/ur_api.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,26 +1690,25 @@ ur_result_t UR_APICALL urUSMPoolRelease(
16901690
/// + `NULL == hPool`
16911691
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
16921692
/// + `::UR_USM_POOL_INFO_CONTEXT < propName`
1693-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
1694-
/// + `NULL == pPropValue`
1695-
/// + `NULL == pPropSizeRet`
1696-
/// + `propSize != 0 && pPropValue == NULL`
1697-
/// + `pPropValue == NULL && pPropSizeRet == NULL`
16981693
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
16991694
/// + If `propName` is not supported by the adapter.
17001695
/// - ::UR_RESULT_ERROR_INVALID_SIZE
17011696
/// + `propSize == 0 && pPropValue != NULL`
17021697
/// + If `propSize` is less than the real number of bytes needed to return the info.
1698+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
1699+
/// + `propSize != 0 && pPropValue == NULL`
1700+
/// + `pPropValue == NULL && pPropSizeRet == NULL`
17031701
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
17041702
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
17051703
ur_result_t UR_APICALL urUSMPoolGetInfo(
17061704
ur_usm_pool_handle_t hPool, ///< [in] handle of the USM memory pool
17071705
ur_usm_pool_info_t propName, ///< [in] name of the pool property to query
17081706
size_t propSize, ///< [in] size in bytes of the pool property value provided
17091707
void *
1710-
pPropValue, ///< [out][typename(propName, propSize)] value of the pool property
1711-
size_t
1712-
*pPropSizeRet ///< [out] size in bytes returned in pool property value
1708+
pPropValue, ///< [out][optional][typename(propName, propSize)] value of the pool
1709+
///< property
1710+
size_t *
1711+
pPropSizeRet ///< [out][optional] size in bytes returned in pool property value
17131712
) {
17141713
ur_result_t result = UR_RESULT_SUCCESS;
17151714
return result;
@@ -3994,10 +3993,9 @@ ur_result_t UR_APICALL urEnqueueMemUnmap(
39943993
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
39953994
/// - ::UR_RESULT_ERROR_INVALID_EVENT
39963995
/// - ::UR_RESULT_ERROR_INVALID_SIZE
3997-
/// + `patternSize == 0`
3996+
/// + `patternSize == 0 || size == 0`
39983997
/// + `patternSize > size`
3999-
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
4000-
/// + `size == 0`
3998+
/// + `(patternSize & (patternSize - 1)) != 0`
40013999
/// + `size % patternSize != 0`
40024000
/// + If `size` is higher than the allocation size of `ptr`
40034001
/// - ::UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST

0 commit comments

Comments
 (0)