$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r82845 - trunk/boost/interprocess/detail
From: igaztanaga_at_[hidden]
Date: 2013-02-12 16:22:24
Author: igaztanaga
Date: 2013-02-12 16:22:23 EST (Tue, 12 Feb 2013)
New Revision: 82845
URL: http://svn.boost.org/trac/boost/changeset/82845
Log:
Use make_unsigned to avoid using signed/unsigned comparisons
Text files modified: 
   trunk/boost/interprocess/detail/os_file_functions.hpp |    16 ++++++++--------                        
   1 files changed, 8 insertions(+), 8 deletions(-)
Modified: trunk/boost/interprocess/detail/os_file_functions.hpp
==============================================================================
--- trunk/boost/interprocess/detail/os_file_functions.hpp	(original)
+++ trunk/boost/interprocess/detail/os_file_functions.hpp	2013-02-12 16:22:23 EST (Tue, 12 Feb 2013)
@@ -19,6 +19,7 @@
 #include <string>
 #include <limits>
 #include <climits>
+#include <boost/type_traits/make_unsigned.hpp>
 
 #if (defined BOOST_INTERPROCESS_WINDOWS)
 #  include <boost/interprocess/detail/win32_api.hpp>
@@ -129,10 +130,10 @@
    if(!winapi::get_file_size(hnd, filesize))
       return false;
 
-   const offset_t max_filesize = (std::numeric_limits<offset_t>::max)();
+   typedef boost::make_unsigned<offset_t>::type uoffset_t;
+   const uoffset_t max_filesize = uoffset_t((std::numeric_limits<offset_t>::max)());
    //Avoid unused variable warnings in 32 bit systems
-   (void)max_filesize;
-   if( sizeof(std::size_t) >= sizeof(offset_t) && size > std::size_t(max_filesize) ){
+   if(size > max_filesize){
       winapi::set_last_error(winapi::error_file_too_large);
       return false;
    }
@@ -449,11 +450,10 @@
 
 inline bool truncate_file (file_handle_t hnd, std::size_t size)
 {
-   if(sizeof(off_t) == sizeof(std::size_t)){
-      if(size > ((~std::size_t(0)) >> 1)){
-         errno = EINVAL;
-         return false;
-      }
+   typedef boost::make_unsigned<off_t>::type uoff_t;
+   if(uoff_t((std::numeric_limits<off_t>::max)()) < size){
+      errno = EINVAL;
+      return false;
    }
    return 0 == ::ftruncate(hnd, off_t(size));
 }