History

DecUT_ParseSyntax.cpp: avoid dangling-else warning in if statements

When building with gcc 9.3 or newer it, the following warning is emitted: ``` [141/182] Compiling C++ object 'test/decoder/6757f86@@test_decoder@exe/DecUT_ParseSyntax.cpp.o' ../test/decoder/DecUT_ParseSyntax.cpp: In member function ‘bool DecoderParseSyntaxTest::DecodeBs(const char*, EDecCase)’: ../test/decoder/DecUT_ParseSyntax.cpp:284:11: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else] 284 | else if (eDecCase == ErrorDec) | ^ ../test/decoder/DecUT_ParseSyntax.cpp: In member function ‘bool DecoderParseSyntaxTest::ParseBs(const char*, EDecCase)’: ../test/decoder/DecUT_ParseSyntax.cpp:350:8: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else] 350 | if (eDecCase == CorrectParseOnly) | ^ ../test/decoder/DecUT_ParseSyntax.cpp:357:6: warning: suggest explicit braces to avoid ambiguous ‘else’ [-Wdangling-else] 357 | if (eDecCase == ErrorDec) | ^ ``` These changes add the braces to make the compiler happy and avoid dangling else.

Jordan Petridis committed 6 years ago

Commit e5b72f31 parent 69db7f61 file · +8 −4Browse files

Showing the changes to test/decoder/DecUT_ParseSyntax.cpp (1 of 1 file). Show all

Unified · Split

test/decoder/DecUT_ParseSyntax.cpp+8−4
@@ -279,10 +279,11 @@ bool DecoderParseSyntaxTest::DecodeBs (const char* sFileName, EDecCase eDecCase) · 278 unmodified lines
279279 iRet |= DecodeFrame (pBuf + iBufPos, iSliceSize, m_pData, &m_sBufferInfo, m_pCtx);
280280 iBufPos += iSliceSize;
281281 }
282− if (eDecCase == CorrectDec)
282+ if (eDecCase == CorrectDec) {
283283 EXPECT_TRUE (iRet == dsErrorFree);
284− else if (eDecCase == ErrorDec)
284+ } else if (eDecCase == ErrorDec) {
285285 EXPECT_TRUE ((iRet & (dsBitstreamError | dsRefLost | dsDataErrorConcealed)) != 0) << "iRet = " << iRet;
286+ }
286287
287288 fclose (pH264File);
288289 if (pBuf) {
@@ -347,15 +348,18 @@ bool DecoderParseSyntaxTest::ParseBs (const char* sFileName, EDecCase eDecCase) · 58 unmodified lines
347348 memset (&m_sParserBsInfo, 0, sizeof (SParserBsInfo));
348349 iRet |= m_pDec->DecodeParser (pBuf + iBufPos, iSliceSize, &m_sParserBsInfo);
349350 iRet |= m_pDec->DecodeParser (NULL, 0, &m_sParserBsInfo);
350− if (eDecCase == CorrectParseOnly)
351+ if (eDecCase == CorrectParseOnly) {
351352 EXPECT_TRUE (iRet == dsErrorFree || iRet == dsFramePending);
353+ }
354+
352355 iBufPos += iSliceSize;
353356 ++iSliceIndex;
354357 if (iSliceIndex == 4)
355358 break;
356359 }
357− if (eDecCase == ErrorDec)
360+ if (eDecCase == ErrorDec) {
358361 EXPECT_TRUE ((iRet & (dsBitstreamError | dsRefLost | dsDataErrorConcealed)) != 0) << iRet;
362+ }
359363
360364 fclose (pH264File);
361365 if (pBuf) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t