From b8d12a7d12b2f48b6cdaea76f0d91f1ce04e9a32 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Fri, 5 Apr 2024 20:02:36 +0200 Subject: [PATCH] Replace do { while (true) ; with for (;;) --- .../glslang/MachineIndependent/Scan.cpp | 33 +++++++++---------- libretro-common/utils/md5.c | 27 ++++++--------- libretro-common/utils/sha1.c | 4 +-- 3 files changed, 26 insertions(+), 38 deletions(-) diff --git a/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp b/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp index 0464f965fd..f12c7e999b 100755 --- a/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp +++ b/deps/glslang/glslang/glslang/MachineIndependent/Scan.cpp @@ -86,7 +86,7 @@ bool TInputScanner::consumeComment() // a '//' style comment get(); // consume the second '/' c = get(); - do { + for (;;) { while (c != EndOfInput && c != '\\' && c != '\r' && c != '\n') c = get(); @@ -107,19 +107,16 @@ bool TInputScanner::consumeComment() get(); c = get(); } - } while (true); + }; // put back the last non-comment character if (c != EndOfInput) unget(); - - return true; } else if (c == '*') { - // a '/*' style comment get(); // consume the '*' c = get(); - do { + for (;;) { while (c != EndOfInput && c != '*') c = get(); if (c == '*') { @@ -129,21 +126,22 @@ bool TInputScanner::consumeComment() // not end of comment } else // end of input break; - } while (true); - - return true; - } else { + }; + } + else + { // it's not a comment, put the '/' back unget(); return false; } + return true; } // skip whitespace, then skip a comment, rinse, repeat void TInputScanner::consumeWhitespaceComment(bool& foundNonSpaceTab) { - do { + for (;;) { consumeWhiteSpace(foundNonSpaceTab); // if not starting a comment now, then done @@ -153,10 +151,9 @@ void TInputScanner::consumeWhitespaceComment(bool& foundNonSpaceTab) // skip potential comment foundNonSpaceTab = true; - if (! consumeComment()) + if (!consumeComment()) return; - - } while (true); + }; } // Returns true if there was non-white space (e.g., a comment, newline) before the #version @@ -184,7 +181,7 @@ bool TInputScanner::scanVersion(int& version, EProfile& profile, bool& notFirstT bool foundNonSpaceTab = false; bool lookingInMiddle = false; int c; - do { + for (;;) { if (lookingInMiddle) { notFirstToken = true; // make forward progress by finishing off the current line plus extra new lines @@ -273,7 +270,7 @@ bool TInputScanner::scanVersion(int& version, EProfile& profile, bool& notFirstT profile = ECompatibilityProfile; return versionNotFirst; - } while (true); + }; } // Fill this in when doing glslang-level scanning, to hand back to the parser. @@ -723,7 +720,7 @@ void TScanContext::deleteKeywordMap() // Returning 0 implies end of input. int TScanContext::tokenize(TPpContext* pp, TParserToken& token) { - do { + for (;;) { parserToken = &token; TPpToken ppToken; int token = pp->tokenize(ppToken); @@ -818,7 +815,7 @@ int TScanContext::tokenize(TPpContext* pp, TParserToken& token) _parseContext.error(loc, "unexpected token", buf, ""); break; } - } while (true); + }; } int TScanContext::tokenizeIdentifier() diff --git a/libretro-common/utils/md5.c b/libretro-common/utils/md5.c index 5deb03ce5b..50f5d30eaf 100644 --- a/libretro-common/utils/md5.c +++ b/libretro-common/utils/md5.c @@ -89,16 +89,12 @@ */ static const void *MD5_body(MD5_CTX *ctx, const void *data, unsigned long size) { - const unsigned char *ptr; - MD5_u32plus a, b, c, d; MD5_u32plus saved_a, saved_b, saved_c, saved_d; - - ptr = (const unsigned char *)data; - - a = ctx->a; - b = ctx->b; - c = ctx->c; - d = ctx->d; + const unsigned char *ptr = (const unsigned char *)data; + MD5_u32plus a = ctx->a; + MD5_u32plus b = ctx->b; + MD5_u32plus c = ctx->c; + MD5_u32plus d = ctx->d; do { saved_a = a; @@ -207,10 +203,8 @@ void MD5_Init(MD5_CTX *ctx) void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) { - MD5_u32plus saved_lo; - unsigned long used, available; - - saved_lo = ctx->lo; + unsigned long used; + MD5_u32plus saved_lo = ctx->lo; if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) ctx->hi++; ctx->hi += size >> 29; @@ -219,7 +213,7 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) if (used) { - available = 64 - used; + unsigned long available = 64 - used; if (size < available) { @@ -244,9 +238,8 @@ void MD5_Update(MD5_CTX *ctx, const void *data, unsigned long size) void MD5_Final(unsigned char *result, MD5_CTX *ctx) { - unsigned long used, available; - - used = ctx->lo & 0x3f; + unsigned long available; + unsigned long used = ctx->lo & 0x3f; ctx->buffer[used++] = 0x80; diff --git a/libretro-common/utils/sha1.c b/libretro-common/utils/sha1.c index 3c743cb857..7cb37b3db1 100644 --- a/libretro-common/utils/sha1.c +++ b/libretro-common/utils/sha1.c @@ -226,11 +226,9 @@ void SHA1Input( SHA1Context *context, context->Length_High++; /* Force it to 32 bits */ context->Length_High &= 0xFFFFFFFF; + /* Message is too long */ if (context->Length_High == 0) - { - /* Message is too long */ context->Corrupted = 1; - } } if (context->Message_Block_Index == 64)