aboutsummaryrefslogtreecommitdiff
path: root/tiffer.h
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2023-06-23 13:34:59 +0200
committerPřemysl Eric Janouch <p@janouch.name>2023-06-23 13:56:32 +0200
commit4f57070e272f506731557b35b484429a968c7dd2 (patch)
tree7e9502ad265f58e07c46c3a124b0d13755c7bf92 /tiffer.h
parent2dc4e9c13b33ae38099f159a9fd87b4c8ea31978 (diff)
downloadfiv-4f57070e272f506731557b35b484429a968c7dd2.tar.gz
fiv-4f57070e272f506731557b35b484429a968c7dd2.tar.xz
fiv-4f57070e272f506731557b35b484429a968c7dd2.zip
Fix 32-bit build warnings
Diffstat (limited to 'tiffer.h')
-rw-r--r--tiffer.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/tiffer.h b/tiffer.h
index b4e582e..870ad26 100644
--- a/tiffer.h
+++ b/tiffer.h
@@ -156,12 +156,18 @@ tiffer_next_ifd(struct tiffer *self)
return tiffer_u16(self, &self->remaining_fields);
}
+static size_t
+tiffer_length(const struct tiffer *self)
+{
+ return self->begin > self->end ? 0 : self->end - self->begin;
+}
+
/// Initialize a derived TIFF reader for a subIFD at the given location.
static bool
tiffer_subifd(
const struct tiffer *self, uint32_t offset, struct tiffer *subreader)
{
- if (self->begin > self->end || self->end - self->begin < offset)
+ if (tiffer_length(self) < offset)
return false;
*subreader = *self;
@@ -332,7 +338,7 @@ tiffer_next_entry(struct tiffer *self, struct tiffer_entry *entry)
if (values_size <= sizeof offset) {
entry->p = self->p;
self->p += sizeof offset;
- } else if (tiffer_u32(self, &offset) && self->end - self->begin >= offset) {
+ } else if (tiffer_u32(self, &offset) && tiffer_length(self) >= offset) {
entry->p = self->begin + offset;
} else {
return false;