Skip to content

Commit fd5b2c5

Browse files
committed
Avoid force-casting inputs when calling std::min()
1 parent cf977b7 commit fd5b2c5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

storage/kvstore/source/TDBStore.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ int TDBStore::erase_erase_unit(uint8_t area, uint32_t offset)
196196
void TDBStore::calc_area_params()
197197
{
198198
// TDBStore can't exceed 32 bits
199-
bd_size_t bd_size = std::min(_bd->size(), (bd_size_t) 0x80000000L);
199+
bd_size_t bd_size = std::min<bd_size_t>(_bd->size(), 0x80000000L);
200200

201201
memset(_area_params, 0, sizeof(_area_params));
202202
size_t area_0_size = 0;
@@ -293,7 +293,7 @@ int TDBStore::read_record(uint8_t area, uint32_t offset, char *key,
293293
return MBED_ERROR_INVALID_SIZE;
294294
}
295295

296-
actual_data_size = std::min((size_t)data_buf_size, (size_t)data_size - data_offset);
296+
actual_data_size = std::min<size_t>(data_buf_size, data_size - data_offset);
297297

298298
if (copy_data && actual_data_size && !data_buf) {
299299
return MBED_ERROR_INVALID_ARGUMENT;
@@ -327,7 +327,7 @@ int TDBStore::read_record(uint8_t area, uint32_t offset, char *key,
327327
user_key_ptr[key_size] = '\0';
328328
} else {
329329
dest_buf = _work_buf;
330-
chunk_size = std::min(key_size, _work_buf_size);
330+
chunk_size = std::min<size_t>(key_size, _work_buf_size);
331331
}
332332
} else {
333333
// This means that we're on the data part
@@ -860,7 +860,7 @@ int TDBStore::copy_record(uint8_t from_area, uint32_t from_offset, uint32_t to_o
860860
total_size -= chunk_size;
861861

862862
while (total_size) {
863-
chunk_size = std::min(total_size, _work_buf_size);
863+
chunk_size = std::min<size_t>(total_size, _work_buf_size);
864864
ret = read_area(from_area, from_offset, chunk_size, _work_buf);
865865
if (ret) {
866866
return ret;

0 commit comments

Comments
 (0)