1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

// fix a little more warnings

This commit is contained in:
dpasukhi 2024-04-06 18:09:10 +00:00
parent 323aa4abba
commit e1b78718ca
11 changed files with 30 additions and 46 deletions

View File

@ -69,13 +69,9 @@ Storage_Error FSD_CmpFile::Open(const TCollection_AsciiString& aName, const Stor
SetName(aName); SetName(aName);
if (OpenMode() == Storage_VSNone) { if (OpenMode() == Storage_VSNone) {
std::ios_base::openmode anOpenMode = std::ios_base::openmode(0); std::ios_base::openmode anOpenMode;
switch (aMode) switch (aMode)
{ {
case Storage_VSNone:
{
break;
}
case Storage_VSRead: case Storage_VSRead:
{ {
// std::ios::nocreate is not portable // std::ios::nocreate is not portable
@ -104,11 +100,13 @@ Storage_Error FSD_CmpFile::Open(const TCollection_AsciiString& aName, const Stor
#endif #endif
break; break;
} }
} case Storage_VSNone:
if (anOpenMode != 0) default:
{ {
OSD_OpenStream(myStream, aName, anOpenMode); return Storage_VSOpenError;
} }
}
OSD_OpenStream(myStream, aName, anOpenMode);
if (myStream.fail()) { if (myStream.fail()) {
result = Storage_VSOpenError; result = Storage_VSOpenError;
} }

View File

@ -51,9 +51,7 @@ FSD_File::FSD_File()
Storage_Error FSD_File::IsGoodFileType(const TCollection_AsciiString& aName) Storage_Error FSD_File::IsGoodFileType(const TCollection_AsciiString& aName)
{ {
FSD_File f; FSD_File f;
Storage_Error s; Storage_Error s = f.Open(aName,Storage_VSRead);
s = f.Open(aName,Storage_VSRead);
if (s == Storage_VSOk) { if (s == Storage_VSOk) {
TCollection_AsciiString l; TCollection_AsciiString l;
@ -84,13 +82,9 @@ Storage_Error FSD_File::Open(const TCollection_AsciiString& aName,const Storage_
if (OpenMode() == Storage_VSNone) if (OpenMode() == Storage_VSNone)
{ {
std::ios_base::openmode anOpenMode = std::ios_base::openmode(0); std::ios_base::openmode anOpenMode;
switch (aMode) switch (aMode)
{ {
case Storage_VSNone:
{
break;
}
case Storage_VSRead: case Storage_VSRead:
{ {
// std::ios::nocreate is not portable // std::ios::nocreate is not portable
@ -107,11 +101,13 @@ Storage_Error FSD_File::Open(const TCollection_AsciiString& aName,const Storage_
anOpenMode = std::ios::in | std::ios::out; anOpenMode = std::ios::in | std::ios::out;
break; break;
} }
case Storage_VSNone:
default:
{
return Storage_VSOpenError;
}
} }
if (anOpenMode != 0) OSD_OpenStream (myStream, aName.ToCString(), anOpenMode);
{
OSD_OpenStream (myStream, aName.ToCString(), anOpenMode);
}
if (myStream.fail()) { if (myStream.fail()) {
result = Storage_VSOpenError; result = Storage_VSOpenError;
} }
@ -237,7 +233,7 @@ void FSD_File::WriteExtendedLine(const TCollection_ExtendedString& buffer)
void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer) void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer)
{ {
char c = '\0'; char c = '\0';
Standard_ExtCharacter i = 0,j,count = 0; Standard_ExtCharacter i = 0,count = 0;
Standard_Boolean fin = Standard_False; Standard_Boolean fin = Standard_False;
Standard_CString tg = ENDOFNORMALEXTENDEDSECTION; Standard_CString tg = ENDOFNORMALEXTENDEDSECTION;
@ -249,7 +245,6 @@ void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer)
if (c == tg[count]) count++; if (c == tg[count]) count++;
else count = 0; else count = 0;
if (count < SIZEOFNORMALEXTENDEDSECTION) { if (count < SIZEOFNORMALEXTENDEDSECTION) {
j = 0;
i = (Standard_ExtCharacter)c; i = (Standard_ExtCharacter)c;
if (c == '\0') fin = Standard_True; if (c == '\0') fin = Standard_True;
i = (i << 8); i = (i << 8);
@ -258,7 +253,7 @@ void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer)
if (c == tg[count]) count++; if (c == tg[count]) count++;
else count = 0; else count = 0;
if (count < SIZEOFNORMALEXTENDEDSECTION) { if (count < SIZEOFNORMALEXTENDEDSECTION) {
j = (Standard_ExtCharacter)c; Standard_ExtCharacter j = (Standard_ExtCharacter)c;
if (c != '\n') { if (c != '\n') {
fin = Standard_False; fin = Standard_False;
i |= (0x00FF & j); i |= (0x00FF & j);

View File

@ -138,7 +138,6 @@ void Message_Msg::Set (const TCollection_ExtendedString& theMsg)
aFormatType = Msg_StringType; aFormatType = Msg_StringType;
break; break;
default: default:
aFormatType = Msg_IndefiniteType;
continue; continue;
} }
mySeqOfFormats.Append (Standard_Integer(aFormatType)); // type mySeqOfFormats.Append (Standard_Integer(aFormatType)); // type

View File

@ -223,7 +223,7 @@ void Message_PrinterOStream::SetConsoleTextColor (Standard_OStream* theOStream,
return; return;
} }
const char* aCode = "\e[0m"; const char* aCode;
switch (theTextColor) switch (theTextColor)
{ {
case Message_ConsoleColor_Default: case Message_ConsoleColor_Default:

View File

@ -459,7 +459,7 @@ void OSD_File::Build (const OSD_OpenMode theMode,
throw Standard_ProgramError ("OSD_File::Build(): no name was given"); throw Standard_ProgramError ("OSD_File::Build(): no name was given");
} }
const char* anFDOpenMode = "r"; const char* anFDOpenMode;
Standard_Integer anOpenMode = O_CREAT | O_TRUNC; Standard_Integer anOpenMode = O_CREAT | O_TRUNC;
switch (theMode) switch (theMode)
{ {
@ -622,7 +622,7 @@ void OSD_File::Open (const OSD_OpenMode theMode,
throw Standard_ProgramError ("OSD_File::Open(): no name was given"); throw Standard_ProgramError ("OSD_File::Open(): no name was given");
} }
const char* anFDOpenMode = "r"; const char* anFDOpenMode;
Standard_Integer anOpenMode = 0; Standard_Integer anOpenMode = 0;
switch (theMode) switch (theMode)
{ {

View File

@ -1521,7 +1521,6 @@ TCollection_AsciiString OSD_Path::RelativePath(
TCollection_AsciiString EmptyString = "" ; TCollection_AsciiString EmptyString = "" ;
TCollection_AsciiString FilePath ; TCollection_AsciiString FilePath ;
Standard_Integer len ; Standard_Integer len ;
Standard_Integer i, n ;
Standard_Boolean Wnt = 0 ; Standard_Boolean Wnt = 0 ;
FilePath = aAbsFilePath ; FilePath = aAbsFilePath ;
@ -1554,14 +1553,14 @@ TCollection_AsciiString OSD_Path::RelativePath(
TCollection_AsciiString DirToken, FileToken ; TCollection_AsciiString DirToken, FileToken ;
Standard_Boolean Sibling = 0 ; Standard_Boolean Sibling = 0 ;
for (i = n = 1 ;; n++) { for (Standard_Integer n = 1 ;; n++) {
DirToken = aDirPath.Token("/\\",n) ; DirToken = aDirPath.Token("/\\",n) ;
if (DirToken.IsEmpty()) if (DirToken.IsEmpty())
return FilePath ; return FilePath ;
if (!Sibling) { if (!Sibling) {
len = FilePath.Length() ; len = FilePath.Length() ;
i = FilePath.Search("/") ; Standard_Integer i = FilePath.Search("/") ;
if (i > 0) { if (i > 0) {
if (i == len) if (i == len)
return EmptyString ; return EmptyString ;

View File

@ -44,10 +44,11 @@ Standard_Failure::StringRef* Standard_Failure::StringRef::allocate_message (cons
} }
const Standard_Size aLen = strlen (theString); const Standard_Size aLen = strlen (theString);
StringRef* aStrPtr = (StringRef* )malloc (aLen + sizeof(Standard_Integer) + 1); StringRef* aStrPtr = (StringRef* )Standard::AllocateOptimal (aLen + sizeof(Standard_Integer) + 1);
if (aStrPtr != NULL) if (aStrPtr != NULL)
{ {
strcpy ((char* )&aStrPtr->Message[0], theString); strncpy ((char* )&aStrPtr->Message[0], theString, aLen);
((char* )&aStrPtr->Message[0])[aLen] = '\0';
aStrPtr->Counter = 1; aStrPtr->Counter = 1;
} }
return aStrPtr; return aStrPtr;
@ -78,7 +79,7 @@ void Standard_Failure::StringRef::deallocate_message (Standard_Failure::StringRe
{ {
if (--theString->Counter == 0) if (--theString->Counter == 0)
{ {
free ((void* )theString); Standard::Free((void* )theString);
} }
} }
} }

View File

@ -151,7 +151,8 @@ void StepFile_ReadData::CreateNewText(const char* theNewText, int theLenText)
strcpy(myResText + (int)strlen(anOldResText), theNewText); strcpy(myResText + (int)strlen(anOldResText), theNewText);
return; return;
} }
strcpy(myResText, theNewText); strncpy(myResText, theNewText, aLength);
myResText[aLength] = '\0';
} }
//======================================================================= //=======================================================================

View File

@ -298,7 +298,6 @@ void Units_UnitsDictionary::Creates()
} }
if(unit2[0]) { if(unit2[0]) {
j = 0;
for(j=1;j<=theunitssequence->Length();j++) for(j=1;j<=theunitssequence->Length();j++)
if(theunitssequence->Value(j) == unit2)break; if(theunitssequence->Value(j) == unit2)break;

View File

@ -52,7 +52,7 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
Standard_Boolean GOOD; Standard_Boolean GOOD;
Standard_Integer j; Standard_Integer j;
Standard_Real dxold, fh, fl; Standard_Real dxold, fh, fl;
Standard_Real swap, temp, xh, xl; Standard_Real xh, xl;
GOOD = F.Values(Bound1, fl, df); GOOD = F.Values(Bound1, fl, df);
if(!GOOD) { if(!GOOD) {
@ -83,9 +83,6 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
else { else {
xl = Bound2; xl = Bound2;
xh = Bound1; xh = Bound1;
swap = fl;
fl = fh;
fh = swap;
} }
// Modified by Sergey KHROMOV - Wed Jan 22 12:06:49 2003 End // Modified by Sergey KHROMOV - Wed Jan 22 12:06:49 2003 End
x = 0.5 * (Bound1 + Bound2); x = 0.5 * (Bound1 + Bound2);
@ -112,7 +109,7 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
else { else {
dxold = dx; dxold = dx;
dx = f / df; dx = f / df;
temp = x; Standard_Real temp = x;
x -= dx; x -= dx;
if(temp == x) { if(temp == x) {
TheStatus = math_OK; TheStatus = math_OK;
@ -133,11 +130,9 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
} }
if(f < 0.0) { if(f < 0.0) {
xl = x; xl = x;
fl = f;
} }
else if(f > 0.0) { else if(f > 0.0) {
xh = x; xh = x;
fh = f;
} }
else { else {
TheStatus = math_OK; TheStatus = math_OK;

View File

@ -92,7 +92,6 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F,
math_Vector Point2(1, F.NbVariables()); math_Vector Point2(1, F.NbVariables());
math_Vector* precedent = &Point1; math_Vector* precedent = &Point1;
math_Vector* suivant = &Point2; math_Vector* suivant = &Point2;
math_Vector* auxiliaire = precedent;
Standard_Boolean Ok = Standard_True; Standard_Boolean Ok = Standard_True;
Standard_Integer NbConv = 0, ii, Nreduction; Standard_Integer NbConv = 0, ii, Nreduction;
@ -234,9 +233,7 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F,
} }
if (VItere <= VPrecedent) { if (VItere <= VPrecedent) {
auxiliaire = precedent; std::swap(precedent, suivant);
precedent = suivant;
suivant = auxiliaire;
PreviousMinimum = VPrecedent; PreviousMinimum = VPrecedent;
TheMinimum = VItere; TheMinimum = VItere;
Ok = (nbiter < Itermax); Ok = (nbiter < Itermax);