On Sat, Apr 25, 2020 at 2:11 PM Peter Kovacs <pe...@apache.org> wrote:
> Hello all, > > I hunt some Warnings and Errors that get logged during build. > > I stumbled over this code here in file_misc.cxx [1]: > > 684 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#684>*static* > > oslFileError > < > http://opengrok.openoffice.org/openoffice/s?defs=oslFileError&project=trunk> > > oslDoMoveFile > < > http://opengrok.openoffice.org/openoffice/s?refs=oslDoMoveFile&project=trunk>( > > *const* sal_Char > <http://opengrok.openoffice.org/openoffice/s?defs=sal_Char&project=trunk>* > > pszPath > <http://opengrok.openoffice.org/openoffice/s?refs=pszPath&project=trunk>, > *const* sal_Char > <http://opengrok.openoffice.org/openoffice/s?defs=sal_Char&project=trunk>* > > pszDestPath > < > http://opengrok.openoffice.org/openoffice/s?refs=pszDestPath&project=trunk>) > > 685 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#685>{ > > 686 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#686>oslFileError > > < > http://opengrok.openoffice.org/openoffice/s?defs=oslFileError&project=trunk> > > tErr > <http://opengrok.openoffice.org/openoffice/s?refs=tErr&project=trunk>=osl_File_E_invalidError > > < > http://opengrok.openoffice.org/openoffice/s?defs=osl_File_E_invalidError&project=trunk>; > > 687 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#687>688 > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#688>tErr > > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk> = > osl_psz_moveFile > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#osl_psz_moveFile>(pszPath > > <http://opengrok.openoffice.org/openoffice/s?defs=pszPath&project=trunk>,pszDestPath > > < > http://opengrok.openoffice.org/openoffice/s?defs=pszDestPath&project=trunk>); > > 689 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#689>*if* > > ( tErr > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk> == > osl_File_E_None > < > http://opengrok.openoffice.org/openoffice/s?defs=osl_File_E_None&project=trunk> > > ) 690 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#690>{ > > 691 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#691>*return* > > tErr > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk>; > 692 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#692>} > > 693 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#693>694 > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#694>*if* > > ( tErr > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk> != > osl_File_E_XDEV > < > http://opengrok.openoffice.org/openoffice/s?defs=osl_File_E_XDEV&project=trunk> > > ) 695 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#695>{ > > 696 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#696>*return* > > tErr > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk>; > 697 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#697>} > > 698 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#698>699 > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#699>tErr > > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk>=osl_psz_copyFile > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#osl_psz_copyFile>(pszPath > > <http://opengrok.openoffice.org/openoffice/s?defs=pszPath&project=trunk>,pszDestPath > > < > http://opengrok.openoffice.org/openoffice/s?defs=pszDestPath&project=trunk>); > > 700 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#700>701 > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#701>*if* > > ( tErr > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk> != > osl_File_E_None > < > http://opengrok.openoffice.org/openoffice/s?defs=osl_File_E_None&project=trunk> > > ) 702 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#702>{ > > 703 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#703>oslFileError > > < > http://opengrok.openoffice.org/openoffice/s?defs=oslFileError&project=trunk> > > tErrRemove > <http://opengrok.openoffice.org/openoffice/s?refs=tErrRemove&project=trunk>; > > 704 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#704>tErrRemove > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#tErrRemove>=osl_psz_removeFile > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#osl_psz_removeFile>(pszDestPath > > < > http://opengrok.openoffice.org/openoffice/s?defs=pszDestPath&project=trunk>); > > 705 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#705>*return* > > tErr > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk>; > 706 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#706>} > > 707 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#707>708 > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#708>tErr > > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk>=osl_psz_removeFile > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#osl_psz_removeFile>(pszPath > > <http://opengrok.openoffice.org/openoffice/s?defs=pszPath&project=trunk>); > > 709 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#709>710 > > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#710>*return* > > tErr > <http://opengrok.openoffice.org/openoffice/s?defs=tErr&project=trunk>; > 711 > < > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx?r=3f12a67e#711 > >} > > Now my understanding is as follows: > > Target: move a file > > Parameter pszPath > <http://opengrok.openoffice.org/openoffice/s?refs=pszPath&project=trunk> > = the file to move > > Parameter pszDestPath > < > http://opengrok.openoffice.org/openoffice/s?refs=pszDestPath&project=trunk> > > = the destination file > > 686 we set Error code to invalid; > > 688 we try to move the file; > > 689 If there is no error > > 691 return, successful move > > 694 if not successful is it this specific error? > > 696 if so return Error message > > Now in all other cases > > 699 try to copy the file > > 701 if the copy is successful > > 704 remove the target > > 705 and send the original error > > ELSE!!!! > > 708 delete the source of the move > > 711 return error > > IMHO Lines 694 to 710 add no value and sound to me like they have a > potential to create harm > > Anyone has an Idea? Do I read the code wrong? > > [1] > http://opengrok.openoffice.org/xref/trunk/main/sal/osl/unx/file_misc.cxx > > 701-706 if the copy was UNSUCCESSFUL, we delete the target, and return the error from the copy. 708 we delete the original because the copy must have succeeded.