Skip to content

Commit f04f811

Browse files
committed
Trick clang-tidy 21 into not complaining
We know bufSize is 1024 so it fits more than enough in an integer
1 parent f275e2c commit f04f811

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

fofi/FoFiIdentifier.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ bool FileReader::cmp(int pos, const char *s)
179179

180180
bool FileReader::fillBuf(int pos, int len)
181181
{
182-
if (pos < 0 || len < 0 || len > (int)sizeof(buf) || pos > INT_MAX - (int)sizeof(buf)) {
182+
constexpr int bufSize = sizeof(buf);
183+
if (pos < 0 || len < 0 || len > bufSize || pos > INT_MAX - bufSize) {
183184
return false;
184185
}
185186
if (pos >= bufPos && pos + len <= bufPos + bufLen) {
@@ -305,15 +306,16 @@ bool StreamReader::fillBuf(int pos, int len)
305306
{
306307
int c;
307308

308-
if (pos < 0 || len < 0 || len > (int)sizeof(buf) || pos > INT_MAX - (int)sizeof(buf)) {
309+
constexpr int bufSize = sizeof(buf);
310+
if (pos < 0 || len < 0 || len > bufSize || pos > INT_MAX - bufSize) {
309311
return false;
310312
}
311313
if (pos < bufPos) {
312314
return false;
313315
}
314316

315317
// if requested region will not fit in the current buffer...
316-
if (pos + len > bufPos + (int)sizeof(buf)) {
318+
if (pos + len > bufPos + bufSize) {
317319

318320
// if the start of the requested data is already in the buffer, move
319321
// it to the start of the buffer

0 commit comments

Comments
 (0)