[PATCH] D38132: [Support] mapped_file_region: avoid tautological comparison.
Zachary Turner via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 07:25:59 PDT 2017
No, I just fail. I somehow thought the check was against the Offset
parameter.
Is changing the function to take a size_t an option?
On Thu, Sep 21, 2017 at 7:23 AM Roman Lebedev via Phabricator <
reviews at reviews.llvm.org> wrote:
> lebedev.ri added a comment.
>
> On Thu, Sep 21, 2017 at 4:56 PM, Zachary Turner <zturner at google.com>
> wrote:
>
> > I would move this logic into the init function.
>
> Do note that the check is comparing length (function param), and not Size
> (class member variable), even thought they currently have the same data
> type.
>
> > But there's another problem. mmap doesn't even accept a size_t, it
> accepts
> > an off_t. Also, as far as I'm aware, off_t is a signed type. So perhaps
> you
> > can compare against std::numeric_limits<off_t>::max() which will never
> be a
> > tautological comparison
>
> Hmm, am i looking in the wrong place?
>
> MMAP(3POSIX)
> POSIX Programmer's Manual
>
> MMAP(3POSIX)
>
> PROLOG
> This manual page is part of the POSIX Programmer's Manual. The
> Linux implementation of this interface may differ (consult the
> corresponding Linux manual page for details of Linux behavior), or the
> interface may not be implemented on Linux.
>
> NAME
> mmap — map pages of memory
>
> SYNOPSIS
> #include <sys/mman.h>
>
> void *mmap(void *addr, size_t len, int prot, int flags,
> int fildes, off_t off);
>
>
>
> MMAP(2)
> Linux Programmer's Manual
>
> MMAP(2)
>
> NAME
> mmap, munmap - map or unmap files or devices into memory
>
> SYNOPSIS
> #include <sys/mman.h>
>
> void *mmap(void *addr, size_t length, int prot, int flags,
> int fd, off_t offset);
> int munmap(void *addr, size_t length);
>
> `mman.h`:
>
> #ifndef __USE_FILE_OFFSET64
> extern void *mmap (void *__addr, size_t __len, int __prot,
> int __flags, int __fd, __off_t __offset) __THROW;
> #else
> # ifdef __REDIRECT_NTH
> extern void * __REDIRECT_NTH (mmap,
> (void *__addr, size_t __len, int __prot,
> int __flags, int __fd, __off64_t __offset),
> mmap64);
> # else
> # define mmap mmap64
> # endif
> #endif
>
>
> Repository:
> rL LLVM
>
> https://reviews.llvm.org/D38132
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170921/0ae1e60c/attachment.html>
More information about the llvm-commits
mailing list