Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CodeQL warnings #4348

Merged
merged 1 commit into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public static void increaseMasterVolume(@ParamDoc(name = "percent") final float
if (newVolume - volume < .01) {
// the getMasterVolume() may only returns integers, so we have to make sure that we
// increase the volume level at least by 1%.
newVolume += .01;
newVolume += .01f;
}
if (newVolume > 1) {
newVolume = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected boolean waitFor(BooleanSupplier condition) {
* @return true on success, false on timeout
*/
protected boolean waitFor(BooleanSupplier condition, long timeout, long sleepTime) {
int waitingTime = 0;
long waitingTime = 0;
boolean rv;
while (!(rv = condition.getAsBoolean()) && waitingTime < timeout) {
waitingTime += sleepTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ public int read(byte @Nullable [] b, int off, int len) throws IOException {

@Override
public long skip(long n) throws IOException {
offset += n;
if (n > Integer.MAX_VALUE || n < Integer.MIN_VALUE) {
throw new IOException("Invalid offset, exceeds Integer range");
}
offset += (int) n;
return n;
}

Expand All @@ -103,7 +106,7 @@ public void close() throws IOException {
}

public long length() {
Long totalSize = cacheEntry.getTotalSize();
long totalSize = cacheEntry.getTotalSize();
if (totalSize > 0L) {
return totalSize;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ protected void setCacheContext(Path cacheDirectory, Storage<V> storage) {
*
* @return
*/
protected Long getTotalSize() {
protected long getTotalSize() {
if (completed) { // we already know the total size of the sound
return currentSize;
} else {
Expand Down Expand Up @@ -323,7 +323,9 @@ protected int availableFrom(int offset) {
return 0;
}
try {
return Math.max(0, Long.valueOf(fileChannelLocal.size() - offset).intValue());
long nBytes = Math.min(Integer.MAX_VALUE, Math.max(0, fileChannelLocal.size() - offset));
// nBytes is for sure in integer range, safe to cast
return (int) nBytes;
} catch (IOException e) {
logger.debug("Cannot get file length for cache file {}", key);
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ protected boolean waitFor(BooleanSupplier condition) {
* @return true on success, false on timeout
*/
protected boolean waitFor(BooleanSupplier condition, long timeout, long sleepTime) {
int waitingTime = 0;
long waitingTime = 0;
boolean rv;
while (!(rv = condition.getAsBoolean()) && waitingTime < timeout) {
waitingTime += sleepTime;
Expand Down