From 8d2c64140dd18652f32ec47a3f881a1be9a24ae5 Mon Sep 17 00:00:00 2001 From: millert Date: Sun, 14 Aug 2022 14:54:13 +0000 Subject: [PATCH] Use size_t, not off_t, for length parameters. This matches how the functions are called and eliminates a few casts. OK tb@ --- usr.bin/ctfconv/elf.c | 7 ++++--- usr.bin/ctfconv/generate.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/usr.bin/ctfconv/elf.c b/usr.bin/ctfconv/elf.c index ff71223d301..043939afb1a 100644 --- a/usr.bin/ctfconv/elf.c +++ b/usr.bin/ctfconv/elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elf.c,v 1.9 2017/11/14 09:14:50 mpi Exp $ */ +/* $OpenBSD: elf.c,v 1.10 2022/08/14 14:54:13 millert Exp $ */ /* * Copyright (c) 2016 Martin Pieuchot @@ -34,7 +34,7 @@ iself(const char *p, size_t filesize) { Elf_Ehdr *eh = (Elf_Ehdr *)p; - if (filesize < (off_t)sizeof(Elf_Ehdr)) { + if (filesize < sizeof(Elf_Ehdr)) { warnx("file too small to be ELF"); return 0; } @@ -55,7 +55,8 @@ iself(const char *p, size_t filesize) return 0; } if (eh->e_shoff > filesize) { - warnx("bogus section table offset 0x%llx", (off_t)eh->e_shoff); + warnx("bogus section table offset 0x%llx", + (unsigned long long)eh->e_shoff); return 0; } if (eh->e_shentsize < sizeof(Elf_Shdr)) { diff --git a/usr.bin/ctfconv/generate.c b/usr.bin/ctfconv/generate.c index e19094fe231..c2911f59c76 100644 --- a/usr.bin/ctfconv/generate.c +++ b/usr.bin/ctfconv/generate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: generate.c,v 1.4 2017/09/26 08:16:18 mpi Exp $ */ +/* $OpenBSD: generate.c,v 1.5 2022/08/14 14:54:13 millert Exp $ */ /* * Copyright (c) 2017 Martin Pieuchot @@ -67,7 +67,7 @@ struct strentry { }; #ifdef ZLIB -char *data_compress(const char *, size_t, off_t, size_t *); +char *data_compress(const char *, size_t, size_t, size_t *); #endif /* ZLIB */ void @@ -84,7 +84,7 @@ dbuf_realloc(struct dbuf *dbuf, size_t len) void dbuf_copy(struct dbuf *dbuf, void const *data, size_t len) { - off_t left; + size_t left; assert(dbuf->cptr != NULL); assert(dbuf->data != NULL); @@ -94,7 +94,7 @@ dbuf_copy(struct dbuf *dbuf, void const *data, size_t len) return; left = dbuf->size - dbuf->coff; - if (left < (off_t)len) + if (left < len) dbuf_realloc(dbuf, ROUNDUP((len - left), DBUF_CHUNKSZ)); memcpy(dbuf->cptr, data, len); @@ -413,7 +413,7 @@ generate(const char *path, const char *label, int compress) #ifdef ZLIB char * -data_compress(const char *buf, size_t size, off_t len, size_t *pclen) +data_compress(const char *buf, size_t size, size_t len, size_t *pclen) { z_stream stream; char *data; -- 2.20.1