summaryrefslogtreecommitdiff
path: root/libutils/FileMap.cpp
AgeCommit message (Collapse)Author
2020-05-28Fail explicitly on length overflow.Christopher Ferris
Instead of aborting when FileMap::create detects an overflow, detect the overflow directly and fail the call. Bug: 156997193 Test: Ran unit tests, including new unit test that aborted before. Merged-In: Ie49975b8949fd12bbde14346ec9bbb774ef88a51 Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51 (cherry picked from commit 68604b9c29b5bd11e2e2dbb848d6b364bf627d21)
2020-05-07Change call to mmap64.Christopher Ferris
The code was using an off64_t but calling mmap. This caused the code to abort on 32 bit. Add a unit test that would abort on the previous version. Bug: 155662887 Test: New unit test passes. Change-Id: I7a6efbc0d4227403c3d08a08deea56f239382157 Merged-In: I7a6efbc0d4227403c3d08a08deea56f239382157 (cherry picked from commit 7b9f35c9de53352f915c5b5e8eb39dab09356c19)
2019-02-06MappedFile and FileMap should support zero-length mappings.Elliott Hughes
Bug: http://b/119818070 "app crashes when reading asset of zero length" Test: ran tests Change-Id: Idd2ad6f6e72c8e445aff78a460fac96dea41c950
2018-10-05Add noexcept to move constructors and assignment operators.Chih-Hung Hsieh
Bug: 116614593 Test: build with WITH_TIDY=1 Change-Id: I5a7461386946ca623ab509609092aa0ac8418b80
2018-07-16[libutils] Modernize codebase by replacing NULL with nullptrYi Kong
Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I5e89ec8c42151875439d2656475a8739ab9cb7dc
2017-05-11Fix uninitialized member variableRenaud Paquay
The default constructor of FileMap was missing an initializer for the mFileMapping variables. This results in CloseHandle being called with a "random" value, which can cause havoc in Win32 process over time (e.g. in the case of libaapt2_jni.dll, which is loaded in a JVM process). Also, update the code to use "NULL" for invalid file map handle and "INVALID_HANDLE_VALUE" for invalid file handle. Bug: 38197857 Test: Stress testing on (Windows) machine Change-Id: Ibd769219d601fbafcfcee89e848b31cc5137826c
2016-09-22Fix warnings in libutils headersColin Cross
system/core/include is included in the global include path using -isystem, which hides all warnings. Fix warnings in libutils headers in preparation for moving from -isystem to -I. - Fix implicit cast from int64_t to long in Condition.h. Remove the __LP64__ check and always compare against LONG_MAX before casting. - Fix implicit cast from size_t to ssize_t in KeyedVector.h - Fix -Wshadow-field-in-constructor warnings in Looper.h and RefBase.h - Move destructors for MessageHandler and LooperCallback to Looper.cpp and ReferenceRenamer and VirtualLightRefBase to RefBase.cpp to prevent vtables in every compilation unit. - Declare template variables in Singleton.h - Fix old-style casts in StrongPointer.h and TypeHelpers.h - Use template metaprogramming in TypeHelpers.h to avoid warnings on memmove on non-trivial types. - Add an assignment operator to key_value_pair_t to complete rule-of-three - Use memcpy instead of dereferencing a reinterpret_casted pointer to treat the bits of a float or double as int32_t or int64_t - Escape unicode sequences inside doxygen comments between \code and \endcode - Remove WIN32 ZD definition in Compat.h, %zd works fine with mingw - Fix WIN32 printf warnings in Filemap.cpp - Initialize mNullValue with 0 in LruCache.h, some of the tests use a non-pointer type for TValue. Test: m -j native Bug: 31492149 Change-Id: I385a05a3ca01258e44fe3b37ef77e4aaff547b26
2015-10-01Implement C++11 move semantics for android::FileMapAdam Lesinski
FileMaps should be movable, thereby not requiring them to be only used with a unique_ptr as they currently are. Change-Id: I0fb8013bf398a2ced5420d85ba888c2a7fc5a496
2015-02-23Remove useless refCounting from FileMap.Narayan Kamath
Nobody ever called acquire() so release() was always equivalent to delete. Just use delete instead so that people can use unique_ptr directly (or shared_ptr if they really want refcounts). Change-Id: I9e3ad5e0f6a4fcc4e02e5a2ff7ef9514fe234415
2015-02-19Remove reference to NOT_USING_KLIBC and cygwin.Narayan Kamath
The reference to NOT_USING_KLIBC appears to be the only one in our codebase. This change also removes some cygwin specific retry logic - all other supported platforms in this section of the code should support mapping at an offset. Note that i've reversed the sense of the check, we always sysconf since that's recommended practice. Change-Id: Ib985fb665193d7a07a282f7092cd77c0bc508a66
2014-11-19kill HAVE_MADVISEYabin Cui
Change to avoid "unused parameter" warning. Bug: 18397020 Change-Id: I4b26de55314c78237daead8e873385b97cafe4d4
2014-11-18kill HAVE_MADVISEYabin Cui
Bug: 18397020 Change-Id: Ibc8d886d729c51932a403531888214de4e541452
2014-11-11kill HAVE_POSIX_FILEMAPYabin Cui
Bug: 18315579 Change-Id: I0bd5fb946b12cb90e0c9c73a478df41609b8c3e2
2014-10-16Fix windows specific behavior of FileMapXavier Ducrohet
The implementation of the FileMap destructor would close the file, only on Windows, which did not match the behavior on mac/linux. This is because calling munmap does not close the file descriptor. It must be closed separately, before or after munmap. On Windows, the file must also be closed manually, before or after closing the mappingFile. The change basically removes the closing file from the windows-specific part of the destructor, to make behavior more consistent on all platforms where the caller to FileMap is responsible for closing its own file (since FileMap receives an opened file). Change-Id: I5e3cfffbb870d5f3595802ccac57dbc1dbf1ce6e
2014-06-02libutils: turn on -WerrorMark Salyzyn
- Deal with some -Wunused issues - Override PRI macros (windows) - Revert use of PRI macros on off64_t (linux) - Deal with a gnu++11 complaince issue Change-Id: Ie66751293bd84477a5a6dfd8a57e700a16e36964
2014-04-17libutils: FileMap styling adjustmentsMark Salyzyn
Change-Id: I487ebe67a46a7b8f680e722141dd216bbd396f3e
2014-04-17libutils: FileMap 64 bit compile issuesMark Salyzyn
Change-Id: Ie7a0aeb2a7e2d2a90aa2b97c657ea7ec566bf793
2013-08-02move libs/utils to libutilsAlex Ray
Change-Id: I6cf4268599460791414882f91eeb88a992fbd29d