]> OCCT Git - occt.git/commitdiff
// fix a little more warnings CR33669
authordpasukhi <dmitry.pasukhin@opencascade.com>
Sat, 6 Apr 2024 18:09:10 +0000 (18:09 +0000)
committerdpasukhi <dmitry.pasukhin@opencascade.com>
Sat, 6 Apr 2024 18:09:10 +0000 (18:09 +0000)
src/FSD/FSD_CmpFile.cxx
src/FSD/FSD_File.cxx
src/Message/Message_Msg.cxx
src/Message/Message_PrinterOStream.cxx
src/OSD/OSD_File.cxx
src/OSD/OSD_Path.cxx
src/Standard/Standard_Failure.cxx
src/StepFile/StepFile_ReadData.cxx
src/Units/Units_UnitsDictionary.cxx
src/math/math_BissecNewton.cxx
src/math/math_NewtonMinimum.cxx

index 85d76117f1efca7c66935b29fe2e8bd88b031a23..e5fdc3dc3edc316b67a197cc338d784886293ab6 100644 (file)
@@ -69,13 +69,9 @@ Storage_Error FSD_CmpFile::Open(const TCollection_AsciiString& aName, const Stor
   SetName(aName);
 
   if (OpenMode() == Storage_VSNone) {
-    std::ios_base::openmode anOpenMode = std::ios_base::openmode(0);
+    std::ios_base::openmode anOpenMode;
     switch (aMode)
     {
-    case Storage_VSNone:
-    {
-      break;
-    }
     case Storage_VSRead:
     {
       // std::ios::nocreate is not portable
@@ -104,11 +100,13 @@ Storage_Error FSD_CmpFile::Open(const TCollection_AsciiString& aName, const Stor
 #endif
       break;
     }
-    }
-    if (anOpenMode != 0)
+    case Storage_VSNone:
+    default:
     {
-      OSD_OpenStream(myStream, aName, anOpenMode);
+      return Storage_VSOpenError;
+    }
     }
+    OSD_OpenStream(myStream, aName, anOpenMode);
     if (myStream.fail()) {
       result = Storage_VSOpenError;
     }
index 8ee7e2066d51766249ca67e7985bf550c31915d8..325dc8af37733fc8b2e286be5da2e224e86da184 100644 (file)
@@ -51,9 +51,7 @@ FSD_File::FSD_File()
 Storage_Error FSD_File::IsGoodFileType(const TCollection_AsciiString& aName)
 {
   FSD_File      f;
-  Storage_Error s;
-
-  s = f.Open(aName,Storage_VSRead);
+  Storage_Error s = f.Open(aName,Storage_VSRead);
 
   if (s == Storage_VSOk) {
     TCollection_AsciiString l;
@@ -84,13 +82,9 @@ Storage_Error FSD_File::Open(const TCollection_AsciiString& aName,const Storage_
 
   if (OpenMode() == Storage_VSNone)
   {
-    std::ios_base::openmode anOpenMode = std::ios_base::openmode(0);
+    std::ios_base::openmode anOpenMode;
     switch (aMode)
     {
-      case Storage_VSNone:
-      {
-        break;
-      }
       case Storage_VSRead:
       {
         // 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;
         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()) {
       result = Storage_VSOpenError;
     }
@@ -237,7 +233,7 @@ void FSD_File::WriteExtendedLine(const TCollection_ExtendedString& buffer)
 void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer)
 {
   char c = '\0';
-  Standard_ExtCharacter i = 0,j,count = 0;
+  Standard_ExtCharacter i = 0,count = 0;
   Standard_Boolean fin = Standard_False;
   Standard_CString tg = ENDOFNORMALEXTENDEDSECTION;
  
@@ -249,7 +245,6 @@ void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer)
     if (c == tg[count]) count++;
     else count = 0;
     if (count < SIZEOFNORMALEXTENDEDSECTION) {
-      j = 0;
       i = (Standard_ExtCharacter)c;
       if (c == '\0') fin = Standard_True;
       i = (i << 8);
@@ -258,7 +253,7 @@ void FSD_File::ReadExtendedLine(TCollection_ExtendedString& buffer)
       if (c == tg[count]) count++;
       else count = 0;
       if (count < SIZEOFNORMALEXTENDEDSECTION) {
-       j = (Standard_ExtCharacter)c;
+       Standard_ExtCharacter j = (Standard_ExtCharacter)c;
        if (c != '\n') {
          fin = Standard_False;
          i |= (0x00FF & j);
index ade83fe1ff3dea6dfb18efadb2ada857d32d702a..aa4f686e9ec8eb9134fb47f46814c3ae7489862f 100644 (file)
@@ -138,7 +138,6 @@ void Message_Msg::Set (const TCollection_ExtendedString& theMsg)
         aFormatType = Msg_StringType;
         break;
       default:
-        aFormatType = Msg_IndefiniteType;
         continue;
       }
       mySeqOfFormats.Append (Standard_Integer(aFormatType));  // type
index ee53f8187ac6c0cc02793a7ca1a117876c575543..02b030785db1949150450bd0c2cbaa495aadff39 100644 (file)
@@ -223,7 +223,7 @@ void Message_PrinterOStream::SetConsoleTextColor (Standard_OStream* theOStream,
     return;
   }
 
-  const char* aCode = "\e[0m";
+  const char* aCode;
   switch (theTextColor)
   {
     case Message_ConsoleColor_Default:
index db63054d1d0cc48b68296bd10a99f8014089761c..1518a3b0c984dd49b064f6327ec4d14431c87e5d 100644 (file)
@@ -459,7 +459,7 @@ void OSD_File::Build (const OSD_OpenMode theMode,
     throw Standard_ProgramError ("OSD_File::Build(): no name was given");
   }
 
-  const char* anFDOpenMode = "r";
+  const char* anFDOpenMode;
   Standard_Integer anOpenMode = O_CREAT | O_TRUNC;
   switch (theMode)
   {
@@ -622,7 +622,7 @@ void OSD_File::Open (const OSD_OpenMode theMode,
     throw Standard_ProgramError ("OSD_File::Open(): no name was given");
   }
 
-  const char* anFDOpenMode = "r";
+  const char* anFDOpenMode;
   Standard_Integer anOpenMode = 0;
   switch (theMode)
   {
index e034e9e91dab0f1b5b7603cf6ab0f73f11d1be21..ec46e036477d9b8a221a2c80e6d7834c7ad133fc 100644 (file)
@@ -1521,7 +1521,6 @@ TCollection_AsciiString OSD_Path::RelativePath(
   TCollection_AsciiString EmptyString = "" ;
   TCollection_AsciiString FilePath ;
   Standard_Integer len ;
-  Standard_Integer i, n ;
   Standard_Boolean Wnt = 0 ;
 
   FilePath = aAbsFilePath ;
@@ -1554,14 +1553,14 @@ TCollection_AsciiString OSD_Path::RelativePath(
   TCollection_AsciiString DirToken, FileToken ;
   Standard_Boolean Sibling = 0 ;
 
-  for (i = n = 1 ;; n++) {
+  for (Standard_Integer n = 1 ;; n++) {
       DirToken = aDirPath.Token("/\\",n) ;
       if (DirToken.IsEmpty())
           return FilePath ;
 
       if (!Sibling) {
           len = FilePath.Length() ;
-          i = FilePath.Search("/") ;
+          Standard_Integer i = FilePath.Search("/") ;
           if (i > 0) {
               if (i == len)
                   return EmptyString ;
index 002c42a426ae52a4139d803c0933385b5e87988b..cacdd21d6a3bacf6be404de31401b3615d9227be 100644 (file)
@@ -44,10 +44,11 @@ Standard_Failure::StringRef* Standard_Failure::StringRef::allocate_message (cons
   }
 
   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)
   {
-    strcpy ((char* )&aStrPtr->Message[0], theString);
+    strncpy ((char* )&aStrPtr->Message[0], theString, aLen);
+    ((char* )&aStrPtr->Message[0])[aLen] = '\0';
     aStrPtr->Counter = 1;
   }
   return aStrPtr;
@@ -78,7 +79,7 @@ void Standard_Failure::StringRef::deallocate_message (Standard_Failure::StringRe
   {
     if (--theString->Counter == 0)
     {
-      free ((void* )theString);
+      Standard::Free((void* )theString);
     }
   }
 }
index 91d0dd933cba59995d73f094b9ab05a422361f90..95362afd6d2e7840b8e2bff51745c80f91e4663c 100644 (file)
@@ -151,7 +151,8 @@ void StepFile_ReadData::CreateNewText(const char* theNewText, int theLenText)
     strcpy(myResText + (int)strlen(anOldResText), theNewText);
     return;
   }
-  strcpy(myResText, theNewText);
+  strncpy(myResText, theNewText, aLength);
+  myResText[aLength] = '\0';
 }
 
 //=======================================================================
index 05268f9a1e18ba0e20e9e3b3689405df464e07c6..890ff0a0099dbf052da7be02bbed96ed7591fd39 100644 (file)
@@ -298,7 +298,6 @@ void Units_UnitsDictionary::Creates()
       }
 
       if(unit2[0]) {
-        j = 0;
         for(j=1;j<=theunitssequence->Length();j++)
           if(theunitssequence->Value(j) == unit2)break;
 
index 88eecc5a2eaf8f6012ddf1fa436622b39f242ea2..01dc4659f0a5e6ead1ed931701c9d403d5af46d8 100644 (file)
@@ -52,7 +52,7 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
   Standard_Boolean GOOD;
   Standard_Integer j;
   Standard_Real dxold, fh, fl;
-  Standard_Real swap, temp, xh, xl;
+  Standard_Real xh, xl;
   
   GOOD = F.Values(Bound1, fl, df);
   if(!GOOD) {
@@ -83,9 +83,6 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
   else {
     xl = Bound2;
     xh = Bound1;
-    swap = fl;
-    fl = fh;
-    fh = swap;
   }
 //  Modified by Sergey KHROMOV - Wed Jan 22 12:06:49 2003 End
   x = 0.5 * (Bound1 + Bound2);
@@ -112,7 +109,7 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
     else {
       dxold = dx;
       dx = f / df;
-      temp = x;
+      Standard_Real temp = x;
       x -= dx;
       if(temp == x) {
        TheStatus = math_OK;
@@ -133,11 +130,9 @@ void math_BissecNewton::Perform(math_FunctionWithDerivative& F,
     }
     if(f < 0.0) {
       xl = x;
-      fl = f;
     }
     else if(f > 0.0) {
       xh = x;
-      fh = f;
     }
     else {
       TheStatus = math_OK;
index 89ae93f952c2543ad9289322232c990829b68d45..2e06d08ea21e242a8c79b5698f7c31c9e6815547 100644 (file)
@@ -92,7 +92,6 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F,
   math_Vector Point2(1, F.NbVariables());
   math_Vector* precedent = &Point1;
   math_Vector* suivant = &Point2;
-  math_Vector* auxiliaire = precedent;
 
   Standard_Boolean Ok = Standard_True;
   Standard_Integer NbConv = 0, ii, Nreduction;
@@ -234,9 +233,7 @@ void math_NewtonMinimum::Perform(math_MultipleVarFunctionWithHessian& F,
     }
 
     if (VItere <= VPrecedent) {
-       auxiliaire =  precedent;
-       precedent = suivant;
-       suivant = auxiliaire;
+       std::swap(precedent, suivant);
        PreviousMinimum = VPrecedent;
        TheMinimum = VItere;
        Ok = (nbiter < Itermax);