[PATCH] D38132: [Support] mapped_file_region: avoid tautological comparison.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 07:23:26 PDT 2017


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





More information about the llvm-commits mailing list