]> OCCT Git - occt-copy.git/commitdiff
0032495: Coding rules - eliminate CLang UndefinedBehaviorSanitizer warnings
authorkgv <kgv@opencascade.com>
Wed, 28 Jul 2021 06:32:34 +0000 (09:32 +0300)
committermkrylova <mkrylova@opencascade.com>
Mon, 2 Aug 2021 09:23:57 +0000 (12:23 +0300)
src/AdvApp2Var/AdvApp2Var_SysBase.cxx
src/NCollection/NCollection_Array1.hxx

index ec648a0779ade994e9e29f5795bfa589253d0b82..688eb49998b820b4bb9f3b51bab480f2243257b0 100644 (file)
@@ -115,9 +115,9 @@ int mcrgetv_(integer *sz,
             intptr_t *iad,
             integer *ier);
 
-static
+/*static
 int mcrlocv_(void* t,
-            intptr_t *l);
+            intptr_t *l);*/
 
 
 static struct {
@@ -383,9 +383,9 @@ int AdvApp2Var_SysBase::macrchk_()
   
   /* Local variables */
   integer  i__, j;
-  intptr_t ioff;
-  doublereal* t = 0;
-  intptr_t loc;
+  //intptr_t ioff;
+  //doublereal* t = NULL;
+  //intptr_t loc = 0;
   
 /* ***********************************************************************
  */
@@ -470,7 +470,7 @@ int AdvApp2Var_SysBase::macrchk_()
  */
 
 /* CALCULATE ADDRESS OF T */
-  mcrlocv_(t, &loc);  
+  //loc = reinterpret_cast<intptr_t> (t); // mcrlocv_
   /* CONTROL OF FLAGS IN THE TABLE */
   i__1 = mcrgene_.ncore;
   for (i__ = 0; i__ < i__1; ++i__) {
@@ -481,10 +481,10 @@ int AdvApp2Var_SysBase::macrchk_()
       intptr_t* pp = p + j;
       if (*pp != -1) {
        
-       ioff = (*pp - loc) / 8;
+       double* t = reinterpret_cast<double*>(*pp); //ioff = (*pp - loc) / 8;
        
-       if (t[ioff] != -134744073.) {
-         
+       if (*t != -134744073.) //if (t[ioff] != -134744073.)
+       {
          /* MSG : '*** ERREUR  : REMOVAL FROM MEMORY OF ADDRESS
             E:',ICORE(J,I) */
          /*       AND OF RANK ICORE(12,I) */
@@ -727,10 +727,10 @@ int macrgfl_(intptr_t *iadfld,
   
   char cbid[1] = {};
   integer ibid, ienr;
-  doublereal* t = 0;
+  //doublereal* t = 0;
   integer novfl = 0;
-  intptr_t ioff,iadt;
-  
+  //intptr_t ioff = 0, iadt = 0;
+
   
   /* ***********************************************************************
    */
@@ -825,26 +825,26 @@ int macrgfl_(intptr_t *iadfld,
   }
   
   /*  CALCULATE THE ADDRESS OF T */
-  mcrlocv_(t, &iadt);
+  //iadt = reinterpret_cast<intptr_t> (t); // mcrlocv_
   
   /* CALCULATE THE OFFSET */
-  ioff = (*iadfld - iadt) / 8;
+  double* t = reinterpret_cast<double*>(*iadfld); //ioff = (*iadfld - iadt) / 8;
   
   /*  SET TO OVERFLOW OF THE USER ZONE IN CASE OF PRODUCTION VERSION */
   if (*iphase == 1 && novfl == 0) {
     ienr = *iznuti / 8;
-    maoverf_(&ienr, &t[ioff + 1]);
+    maoverf_(&ienr, &t[1]); //maoverf_(&ienr, &t[ioff + 1]);
   }
     
   /*  UPDATE THE START FLAG */
-  t[ioff] = -134744073.;
+  *t = -134744073.; //t[ioff] = -134744073.;
   
   /*  FAKE CALL TO STOP THE DEBUGGER : */
   macrbrk_();
   
   /*  UPDATE THE START FLAG */
-  ioff = (*iadflf - iadt) / 8;
-  t[ioff] = -134744073.;
+  t = reinterpret_cast<double*>(*iadflf); //ioff = (*iadflf - iadt) / 8;
+  *t = -134744073.;//t[ioff] = -134744073.;
     
   /*  FAKE CALL TO STOP THE DEBUGGER : */
   macrbrk_();
@@ -2076,7 +2076,7 @@ int mcrcomm_(integer *kop,
        itab[(i__ << 2) - 4] = *noct / 8 + 1;
        itab[(i__ << 2) - 3] = ipre;
        itab[(i__ << 2) - 2] = *noct;
-       mcrlocv_(&dtab[ipre - 1], iadr);
+       *iadr = reinterpret_cast<intptr_t> (&dtab[ipre - 1]); // mcrlocv_
        itab[(i__ << 2) - 1] = *iadr;
        goto L9900;
       }
@@ -2270,7 +2270,7 @@ int AdvApp2Var_SysBase::mcrdelt_(integer *iunit,
 /* SEARCH IN MCRGENE */
 
     n = -1;
-    mcrlocv_(t, &loc);
+    loc = reinterpret_cast<intptr_t> (t); // mcrlocv_
 
     for (i__ = mcrgene_.ncore - 1; i__ >= 0; --i__) {
        if (*iunit == mcrgene_.icore[i__].unit && *isize == 
@@ -2675,13 +2675,13 @@ int AdvApp2Var_SysBase::mcrlist_(integer *ier) const
 //function : mcrlocv_
 //purpose  : 
 //=======================================================================
-int mcrlocv_(void* t,
+/*int mcrlocv_(void* t,
             intptr_t *l)
 
 {
   *l = reinterpret_cast<intptr_t> (t);
   return 0 ;
-}
+}*/
 
 //=======================================================================
 //function : AdvApp2Var_SysBase::mcrrqst_
@@ -2888,7 +2888,7 @@ int AdvApp2Var_SysBase::mcrrqst_(integer *iunit,
 /*     . add delta for alinement with the base */
 /*     . round to multiple of 8 above */
 
-  mcrlocv_(t, &loc);
+  loc = reinterpret_cast<intptr_t> (t); // mcrlocv_
     izu = ibyte + loc % *iunit;
     irest = izu % 8;
     if (irest != 0) {
index ce020eb0351515467d4ad19430e36bae34775ee2..97718aedb26fc58af39766b253895c686027cc96 100644 (file)
@@ -390,11 +390,10 @@ public:
                const Standard_Boolean theToCopyData)
   {
     Standard_RangeError_Raise_if (theUpper < theLower, "NCollection_Array1::Resize");
-    const Standard_Integer anOldLen   = Length();
-    const Standard_Integer aNewLen    = theUpper - theLower + 1;
-    const Standard_Integer aLowerOld  = myLowerBound;
+    const Standard_Integer anOldLen = Length();
+    const Standard_Integer aNewLen  = theUpper - theLower + 1;
 
-    TheItemType* aBeginOld = &myData[aLowerOld];
+    TheItemType* aBeginOld = myData != NULL ? &myData[myLowerBound] : NULL;
     myLowerBound = theLower;
     myUpperBound = theUpper;
     if (aNewLen == anOldLen)