libpalaso icon indicating copy to clipboard operation
libpalaso copied to clipboard

[SIL.Media] Fix 'Cast to same type' code warnings

Open imnasnainaec opened this issue 8 months ago • 2 comments

There are 159 "Cast to same type" code warnings (https://github.com/sillsdev/libpalaso/security/code-scanning?page=7&query=is%3Aopen+branch%3Amaster+rule%3Acs%2Fuseless-cast-to-self), most of them in [SIL.Windows.Forms*], but the 8 that aren't (https://github.com/sillsdev/libpalaso/security/code-scanning/2461 thru https://github.com/sillsdev/libpalaso/security/code-scanning/2468) are in [SIL.Media]. This pr fixes those, with some additional cleanup in the three offending files.


This change is Reviewable

imnasnainaec avatar Apr 25 '25 21:04 imnasnainaec

Palaso Tests

     3 files   -     1       3 suites   - 1   14m 33s :stopwatch: - 3m 44s  4 935 tests ±    0   4 706 :white_check_mark: ±    0  229 :zzz: ± 0  0 :x: ±0  14 272 runs   - 1 785  13 648 :white_check_mark:  - 1 722  624 :zzz:  - 63  0 :x: ±0 

Results for commit ec11db20. ± Comparison against base commit 1ae6a9b6.

:recycle: This comment has been updated with latest results.

github-actions[bot] avatar Apr 25 '25 21:04 github-actions[bot]

SIL.Media/AlsaAudio/AlsaAudioDevice.cs line 535 at r1 (raw file):

			n = (ulong)_bufferSize;
			ulong start_threshold;
			if (_startDelay <= 0)

I realize that this PR is for something else anyway, but since you're changing these lines, what about using either a ternary or:

Code snippet:

start_threshold = (ulong)((double)rate * _startDelay / 1000000);
if (_startDelay <= 0)
    start_threshold += n;

tombogle avatar May 09 '25 21:05 tombogle