diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-08-23 10:01:35 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2021-08-23 10:01:35 (GMT) |
commit | 4c3b4b2a2b133094b98d27616e7728d99097a57f (patch) | |
tree | f3091f50d9f67873f294f31607b967d09541c63b | |
parent | d0288f61d325f0fca40f7b1284e05378c849a42e (diff) | |
download | tcl-4c3b4b2a2b133094b98d27616e7728d99097a57f.zip tcl-4c3b4b2a2b133094b98d27616e7728d99097a57f.tar.gz tcl-4c3b4b2a2b133094b98d27616e7728d99097a57f.tar.bz2 |
Add FALLTHRU markers, to help GCC emit less false warnings
-rw-r--r-- | generic/regc_lex.c | 4 | ||||
-rw-r--r-- | generic/regcomp.c | 4 | ||||
-rw-r--r-- | generic/tclBasic.c | 2 | ||||
-rw-r--r-- | generic/tclCmdMZ.c | 1 | ||||
-rw-r--r-- | generic/tclDictObj.c | 1 | ||||
-rw-r--r-- | generic/tclInterp.c | 2 | ||||
-rw-r--r-- | generic/tclParse.c | 1 | ||||
-rw-r--r-- | generic/tclPathObj.c | 3 | ||||
-rw-r--r-- | generic/tclProc.c | 6 | ||||
-rw-r--r-- | generic/tclScan.c | 11 | ||||
-rw-r--r-- | generic/tclStrToD.c | 14 | ||||
-rw-r--r-- | generic/tclStringObj.c | 2 | ||||
-rw-r--r-- | unix/tclUnixFile.c | 29 | ||||
-rw-r--r-- | win/tclWinFile.c | 12 | ||||
-rw-r--r-- | win/tclWinTest.c | 2 | ||||
-rw-r--r-- | win/tclWinTime.c | 38 |
16 files changed, 77 insertions, 55 deletions
diff --git a/generic/regc_lex.c b/generic/regc_lex.c index 0cc62a2..992f5fd 100644 --- a/generic/regc_lex.c +++ b/generic/regc_lex.c @@ -909,9 +909,7 @@ lexescape( v->now = save; - /* - * And fall through into octal number. - */ + /* FALLTHRU */ case CHR('0'): NOTE(REG_UUNPORT); diff --git a/generic/regcomp.c b/generic/regcomp.c index fda40e0..1a3e334 100644 --- a/generic/regcomp.c +++ b/generic/regcomp.c @@ -605,7 +605,7 @@ makesearch( break; } } - + /* * We want to mark states as being in the list already by having non * NULL tmp fields, but we can't just store the old slist value in tmp @@ -922,7 +922,7 @@ parseqatom( */ NOTE(REG_UPBOTCH); - /* fallthrough into case PLAIN */ + /* FALLTHRU */ case PLAIN: onechr(v, v->nextvalue, lp, rp); okcolors(v->nfa, v->cm); diff --git a/generic/tclBasic.c b/generic/tclBasic.c index 52e0ce5..e37ef13 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -5586,8 +5586,8 @@ Tcl_ExprLongObj( return TCL_ERROR; } resultPtr = Tcl_NewBignumObj(&big); - /* FALLTHROUGH */ } + /* FALLTHRU */ case TCL_NUMBER_LONG: case TCL_NUMBER_WIDE: case TCL_NUMBER_BIG: diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c index f6bdd3e..0629a81 100644 --- a/generic/tclCmdMZ.c +++ b/generic/tclCmdMZ.c @@ -4267,6 +4267,7 @@ Tcl_TimeRateObjCmd( */ threshold = 1; maxcnt = 0; + /* FALLTHRU */ case TCL_CONTINUE: result = TCL_OK; break; diff --git a/generic/tclDictObj.c b/generic/tclDictObj.c index 4fec2c1..bde8162 100644 --- a/generic/tclDictObj.c +++ b/generic/tclDictObj.c @@ -2772,6 +2772,7 @@ DictFilterCmd( Tcl_ResetResult(interp); Tcl_DictObjDone(&search); + /* FALLTHRU */ case TCL_CONTINUE: result = TCL_OK; break; diff --git a/generic/tclInterp.c b/generic/tclInterp.c index dbbf10a..b00df59 100644 --- a/generic/tclInterp.c +++ b/generic/tclInterp.c @@ -923,6 +923,7 @@ Tcl_InterpObjCmd( return SlaveTimeLimitCmd(interp, slaveInterp, 4, objc, objv); } } + break; case OPT_MARKTRUSTED: { Tcl_Interp *slaveInterp; @@ -2433,6 +2434,7 @@ SlaveObjCmd( return SlaveTimeLimitCmd(interp, slaveInterp, 3, objc, objv); } } + break; case OPT_MARKTRUSTED: if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, NULL); diff --git a/generic/tclParse.c b/generic/tclParse.c index 48d86ef..9c3dbe8 100644 --- a/generic/tclParse.c +++ b/generic/tclParse.c @@ -2160,6 +2160,7 @@ Tcl_SubstObj( return NULL; case TCL_BREAK: tokensLeft = 0; /* Halt substitution */ + /* FALLTHRU */ default: Tcl_AppendObjToObj(result, Tcl_GetObjResult(interp)); } diff --git a/generic/tclPathObj.c b/generic/tclPathObj.c index d8be51a..f97c36a 100644 --- a/generic/tclPathObj.c +++ b/generic/tclPathObj.c @@ -861,7 +861,7 @@ TclJoinPath( Tcl_PathType type; char *strElt, *ptr; Tcl_Obj *driveName = NULL; - + elt = objv[i]; /* @@ -1358,6 +1358,7 @@ TclNewFSPathObj( count = 0; state = 1; } + break; case 1: /* Scanning for next dirsep */ switch (*p) { case '/': diff --git a/generic/tclProc.c b/generic/tclProc.c index 2ee2456..432ee64 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -722,7 +722,7 @@ TclGetFrame( } level = curLevel - level; } else { - /* + /* * (historical, TODO) If name does not contain a level (#0 or 1), * TclGetFrame and Tcl_UpVar2 uses current level - 1 */ @@ -1808,9 +1808,7 @@ TclObjInterpProcCore( "\" outside of a loop", NULL); result = TCL_ERROR; - /* - * Fall through to the TCL_ERROR handling code. - */ + /* FALLTHRU */ case TCL_ERROR: /* diff --git a/generic/tclScan.c b/generic/tclScan.c index 229f3fa..09dffd3 100644 --- a/generic/tclScan.c +++ b/generic/tclScan.c @@ -358,8 +358,10 @@ ValidateFormat( format += Tcl_UtfToUniChar(format, &ch); break; } + /* FALLTHRU */ case 'L': flags |= SCAN_LONGER; + /* FALLTHRU */ case 'h': format += Tcl_UtfToUniChar(format, &ch); } @@ -380,9 +382,7 @@ ValidateFormat( TCL_STATIC); goto error; } - /* - * Fall through! - */ + /* FALLTHRU */ case 'n': case 's': if (flags & (SCAN_LONGER|SCAN_BIG)) { @@ -694,11 +694,10 @@ Tcl_ScanObjCmd( format += Tcl_UtfToUniChar(format, &ch); break; } + /* FALLTHRU */ case 'L': flags |= SCAN_LONGER; - /* - * Fall through so we skip to the next character. - */ + /* FALLTHRU */ case 'h': format += Tcl_UtfToUniChar(format, &ch); } diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c index 3776521..ea73e09 100644 --- a/generic/tclStrToD.c +++ b/generic/tclStrToD.c @@ -801,6 +801,7 @@ TclParseNumber( acceptState = state; acceptPoint = p; acceptLen = len; + /* FALLTHRU */ case ZERO_B: if (c == '0') { numTrailZeros++; @@ -1150,6 +1151,7 @@ TclParseNumber( #endif Tcl_Panic("TclParseNumber: bad acceptState %d parsing '%s'", acceptState, bytes); + break; case BINARY: shift = numTrailZeros; if (!significandOverflow && significandWide != 0 && @@ -1307,9 +1309,9 @@ TclParseNumber( objPtr->typePtr = &tclDoubleType; if (exponentSignum) { - /* + /* * At this point exponent>=0, so the following calculation - * cannot underflow. + * cannot underflow. */ exponent = -exponent; } @@ -1335,7 +1337,7 @@ TclParseNumber( } } - /* + /* * The desired number is now significandWide * 10**exponent * or significandBig * 10**exponent, depending on whether * the significand has overflowed a wide int. @@ -1885,7 +1887,7 @@ RefineApproximation( /* * Compute twoMv as 2*M*v, where v is the approximate value. - * This is done by bit-whacking to calculate 2**(M2+1)*significand, + * This is done by bit-whacking to calculate 2**(M2+1)*significand, * and then multiplying by 5**M5. */ @@ -1920,7 +1922,7 @@ RefineApproximation( } mp_mul_2d(&twoMd, M2+exponent+1, &twoMd); - /* + /* * Now let twoMd = twoMd - twoMv, the difference between the exact and * approximate values. */ @@ -1988,7 +1990,7 @@ RefineApproximation( } } - /* + /* * Reduce the numerator and denominator of the corrector term so that * they will fit in the floating point precision. */ diff --git a/generic/tclStringObj.c b/generic/tclStringObj.c index d62fc72..519afce 100644 --- a/generic/tclStringObj.c +++ b/generic/tclStringObj.c @@ -2077,6 +2077,7 @@ Tcl_AppendFormatToObj( msg = "unsigned bignum format is invalid"; goto errorMsg; } + /* FALLTHRU */ case 'd': case 'o': case 'x': @@ -2651,6 +2652,7 @@ AppendPrintfToObjVA( break; case 'h': size = -1; + /* FALLTHRU */ default: p++; } diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index f2a6b23..5fe7238 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -42,9 +42,11 @@ TclpFindExecutable( Tcl_Encoding encoding; #ifdef __CYGWIN__ int length; - char buf[PATH_MAX * 2]; + wchar_t buf[PATH_MAX] = L""; char name[PATH_MAX * 3 + 1]; - GetModuleFileNameW(NULL, buf, sizeof(buf)/2); + (void)argv0; + + GetModuleFileNameW(NULL, (void *)buf, sizeof(buf)/sizeof(wchar_t)); cygwin_conv_path(3, buf, name, sizeof(name)); length = strlen(name); if ((length > 4) && !strcasecmp(name + length - 4, ".exe")) { @@ -1188,13 +1190,18 @@ TclpUtime( Tcl_Obj *pathPtr, /* File to modify */ struct utimbuf *tval) /* New modification date structure */ { - return utime(Tcl_FSGetNativePath(pathPtr), tval); + return utime((const char *)Tcl_FSGetNativePath(pathPtr), tval); } #ifdef __CYGWIN__ -int TclOSstat(const char *name, void *cygstat) { +int +TclOSstat( + const char *name, + void *cygstat) +{ struct stat buf; - Tcl_StatBuf *statBuf = cygstat; + Tcl_StatBuf *statBuf = (Tcl_StatBuf *)cygstat; int result = stat(name, &buf); + statBuf->st_mode = buf.st_mode; statBuf->st_ino = buf.st_ino; statBuf->st_dev = buf.st_dev; @@ -1208,10 +1215,16 @@ int TclOSstat(const char *name, void *cygstat) { statBuf->st_ctime = buf.st_ctime; return result; } -int TclOSlstat(const char *name, void *cygstat) { + +int +TclOSlstat( + const char *name, + void *cygstat) +{ struct stat buf; - Tcl_StatBuf *statBuf = cygstat; + Tcl_StatBuf *statBuf = (Tcl_StatBuf *)cygstat; int result = lstat(name, &buf); + statBuf->st_mode = buf.st_mode; statBuf->st_ino = buf.st_ino; statBuf->st_dev = buf.st_dev; @@ -1225,7 +1238,7 @@ int TclOSlstat(const char *name, void *cygstat) { statBuf->st_ctime = buf.st_ctime; return result; } -#endif +#endif /* CYGWIN */ /* * Local Variables: diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 32c674c..d3c2e68 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1467,7 +1467,7 @@ TclpGetUserHome( GetProcAddress(handle, "GetProfilesDirectoryW"); Tcl_CreateExitHandler(FreeLoadLibHandle, handle); } - + apistubs = -1; if ( (netUserGetInfoProc != NULL) && (netGetDCNameProc != NULL) && (netApiBufferFreeProc != NULL) && (getProfilesDirectoryProc != NULL) @@ -1492,9 +1492,9 @@ TclpGetUserHome( domain = Tcl_UtfFindFirst(name, '@'); if (domain == NULL) { const char *ptr; - + /* no domain - firstly check it's the current user */ - if ( (ptr = TclpGetUserName(&ds)) != NULL + if ( (ptr = TclpGetUserName(&ds)) != NULL && strcasecmp(name, ptr) == 0 ) { /* try safest and fastest way to get current user home */ @@ -1518,7 +1518,7 @@ TclpGetUserHome( wName = Tcl_UtfToUniCharDString(name, nameLen, &ds); while ((netUserGetInfoProc)(wDomain, wName, 1, (LPBYTE *) &uiPtr) != 0) { - /* + /* * user does not exists - if domain was not specified, * try again using current domain. */ @@ -1634,7 +1634,7 @@ NativeAccess( return 0; } - /* + /* * If it's not a directory (assume file), do several fast checks: */ if (!(attr & FILE_ATTRIBUTE_DIRECTORY)) { @@ -2100,7 +2100,7 @@ NativeStat( */ fileHandle = (tclWinProcs->createFileProc)(nativePath, GENERIC_READ, - FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, NULL); diff --git a/win/tclWinTest.c b/win/tclWinTest.c index 7f49b63..9088f59 100644 --- a/win/tclWinTest.c +++ b/win/tclWinTest.c @@ -671,7 +671,7 @@ TestplatformChmod( */ if (set_readOnly == acl_readOnly_found || setNamedSecurityInfoProc( - (LPSTR) nativePath, SE_FILE_OBJECT, + (LPSTR) nativePath, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION /*| PROTECTED_DACL_SECURITY_INFORMATION*/, NULL, NULL, newAcl, NULL) == ERROR_SUCCESS) { res = 0; diff --git a/win/tclWinTime.c b/win/tclWinTime.c index 1204ec7..e4a6a8a 100644 --- a/win/tclWinTime.c +++ b/win/tclWinTime.c @@ -120,9 +120,10 @@ static TimeInfo timeInfo = { */ static struct { int initialized; /* 1 if initialized, 0 otherwise */ - int perfCounter; /* 1 if performance counter usable for wide clicks */ + int perfCounter; /* 1 if performance counter usable for wide + * clicks */ double microsecsScale; /* Denominator scale between clock / microsecs */ -} wideClick = {0, 0.0}; +} wideClick = {0, 0, 0.0}; /* @@ -257,7 +258,7 @@ TclpGetWideClicks(void) /* * The frequency of the performance counter is fixed at system boot and - * is consistent across all processors. Therefore, the frequency need + * is consistent across all processors. Therefore, the frequency need * only be queried upon application initialization. */ if (QueryPerformanceFrequency(&perfCounterFreq)) { @@ -268,7 +269,7 @@ TclpGetWideClicks(void) wideClick.perfCounter = 0; wideClick.microsecsScale = 1; } - + wideClick.initialized = 1; } if (wideClick.perfCounter) { @@ -289,7 +290,7 @@ TclpGetWideClicks(void) * * TclpWideClickInMicrosec -- * - * This procedure return scale to convert wide click values from the + * This procedure return scale to convert wide click values from the * TclpGetWideClicks native resolution to microsecond resolution * and back. * @@ -328,7 +329,7 @@ TclpWideClickInMicrosec(void) *---------------------------------------------------------------------- */ -Tcl_WideInt +Tcl_WideInt TclpGetMicroseconds(void) { Tcl_WideInt usecSincePosixEpoch; @@ -476,7 +477,7 @@ NativeCalc100NsTicks( LONGLONG curCounterFreq, LONGLONG curCounter ) { - return fileTimeLastCall + + return fileTimeLastCall + ((curCounter - perfCounterLastCall) * 10000000 / curCounterFreq); } @@ -493,7 +494,6 @@ NativeGetMicroseconds(void) if (!timeInfo.initialized) { TclpInitLock(); if (!timeInfo.initialized) { - timeInfo.posixEpoch.LowPart = 0xD53E8000; timeInfo.posixEpoch.HighPart = 0x019DB1DE; @@ -624,8 +624,12 @@ NativeGetMicroseconds(void) /* * If calibration cycle occurred after we get curCounter */ + if (curCounter.QuadPart <= perfCounterLastCall) { - /* Calibrated file-time is saved from posix in 100-ns ticks */ + /* + * Calibrated file-time is saved from posix in 100-ns ticks + */ + return fileTimeLastCall / 10; } @@ -1127,7 +1131,6 @@ CalibrationThread( UpdateTimeEachSecond(); } - /* lint */ return (DWORD) 0; } @@ -1158,7 +1161,8 @@ UpdateTimeEachSecond(void) /* Current value returned from * QueryPerformanceCounter. */ FILETIME curSysTime; /* Current system time. */ - static LARGE_INTEGER lastFileTime; /* File time of the previous calibration */ + static LARGE_INTEGER lastFileTime; + /* File time of the previous calibration */ LARGE_INTEGER curFileTime; /* File time at the time this callback was * scheduled. */ Tcl_WideInt estFreq; /* Estimated perf counter frequency. */ @@ -1186,7 +1190,7 @@ UpdateTimeEachSecond(void) return; } QueryPerformanceCounter(&curPerfCounter); - + lastFileTime.QuadPart = curFileTime.QuadPart; /* @@ -1254,7 +1258,7 @@ UpdateTimeEachSecond(void) /* calculate new frequency and estimate drift to the next second */ vt1 = 20000000 + curFileTime.QuadPart; driftFreq = (estFreq * 20000000 / (vt1 - vt0)); - /* + /* * Avoid too large drifts (only half of the current difference), * that allows also be more accurate (aspire to the smallest tdiff), * so then we can prolong calibration interval by tdiff < 100000 @@ -1262,13 +1266,13 @@ UpdateTimeEachSecond(void) driftFreq = timeInfo.curCounterFreq.QuadPart + (driftFreq - timeInfo.curCounterFreq.QuadPart) / 2; - /* + /* * Average between estimated, 2 current and 5 drifted frequencies, * (do the soft drifting as possible) */ estFreq = (estFreq + 2 * timeInfo.curCounterFreq.QuadPart + 5 * driftFreq) / 8; } - + /* Avoid too large discrepancy from nominal frequency */ if (estFreq > 1003*timeInfo.nominalFreq.QuadPart/1000) { estFreq = 1003*timeInfo.nominalFreq.QuadPart/1000; @@ -1277,9 +1281,9 @@ UpdateTimeEachSecond(void) estFreq = 997*timeInfo.nominalFreq.QuadPart/1000; vt0 = curFileTime.QuadPart; } else if (vt0 != curFileTime.QuadPart) { - /* + /* * Be sure the clock ticks never backwards (avoid it by negative drifting) - * just compare native time (in 100-ns) before and hereafter using + * just compare native time (in 100-ns) before and hereafter using * new calibrated values) and do a small adjustment (short time freeze) */ LARGE_INTEGER newPerfCounter; |