"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Re: track pack file size as off_t and size_t
To:
gameoftrees@openbsd.org
Date:
Sat, 19 Dec 2020 01:44:45 +0100

Download raw body.

Thread
Stefan Sperling:

> With the patch below, we keep separate variables for the on-disk and
> memory-mapped sizes which fixes off_t/size_t confusion in some places.
> Furthermore, we only attempt to map files which will fit into a size_t.

pack.mapsize is oddly redundant.

Whether the file is memory-mapped or not is already given by
pack.map != NULL.  That can be checked directly, rather than
pack.mapsize == 0.

So pack.mapsize is merely a convenient abbreviation for
(size_t)pack.filesize.  But where do you actually need the cast?

Why not use pack.filesize throughout, and just check
pack.filesize < SIZE_MAX before the mmap()?

Storing the size twice in adjacent variables is weird.


BTW, I guess strictly speaking pack.map == 0 may be a valid address,
so I wonder whether MAP_FAILED should be used instead to mark a
non-mapping.

-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de