From be0442c6207cc10fca079a803bbdd8985959b657 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 11 Sep 2019 06:47:56 -0700 Subject: Avoid C-style casts in C++ --- utils/makemhr/loaddef.cpp | 12 ++++++------ utils/makemhr/loadsofa.cpp | 2 +- utils/sofa-info.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'utils') diff --git a/utils/makemhr/loaddef.cpp b/utils/makemhr/loaddef.cpp index 89893e38..5f6d76d8 100644 --- a/utils/makemhr/loaddef.cpp +++ b/utils/makemhr/loaddef.cpp @@ -1047,7 +1047,7 @@ static int LoadWaveSource(FILE *fp, SourceRefT *src, const uint hrirRate, const // Load a Spatially Oriented Format for Accoustics (SOFA) file. static MYSOFA_EASY* LoadSofaFile(SourceRefT *src, const uint hrirRate, const uint n) { - struct MYSOFA_EASY *sofa{mysofa_cache_lookup(src->mPath, (float)hrirRate)}; + struct MYSOFA_EASY *sofa{mysofa_cache_lookup(src->mPath, static_cast(hrirRate))}; if(sofa) return sofa; sofa = static_cast(calloc(1, sizeof(*sofa))); @@ -1096,7 +1096,7 @@ static MYSOFA_EASY* LoadSofaFile(SourceRefT *src, const uint hrirRate, const uin fprintf(stderr, "\nError: Out of memory.\n"); return nullptr; } - return mysofa_cache_store(sofa, src->mPath, (float)hrirRate); + return mysofa_cache_store(sofa, src->mPath, static_cast(hrirRate)); } // Copies the HRIR data from a particular SOFA measurement. @@ -1532,7 +1532,7 @@ static int ReadSourceRef(TokenReaderT *tr, SourceRefT *src) src->mType = ET_NONE; src->mSize = 0; src->mBits = 0; - src->mChannel = (uint)intVal; + src->mChannel = static_cast(intVal); src->mSkip = 0; } else if(src->mFormat == SF_WAVE) @@ -1666,7 +1666,7 @@ static int ReadSofaRef(TokenReaderT *tr, SourceRefT *src) TrReadOperator(tr, "@"); if(!TrReadInt(tr, 0, 0x7FFFFFFF, &intVal)) return 0; - src->mOffset = (uint)intVal; + src->mOffset = static_cast(intVal); } else src->mOffset = 0; @@ -1834,13 +1834,13 @@ static int ProcessSources(TokenReaderT *tr, HrirDataT *hData) continue; double ef{(90.0 + aer[1]) * (hData->mFds[fi].mEvCount - 1) / 180.0}; - ei = (uint)std::round(ef); + ei = static_cast(std::round(ef)); ef = (ef - ei) * 180.0f / (hData->mFds[fi].mEvCount - 1); if(std::abs(ef) >= 0.1) continue; double af{aer[0] * hData->mFds[fi].mEvs[ei].mAzCount / 360.0f}; - ai = (uint)std::round(af); + ai = static_cast(std::round(af)); af = (af - ai) * 360.0f / hData->mFds[fi].mEvs[ei].mAzCount; ai = ai % hData->mFds[fi].mEvs[ei].mAzCount; if(std::abs(af) >= 0.1) diff --git a/utils/makemhr/loadsofa.cpp b/utils/makemhr/loadsofa.cpp index 7fb169e2..e82376aa 100644 --- a/utils/makemhr/loadsofa.cpp +++ b/utils/makemhr/loadsofa.cpp @@ -221,7 +221,7 @@ static bool PrepareLayout(const uint m, const float *xyzs, HrirDataT *hData) float ev{90.0f + elems[ei]}; float eif{std::round(ev / step)}; - if(std::fabs(eif - (uint)eif) < (0.1f / step)) + if(std::fabs(eif - static_cast(eif)) < (0.1f / step)) { evStart = static_cast(eif); break; diff --git a/utils/sofa-info.cpp b/utils/sofa-info.cpp index 83e3d065..e9f2257c 100644 --- a/utils/sofa-info.cpp +++ b/utils/sofa-info.cpp @@ -242,7 +242,7 @@ static void PrintCompatibleLayout(const uint m, const float *xyzs) float ev{90.0f + elems[ei]}; float eif{std::round(ev / step)}; - if(std::fabs(eif - (uint)eif) < (0.1f / step)) + if(std::fabs(eif - static_cast(eif)) < (0.1f / step)) { evStart = static_cast(eif); break; -- cgit v1.2.3