• Catalin Iacob's avatar
    Initialize m_hFile in FileMapping constructor. · 6776cb6f
    Catalin Iacob yazdı
    GCC gives the following warning which breaks compilation when using --enable-werror:
    lockbyte.cxx: In function 'storeError store::FileLockBytes_createInstance(rtl::Reference<store::ILockBytes>&, rtl_uString*, storeAccessMode)':
    lockbyte.css:512:37: error: 'prephitmp.221' may be used uninitialized in this function [-Werror=uninitialized]
    lockbyte.cxx:906:1: note: 'prephitmp.221' was declared here
    
    It's not clear from GCC's message, but what it warns about is
    FileMapping::m_hFile. This is because of the following sequence:
    * xMapping.release() makes xMapping.m_value be a default constructed
      FileMapping
    * the xMapping local variable in store::FileLockBytes_createInstance
      gets destructed
    * ~ResourceHolder() calls ResourceHolder::reset
    * ResourceHolder::reset() calls FileMapping::UnmapFile::operator()
      passing m_value as rMapping
    * FileMapping::UnmapFile::operator() uses rMapping.m_hFile but
      rMapping is a default constructed FileMapping and therefore has
      m_hFile uninitialized
    
    Signed-off-by: Stephan Bergmann <sbergman@redhat.com>:
    To me, this looks more like a compiler error.  Also note that
    ResourceHolder::reset only calls FileMapping::UnmapFile::operator() if tmp !=
    value, which is not the case here, as both tmp and value are default-
    constructed.  And FileMapping::operator!= is carefule not to use the potentially
    uninitialized m_hFile.  But always intiializing m_hFile is probably not a bad
    idea, anyway.  And if it helps a certain compiler, all the better.
    6776cb6f
Adı
Son kayıt (commit)
Son güncelleme
..
inc Loading commit data...
prj Loading commit data...
source Loading commit data...
util Loading commit data...
workben Loading commit data...
README Loading commit data...
version.mk Loading commit data...