From: rkv Date: Fri, 30 Oct 2015 08:27:41 +0000 (+0300) Subject: 0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FCR26171;p=occt-copy.git 0026171: Coding rules - eliminate -Wshorten-64-to-32 CLang warnings --- diff --git a/src/Bnd/Bnd_BoundSortBox.cxx b/src/Bnd/Bnd_BoundSortBox.cxx index 497ab1dfed..498d015e01 100644 --- a/src/Bnd/Bnd_BoundSortBox.cxx +++ b/src/Bnd/Bnd_BoundSortBox.cxx @@ -152,9 +152,9 @@ public: void AppendAxisY(const Standard_Integer i,const Standard_Integer v); void AppendAxisZ(const Standard_Integer i,const Standard_Integer v); - void Add(long unsigned t) { int o=t&31; int k=t>>5; p[k]|=_P2[o]; } - int Val(long unsigned t) { int o=t&31; int k=t>>5; return(p[k]&_P2[o]); } - void Raz(long unsigned t) { int o=t&31; int k=t>>5; p[k]&= ~(_P2[o]); } + void Add(Standard_Integer t) { int o=t&31; int k=t>>5; p[k]|=_P2[o]; } + unsigned long Val(Standard_Integer t) { int o=t&31; int k=t>>5; return(p[k]&_P2[o]); } +// void Raz(long unsigned t) { int o=t&31; int k=t>>5; p[k]&= ~(_P2[o]); } Standard_Integer NbAxisX(const Standard_Integer i) { return(axisX[0][i]); } Standard_Integer NbAxisY(const Standard_Integer i) { return(axisY[0][i]); } @@ -457,7 +457,7 @@ void Bnd_BoundSortBox::SortBoxes() for (lacaseX=firstcaseX; lacaseX<=lastcaseX; lacaseX++) { for (lacaseY=firstcaseY; lacaseY<=lastcaseY; lacaseY++) { for (lacaseZ=firstcaseZ; lacaseZ<=lastcaseZ; lacaseZ++) { - long unsigned t=Map->GrilleInteger(lacaseX-1,lacaseY-1,lacaseZ-1); + Standard_Integer t=Map->GrilleInteger(lacaseX-1,lacaseY-1,lacaseZ-1); Map->Add(t); } } @@ -578,7 +578,7 @@ void Bnd_BoundSortBox::Add(const Bnd_Box& theBox, for (theGapX=firstGapX; theGapX<=lastGapX; theGapX++) { for (theGapY=firstGapY; theGapY<=lastGapY; theGapY++) { for (theGapZ=firstGapZ; theGapZ<=lastGapZ; theGapZ++) { - long unsigned t=Map->GrilleInteger(theGapX-1,theGapY-1,theGapZ-1); + Standard_Integer t=Map->GrilleInteger(theGapX-1,theGapY-1,theGapZ-1); Map->Add(t); } } @@ -668,7 +668,7 @@ const TColStd_ListOfInteger& Bnd_BoundSortBox::Compare (const Bnd_Box& theBox) for(Standard_Integer i=i0; touch==Standard_False && i<=i1;i++) { for(Standard_Integer j=j0; touch==Standard_False && j<=j1;j++) { for(Standard_Integer k=k0; touch==Standard_False && k<=k1;k++) { - long unsigned t=Map->GrilleInteger(i,j,k); + Standard_Integer t=Map->GrilleInteger(i,j,k); if(Map->Val(t)) { touch = Standard_True; } diff --git a/src/ExprIntrp/lex.ExprIntrp.c b/src/ExprIntrp/lex.ExprIntrp.c index fa1f37beb1..9fda0e9963 100644 --- a/src/ExprIntrp/lex.ExprIntrp.c +++ b/src/ExprIntrp/lex.ExprIntrp.c @@ -2207,7 +2207,7 @@ YY_MALLOC_DECL */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ - if ( (result = read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ + if ( (result = (int)read( fileno(yyin), (char *) buf, max_size )) < 0 ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); #endif @@ -2827,7 +2827,7 @@ static int input() else { /* need more input */ - int offset = yy_c_buf_p - yytext_ptr; + long offset = yy_c_buf_p - yytext_ptr; ++yy_c_buf_p; switch ( yy_get_next_buffer() ) diff --git a/src/FSD/FSD_BinaryFile.cxx b/src/FSD/FSD_BinaryFile.cxx index 70e24b9f21..5d5b2350e5 100644 --- a/src/FSD/FSD_BinaryFile.cxx +++ b/src/FSD/FSD_BinaryFile.cxx @@ -437,7 +437,7 @@ Storage_Error FSD_BinaryFile::BeginWriteInfoSection() myStream)) Storage_StreamWriteError::Raise(); - myHeader.binfo = ftell(myStream); + myHeader.binfo = (Standard_Integer)ftell(myStream); WriteHeader(); return Storage_VSOk; @@ -483,7 +483,7 @@ void FSD_BinaryFile::WriteInfo(const Standard_Integer nbObj, Storage_Error FSD_BinaryFile::EndWriteInfoSection() { - myHeader.einfo = ftell(myStream); + myHeader.einfo = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -565,7 +565,7 @@ Storage_Error FSD_BinaryFile::EndReadInfoSection() Storage_Error FSD_BinaryFile::BeginWriteCommentSection() { - myHeader.bcomment = ftell(myStream); + myHeader.bcomment = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -592,7 +592,7 @@ void FSD_BinaryFile::WriteComment(const TColStd_SequenceOfExtendedString& aCom) Storage_Error FSD_BinaryFile::EndWriteCommentSection() { - myHeader.ecomment = ftell(myStream); + myHeader.ecomment = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -643,7 +643,7 @@ Storage_Error FSD_BinaryFile::EndReadCommentSection() Storage_Error FSD_BinaryFile::BeginWriteTypeSection() { - myHeader.btype = ftell(myStream); + myHeader.btype = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -677,7 +677,7 @@ void FSD_BinaryFile::WriteTypeInformations(const Standard_Integer typeNum, Storage_Error FSD_BinaryFile::EndWriteTypeSection() { - myHeader.etype = ftell(myStream); + myHeader.etype = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -736,7 +736,7 @@ Storage_Error FSD_BinaryFile::EndReadTypeSection() Storage_Error FSD_BinaryFile::BeginWriteRootSection() { - myHeader.broot = ftell(myStream); + myHeader.broot = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -770,7 +770,7 @@ void FSD_BinaryFile::WriteRoot(const TCollection_AsciiString& rootName, const St Storage_Error FSD_BinaryFile::EndWriteRootSection() { - myHeader.eroot = ftell(myStream); + myHeader.eroot = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -830,7 +830,7 @@ Storage_Error FSD_BinaryFile::EndReadRootSection() Storage_Error FSD_BinaryFile::BeginWriteRefSection() { - myHeader.bref = ftell(myStream); + myHeader.bref = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -863,7 +863,7 @@ void FSD_BinaryFile::WriteReferenceType(const Standard_Integer reference,const S Storage_Error FSD_BinaryFile::EndWriteRefSection() { - myHeader.eref = ftell(myStream); + myHeader.eref = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -923,7 +923,7 @@ Storage_Error FSD_BinaryFile::EndReadRefSection() Storage_Error FSD_BinaryFile::BeginWriteDataSection() { - myHeader.bdata = ftell(myStream); + myHeader.bdata = (Standard_Integer)ftell(myStream); return Storage_VSOk; } @@ -983,7 +983,7 @@ void FSD_BinaryFile::EndWritePersistentObjectData() Storage_Error FSD_BinaryFile::EndWriteDataSection() { - myHeader.edata = ftell(myStream); + myHeader.edata = (Standard_Integer)ftell(myStream); fseek(myStream,myHeader.binfo,SEEK_SET); WriteHeader(); diff --git a/src/Font/Font_FTFont.hxx b/src/Font/Font_FTFont.hxx index d7ea03b031..d23811e51f 100755 --- a/src/Font/Font_FTFont.hxx +++ b/src/Font/Font_FTFont.hxx @@ -182,7 +182,7 @@ public: //! @return glyphs number in this font. inline Standard_Integer GlyphsNumber() const { - return myFTFace->num_glyphs; + return (Standard_Integer)myFTFace->num_glyphs; } //! Retrieve glyph bitmap rectangle diff --git a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx index c68e8d5a86..eadd84ab59 100644 --- a/src/IntPatch/IntPatch_PrmPrmIntersection.cxx +++ b/src/IntPatch/IntPatch_PrmPrmIntersection.cxx @@ -3241,7 +3241,7 @@ void IntPatch_PrmPrmIntersection::PointDepart(Handle(IntSurf_LineOn2S)& LineOn2S for(si=-1; si<= 1 && nb::UTF8_BYTES_MINUS_ONE[256] = //! This table contains as many values as there might be trailing bytes //! in a UTF-8 sequence. template -const unsigned long NCollection_UtfIterator::offsetsFromUTF8[6] = +const Standard_Utf32Char NCollection_UtfIterator::offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL, 0x03C82080UL, 0xFA082080UL, 0x82082080UL @@ -90,17 +90,17 @@ inline void NCollection_UtfIterator::readUTF8() } // magic numbers -template const unsigned long NCollection_UtfIterator::UTF8_BYTE_MASK = 0xBF; -template const unsigned long NCollection_UtfIterator::UTF8_BYTE_MARK = 0x80; -template const unsigned long NCollection_UtfIterator::UTF16_SURROGATE_HIGH_START = 0xD800; -template const unsigned long NCollection_UtfIterator::UTF16_SURROGATE_HIGH_END = 0xDBFF; -template const unsigned long NCollection_UtfIterator::UTF16_SURROGATE_LOW_START = 0xDC00; -template const unsigned long NCollection_UtfIterator::UTF16_SURROGATE_LOW_END = 0xDFFF; -template const unsigned long NCollection_UtfIterator::UTF16_SURROGATE_HIGH_SHIFT = 10; -template const unsigned long NCollection_UtfIterator::UTF16_SURROGATE_LOW_BASE = 0x0010000UL; -template const unsigned long NCollection_UtfIterator::UTF16_SURROGATE_LOW_MASK = 0x3FFUL; -template const unsigned long NCollection_UtfIterator::UTF32_MAX_BMP = 0x0000FFFFUL; -template const unsigned long NCollection_UtfIterator::UTF32_MAX_LEGAL = 0x0010FFFFUL; +template const Standard_Utf32Char NCollection_UtfIterator::UTF8_BYTE_MASK = 0xBF; +template const Standard_Utf32Char NCollection_UtfIterator::UTF8_BYTE_MARK = 0x80; +template const Standard_Utf32Char NCollection_UtfIterator::UTF16_SURROGATE_HIGH_START = 0xD800; +template const Standard_Utf32Char NCollection_UtfIterator::UTF16_SURROGATE_HIGH_END = 0xDBFF; +template const Standard_Utf32Char NCollection_UtfIterator::UTF16_SURROGATE_LOW_START = 0xDC00; +template const Standard_Utf32Char NCollection_UtfIterator::UTF16_SURROGATE_LOW_END = 0xDFFF; +template const Standard_Utf32Char NCollection_UtfIterator::UTF16_SURROGATE_HIGH_SHIFT = 10; +template const Standard_Utf32Char NCollection_UtfIterator::UTF16_SURROGATE_LOW_BASE = 0x0010000UL; +template const Standard_Utf32Char NCollection_UtfIterator::UTF16_SURROGATE_LOW_MASK = 0x3FFUL; +template const Standard_Utf32Char NCollection_UtfIterator::UTF32_MAX_BMP = 0x0000FFFFUL; +template const Standard_Utf32Char NCollection_UtfIterator::UTF32_MAX_LEGAL = 0x0010FFFFUL; // ======================================================================= // function : readUTF16 @@ -119,8 +119,8 @@ void NCollection_UtfIterator::readUTF16() if (aChar2 >= UTF16_SURROGATE_LOW_START && aChar2 <= UTF16_SURROGATE_LOW_END) { - aChar = ((aChar - UTF16_SURROGATE_HIGH_START) << UTF16_SURROGATE_HIGH_SHIFT) - + (aChar2 - UTF16_SURROGATE_LOW_START) + UTF16_SURROGATE_LOW_BASE; + aChar = ((aChar - (Standard_Utf32Char)UTF16_SURROGATE_HIGH_START) << (Standard_Utf32Char)UTF16_SURROGATE_HIGH_SHIFT) + + (aChar2 - (Standard_Utf32Char)UTF16_SURROGATE_LOW_START) + (Standard_Utf32Char)UTF16_SURROGATE_LOW_BASE; ++myPosNext; } } diff --git a/src/OSD/OSD_Disk.cxx b/src/OSD/OSD_Disk.cxx index 9125812533..d8dd59e0be 100644 --- a/src/OSD/OSD_Disk.cxx +++ b/src/OSD/OSD_Disk.cxx @@ -71,7 +71,7 @@ Standard_Integer OSD_Disk::DiskSize(){ struct statvfs buffer; if ( statvfs(DiskName.ToCString(),&buffer) == 0 ){ - int BSize512 = buffer.f_frsize / 512 ; + int BSize512 = (int)(buffer.f_frsize / 512) ; return buffer.f_blocks * BSize512 ; } else { @@ -84,7 +84,7 @@ Standard_Integer OSD_Disk::DiskFree(){ struct statvfs buffer; if ( statvfs (DiskName.ToCString(),&buffer) == 0 ){ - int BSize512 = buffer.f_frsize / 512 ; + int BSize512 = (int)(buffer.f_frsize / 512) ; return buffer.f_bavail * BSize512 ; } else { diff --git a/src/OSD/OSD_File.cxx b/src/OSD/OSD_File.cxx index 01e986ed53..5702e5af94 100644 --- a/src/OSD/OSD_File.cxx +++ b/src/OSD/OSD_File.cxx @@ -284,7 +284,6 @@ OSD_File OSD_File::BuildTemporary(){ void OSD_File::Read(TCollection_AsciiString& Buffer, const Standard_Integer Nbyte){ Standard_PCharacter readbuf; - int status; if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) { Standard_ProgramError::Raise("OSD_File::Read : it is a directory"); @@ -304,7 +303,7 @@ void OSD_File::Read(TCollection_AsciiString& Buffer, TCollection_AsciiString transfert(Nbyte,' '); readbuf = (Standard_PCharacter)transfert.ToCString(); - status = read (myFileChannel, readbuf, Nbyte); + ssize_t status = read (myFileChannel, readbuf, Nbyte); // Buffer = transfert; // Copy transfert to Buffer @@ -391,8 +390,6 @@ void OSD_File::Read( Standard_Address& Buffer, const Standard_Integer Nbyte, Standard_Integer& Readbyte) { - int status; - Readbyte = 0; if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) { Standard_ProgramError::Raise("OSD_File::Read : it is a directory"); @@ -412,12 +409,12 @@ void OSD_File::Read( Standard_Address& Buffer, if (Buffer == NULL) Standard_ProgramError::Raise("OSD_File::Read : Buffer is null"); - status = read (myFileChannel, (char*) Buffer, Nbyte); + ssize_t status = read (myFileChannel, (char*) Buffer, Nbyte); if (status == -1) myError.SetValue (errno, Iam, "Read"); else{ if ( status < Nbyte ) myIO = EOF; - Readbyte = status; + Readbyte = (Standard_Integer)status; } } @@ -427,8 +424,6 @@ void OSD_File::Write(const TCollection_AsciiString &Buffer, const Standard_Integer Nbyte){ Standard_CString writebuf; - int status; - if ( OSD_File::KindOfFile ( ) == OSD_DIRECTORY ) { Standard_ProgramError::Raise("OSD_File::Write : it is a directory"); } @@ -446,7 +441,7 @@ void OSD_File::Write(const TCollection_AsciiString &Buffer, writebuf = Buffer.ToCString(); - status = write (myFileChannel, writebuf, Nbyte); + ssize_t status = write (myFileChannel, writebuf, Nbyte); if ( status == -1) myError.SetValue (errno, Iam, "Write"); else @@ -457,9 +452,6 @@ void OSD_File::Write(const TCollection_AsciiString &Buffer, void OSD_File::Write(const Standard_Address Buffer, const Standard_Integer Nbyte) { - - int status; - if (myFileChannel == -1) Standard_ProgramError::Raise("OSD_File::Write : file is not open"); @@ -471,7 +463,7 @@ void OSD_File::Write(const Standard_Address Buffer, if (Nbyte <= 0) Standard_ProgramError::Raise("OSD_File::Write : Nbyte is null"); - status = write (myFileChannel, (const char *)Buffer, Nbyte); + ssize_t status = write (myFileChannel, (const char *)Buffer, Nbyte); if ( status == -1) myError.SetValue (errno, Iam, "Write"); else diff --git a/src/OSD/OSD_FileNode.cxx b/src/OSD/OSD_FileNode.cxx index ebf969456d..b8492f05be 100644 --- a/src/OSD/OSD_FileNode.cxx +++ b/src/OSD/OSD_FileNode.cxx @@ -182,8 +182,8 @@ int static copy_file( const char* src, const char* trg ) const int BUFSIZE=4096; char buf[BUFSIZE]; - int n=0; - while ( ( n = read ( fds, buf, BUFSIZE )) >0 ) + ssize_t n=0; + while ( ( n = (int)read ( fds, buf, BUFSIZE )) >0 ) { if ( write ( fdo, buf, n ) != n ) { // writing error if ( ! errno ) diff --git a/src/Standard/Standard_UUID.hxx b/src/Standard/Standard_UUID.hxx index 9a863ec4c7..5748b4f1ec 100644 --- a/src/Standard/Standard_UUID.hxx +++ b/src/Standard/Standard_UUID.hxx @@ -18,18 +18,17 @@ #include #ifdef _WIN32 -#include + #include #else -typedef struct { - unsigned long Data1 ; - unsigned short Data2 ; - unsigned short Data3 ; - unsigned char Data4[8] ; -} GUID ; + typedef struct + { + unsigned int Data1; + unsigned short Data2; + unsigned short Data3; + unsigned char Data4[8]; + } GUID; #endif -typedef GUID Standard_UUID ; +typedef GUID Standard_UUID; #endif - -