Skip to content

Commit 5aa8aa5

Browse files
committed
Fix Coverity issue: logically dead code generated in validation layer.
1 parent c7b48b4 commit 5aa8aa5

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
@@ -2891,25 +2891,24 @@ typedef enum ur_usm_pool_info_t {
28912891
/// + `NULL == hPool`
28922892
/// - ::UR_RESULT_ERROR_INVALID_ENUMERATION
28932893
/// + `::UR_USM_POOL_INFO_CONTEXT < propName`
2894-
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
2895-
/// + `NULL == pPropValue`
2896-
/// + `NULL == pPropSizeRet`
2897-
/// + `propSize != 0 && pPropValue == NULL`
2898-
/// + `pPropValue == NULL && pPropSizeRet == NULL`
28992894
/// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION
29002895
/// + If `propName` is not supported by the adapter.
29012896
/// - ::UR_RESULT_ERROR_INVALID_SIZE
29022897
/// + `propSize == 0 && pPropValue != NULL`
29032898
/// + If `propSize` is less than the real number of bytes needed to return the info.
2899+
/// - ::UR_RESULT_ERROR_INVALID_NULL_POINTER
2900+
/// + `propSize != 0 && pPropValue == NULL`
2901+
/// + `pPropValue == NULL && pPropSizeRet == NULL`
29042902
/// - ::UR_RESULT_ERROR_OUT_OF_HOST_MEMORY
29052903
/// - ::UR_RESULT_ERROR_OUT_OF_RESOURCES
29062904
UR_APIEXPORT ur_result_t UR_APICALL
29072905
urUSMPoolGetInfo(
29082906
ur_usm_pool_handle_t hPool, ///< [in] handle of the USM memory pool
29092907
ur_usm_pool_info_t propName, ///< [in] name of the pool property to query
29102908
size_t propSize, ///< [in] size in bytes of the pool property value provided
2911-
void *pPropValue, ///< [out][typename(propName, propSize)] value of the pool property
2912-
size_t *pPropSizeRet ///< [out] size in bytes returned in pool property value
2909+
void *pPropValue, ///< [out][optional][typename(propName, propSize)] value of the pool
2910+
///< property
2911+
size_t *pPropSizeRet ///< [out][optional] size in bytes returned in pool property value
29132912
);
29142913

29152914
#if !defined(__GNUC__)
@@ -5592,10 +5591,9 @@ urEnqueueMemUnmap(
55925591
/// - ::UR_RESULT_ERROR_INVALID_QUEUE
55935592
/// - ::UR_RESULT_ERROR_INVALID_EVENT
55945593
/// - ::UR_RESULT_ERROR_INVALID_SIZE
5595-
/// + `patternSize == 0`
5594+
/// + `patternSize == 0 || size == 0`
55965595
/// + `patternSize > size`
5597-
/// + `patternSize != 0 && ((patternSize & (patternSize - 1)) != 0)`
5598-
/// + `size == 0`
5596+
/// + `(patternSize & (patternSize - 1)) != 0`
55995597
/// + `size % patternSize != 0`
56005598
/// + If `size` is higher than the allocation size of `ptr`
56015599
/// - ::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
@@ -1738,9 +1738,10 @@ __urdlllocal ur_result_t UR_APICALL urUSMPoolGetInfo(
17381738
ur_usm_pool_info_t propName, ///< [in] name of the pool property to query
17391739
size_t propSize, ///< [in] size in bytes of the pool property value provided
17401740
void *
1741-
pPropValue, ///< [out][typename(propName, propSize)] value of the pool property
1742-
size_t
1743-
*pPropSizeRet ///< [out] size in bytes returned in pool property value
1741+
pPropValue, ///< [out][optional][typename(propName, propSize)] value of the pool
1742+
///< property
1743+
size_t *
1744+
pPropSizeRet ///< [out][optional] size in bytes returned in pool property value
17441745
) {
17451746
ur_result_t result = UR_RESULT_SUCCESS;
17461747

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)