Skip to content

Commit

Permalink
Fix some more type mismatches with std::{min,max}
Browse files Browse the repository at this point in the history
  • Loading branch information
Midar committed Nov 7, 2015
1 parent 6c4cca3 commit d8548e0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/add-ons/kernel/bus_managers/ata/ATATracing.cpp
Expand Up @@ -23,7 +23,7 @@ ata_trace_printf(uint32 flags, const char *format, ...)
size_t totalBytes = vsnprintf(sTraceBuffer + sTraceBufferOffset,
sizeof(sTraceBuffer) - sTraceBufferOffset, format, arguments);
sTraceBufferOffset += std::min(totalBytes,
sizeof(sTraceBuffer) - sTraceBufferOffset - 1);
(size_t)(sizeof(sTraceBuffer) - sTraceBufferOffset - 1));
va_end(arguments);
}

Expand Down
7 changes: 4 additions & 3 deletions src/add-ons/kernel/bus_managers/usb/Hub.cpp
Expand Up @@ -417,7 +417,7 @@ Hub::BuildDeviceName(char *string, uint32 *index, size_t bufferSize,
int32 managerIndex = GetStack()->IndexOfBusManager(GetBusManager());
size_t totalBytes = snprintf(string + *index, bufferSize - *index,
"%" B_PRId32, managerIndex);
*index += std::min(totalBytes, bufferSize - *index - 1);
*index += std::min(totalBytes, (size_t)(bufferSize - *index - 1));
}
}

Expand All @@ -426,7 +426,7 @@ Hub::BuildDeviceName(char *string, uint32 *index, size_t bufferSize,
if (*index < bufferSize) {
size_t totalBytes = snprintf(string + *index, bufferSize - *index,
"/hub");
*index += std::min(totalBytes, bufferSize - *index - 1);
*index += std::min(totalBytes, (size_t)(bufferSize - *index - 1));
}
} else {
// find out where the requested device sitts
Expand All @@ -435,7 +435,8 @@ Hub::BuildDeviceName(char *string, uint32 *index, size_t bufferSize,
if (*index < bufferSize) {
size_t totalBytes = snprintf(string + *index,
bufferSize - *index, "/%" B_PRId32, i);
*index += std::min(totalBytes, bufferSize - *index - 1);
*index += std::min(totalBytes,
(size_t)(bufferSize - *index - 1));
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/system/kernel/debug/debug.cpp
Expand Up @@ -1986,7 +1986,7 @@ debug_strlcpy(team_id teamID, char* to, const char* from, size_t size)
return B_BAD_ADDRESS;

// limit size to avoid address overflows
size_t maxSize = std::min(size,
size_t maxSize = std::min((addr_t)size,
~(addr_t)0 - std::max((addr_t)from, (addr_t)to) + 1);
// NOTE: Since strlcpy() determines the length of \a from, the source
// address might still overflow.
Expand Down
2 changes: 1 addition & 1 deletion src/system/kernel/vm/vm.cpp
Expand Up @@ -5316,7 +5316,7 @@ user_strlcpy(char* to, const char* from, size_t size)
return B_BAD_ADDRESS;

// limit size to avoid address overflows
size_t maxSize = std::min(size,
size_t maxSize = std::min((addr_t)size,
~(addr_t)0 - std::max((addr_t)from, (addr_t)to) + 1);
// NOTE: Since arch_cpu_user_strlcpy() determines the length of \a from,
// the source address might still overflow.
Expand Down

0 comments on commit d8548e0

Please sign in to comment.