base: fix -Wtautological-type-limit-compare

Fixes #144
This commit is contained in:
Nigel Tao committed 2024-03-28 16:38:45 +11:00
1 parent f1a9d34494
commit 3bad76cd2c
2 files changed
+18 -8

No files matched your search

+9 -4
View File
@@ -650,15 +650,20 @@ wuffs_base__pixel_config__set(wuffs_base__pixel_config* c,
return;
}
if (pixfmt_repr) {
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
// TODO: handle things other than 1 byte per pixel.
if (wh <= ((uint64_t)SIZE_MAX)) {
do {
#if SIZE_MAX < UINT64_MAX
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
// TODO: handle things other than 1 byte per pixel.
if (wh > ((uint64_t)SIZE_MAX)) {
break;
}
#endif
c->private_impl.pixfmt.repr = pixfmt_repr;
c->private_impl.pixsub.repr = pixsub_repr;
c->private_impl.width = width;
c->private_impl.height = height;
return;
}
} while (0);
}
c->private_impl.pixfmt.repr = 0;
+9 -4
View File
@@ -4598,15 +4598,20 @@ wuffs_base__pixel_config__set(wuffs_base__pixel_config* c,
return;
}
if (pixfmt_repr) {
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
// TODO: handle things other than 1 byte per pixel.
if (wh <= ((uint64_t)SIZE_MAX)) {
do {
#if SIZE_MAX < UINT64_MAX
uint64_t wh = ((uint64_t)width) * ((uint64_t)height);
// TODO: handle things other than 1 byte per pixel.
if (wh > ((uint64_t)SIZE_MAX)) {
break;
}
#endif
c->private_impl.pixfmt.repr = pixfmt_repr;
c->private_impl.pixsub.repr = pixsub_repr;
c->private_impl.width = width;
c->private_impl.height = height;
return;
}
} while (0);
}
c->private_impl.pixfmt.repr = 0;