Skip to content

Commit 1f48b83

Browse files
committed
Minor code review for unusual paths
1 parent 41deaf3 commit 1f48b83

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

DirectXMesh/DirectXMeshClean.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace
2424
_Inout_ std::vector<uint32_t>& dupVerts, bool breakBowties)
2525
{
2626
if (!adjacency && !attributes)
27-
return E_INVALIDARG;
27+
return E_POINTER;
2828

2929
if ((uint64_t(nFaces) * 3) >= UINT32_MAX)
3030
return HRESULT_E_ARITHMETIC_OVERFLOW;

DirectXMesh/DirectXMeshOptimizeTVC.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ namespace
3535
_In_reads_(nFaces * 3) const uint32_t* adjacency,
3636
const std::vector<std::pair<size_t, size_t>>& subsets)
3737
{
38-
if (!indices || !nFaces || !adjacency || subsets.empty())
39-
return E_INVALIDARG;
38+
if (!indices || !adjacency)
39+
return E_POINTER;
4040

4141
// Convert adjacency to 'physical' adjacency
4242
mPhysicalNeighbors.reset(new (std::nothrow) neighborInfo[nFaces]);
@@ -163,15 +163,12 @@ namespace
163163
_In_reads_(nFaces * 3) const index_t* indices, size_t nFaces,
164164
size_t faceOffset, size_t faceCount) noexcept
165165
{
166-
if (!faceCount || !indices || !nFaces)
167-
return E_INVALIDARG;
166+
if (!indices || !mListElements)
167+
return E_POINTER;
168168

169-
if (faceCount > mMaxSubset)
169+
if (!faceCount || faceCount > mMaxSubset)
170170
return E_UNEXPECTED;
171171

172-
if (!mListElements)
173-
return E_POINTER;
174-
175172
if ((uint64_t(faceOffset) + uint64_t(faceCount)) >= UINT32_MAX)
176173
return HRESULT_E_ARITHMETIC_OVERFLOW;
177174

@@ -457,7 +454,7 @@ namespace
457454
HRESULT initialize(uint32_t cacheSize) noexcept
458455
{
459456
if (!cacheSize)
460-
return E_INVALIDARG;
457+
return E_UNEXPECTED;
461458

462459
mFIFO.reset(new (std::nothrow) uint32_t[cacheSize]);
463460
if (!mFIFO)
@@ -514,8 +511,8 @@ namespace
514511
_Out_writes_(nFaces) uint32_t* faceRemap)
515512
{
516513
auto subsets = ComputeSubsets(attributes, nFaces);
517-
518-
assert(!subsets.empty());
514+
if (subsets.empty())
515+
return E_UNEXPECTED;
519516

520517
mesh_status<index_t> status;
521518
HRESULT hr = status.initialize(indices, nFaces, adjacency, subsets);
@@ -592,8 +589,8 @@ namespace
592589
uint32_t vertexCache, uint32_t restart)
593590
{
594591
auto subsets = ComputeSubsets(attributes, nFaces);
595-
596-
assert(!subsets.empty());
592+
if (subsets.empty())
593+
return E_UNEXPECTED;
597594

598595
mesh_status<index_t> status;
599596
HRESULT hr = status.initialize(indices, nFaces, adjacency, subsets);

DirectXMesh/DirectXMeshletGenerator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ namespace
249249
std::vector<InlineMeshlet<T>>& meshlets)
250250
{
251251
if (!indices || !positions || !adjacency)
252-
return E_INVALIDARG;
252+
return E_POINTER;
253253

254254
if (subset.first + subset.second > nFaces)
255255
return E_UNEXPECTED;

0 commit comments

Comments
 (0)