stratos wrote:
> Update of /cvsroot/monetdb/MonetDB5/src/modules/mal/crackers
> In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26417
> 
> Modified Files:
>       crackers_partial_sideways.mx 
> Log Message:
> more safety checks from coverity
> 
> 
> Index: crackers_partial_sideways.mx
> ===================================================================
> RCS file: 
> /cvsroot/monetdb/MonetDB5/src/modules/mal/crackers/crackers_partial_sideways.mx,v
> retrieving revision 1.7
> retrieving revision 1.8
> diff -u -d -r1.7 -r1.8
> --- crackers_partial_sideways.mx      9 Nov 2009 22:06:57 -0000       1.7
> +++ crackers_partial_sideways.mx      10 Nov 2009 00:05:34 -0000      1.8
> @@ -647,9 +647,9 @@
>       oid i;
>  
>       if (nodeLow == NULL)
> -                printf("\n crackers.createPieceMap Unexpected case: Low node 
> is NULL\n ");

Printf is not to be used for this.
Either you want to leave a debugging message, then use
        stream_printf(GDKout,"\n.....
or return an exception string so the upper layers can deal with it


> +             return NULL;
>       if (nodeHgh == NULL)
> -                printf("\n  crackers.createPieceMap Unexpected case: Hgh 
> node is NULL \n ");
> +             return NULL;
>  
>       if (nodeLow->indexLocal == 0) pos1 = 0;
>       else pos1 = nodeLow->indexLocal + 1;
> @@ -920,7 +920,7 @@
>               return 0;
>  
>          if ((h = BATdescriptor(cur->tape)) == NULL) 
> -                printf("\n\n crackers.sync Cannot access tape \n\n");
> +             return -1;
>  
>       /* check if the current pair is already synced */       
>       cursor = getTapeCursor(cur,tailBatId);
> @@ -936,7 +936,7 @@
>       }
>        /* Take the index of the bat */
>          if ((c = BATdescriptor(CrackerIndex[m].cid)) == NULL)
> -                printf(" \n\n crackers.sync Cannot access crack index \n\n");
> +             return -1;
>  
>       syncs = size - cursor;
>  
> @@ -1057,7 +1057,8 @@
>  
>  @= EnrichMaxTailResultIncrementalSideways
>       siz...@5;
> -     
> +     if (pairt==NULL)        
> +             throw(MAL,"pcrack", "Unexpected error during max. Empty 
> input.");
>       if (BATcount(p) == 0){
>               *maxt = *pairt;
>               j = 1;
> @@ -1070,6 +1071,8 @@
>                       *maxt = *pairt; 
>               pairt  ++;
>       }
> +     if(piece==NULL)
> +             throw(MAL,"pcrack", "Unexpected error. Cur piece is NULL.");
>       if (newPiece)
>               BBPkeepref(piece->batCacheid);          
>       else
> @@ -1106,6 +1109,8 @@
>       if (*inclusiveLow2==FALSE && *inclusiveHgh2==FALSE){
>               @:analyzeTailConjunction(@2,@3,@4,GT,LT,@5)@    
>       }
> +     if(piece==NULL)
> +             throw(MAL,"pcrack", "Unexpected error. Cur piece is NULL.");
>       if (newPiece)
>               BBPkeepref(piece->batCacheid);          
>       else
> @@ -1143,6 +1148,8 @@
>               @:analyzeTailConjunctionPivot(@2,@3,@4,GT,LT,@5)@       
>       }
>  
> +     if(piece==NULL)
> +             throw(MAL,"pcrack", "Unexpected error. Cur piece is NULL.");
>       if (newPiece)
>               BBPkeepref(piece->batCacheid);          
>       else
> @@ -1159,6 +1166,8 @@
>                  pivott ++;
>  
>       } 
> +     if(piece==NULL)
> +             throw(MAL,"pcrack", "Unexpected error in projection. Cur piece 
> is NULL.");
>       if (newPiece)
>               BBPkeepref(piece->batCacheid);          
>       else
> @@ -1177,6 +1186,8 @@
>                  pivott ++;
>  
>       } 
> +     if(piece==NULL)
> +             throw(MAL,"pcrack", "Unexpected error. Cur piece is NULL.");
>       if (newPiece)
>               BBPkeepref(piece->batCacheid);          
>       else
> @@ -1271,11 +1282,19 @@
>  @
>  
>  @= SyncAndCrackBasedonFirstBound
> -                syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, FALSE);
> +                syncs=syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, FALSE);
> +             if (syncs<0)
> +                     throw(MAL,"pcrack", "Failed to access cracker index or 
> tape during syncing.");
> +
>               foundLow = getlownod...@1(*low, *inclusiveLow, 
> CrackerIndex[h].Tree, cm, BUNfirst(cm), &localNodeLow1, &localNodeHgh1, NULL, 
> NULL);
> -             if (foundLow == 0)
> -                     if ((syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, 
> TRUE))>0)
> +
> +             if (foundLow == 0){
> +                     syncs=syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, 
> TRUE);
> +                     if (syncs<0)
> +                             throw(MAL,"pcrack", "Failed to access cracker 
> index or tape during syncing.");
> +                     if (syncs>0)
>                               foundLow = getlownod...@1(*low, *inclusiveLow, 
> CrackerIndex[h].Tree, cm, BUNfirst(cm), &localNodeLow1, &localNodeHgh1, NULL, 
> NULL);
> +             }
>               foundHgh = 1;
>               base = nodeLow1->indexLocal;
>               CrackPiece = SyncAndCrackBasedonFirstBound = TRUE;
> @@ -1288,7 +1307,9 @@
>  @
>  
>  @= SyncAndCrackBasedonLastBound
> -             syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, FALSE);
> +             syncs=syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, FALSE);
> +             if (syncs<0)
> +                     throw(MAL,"pcrack", "Failed to access cracker index or 
> tape during syncing.");
>  
>               /* if the high bound falls in here we crack this piece */
>               if ( (*(@1*)Tloc(c, BUNfirst(c)+nodeHgh1->position)) > *hgh || 
> @@ -1296,9 +1317,13 @@
>                                                               
> nodeHgh1->inclusive == HBound) ){
>                       foundHgh = gethghnod...@1(*hgh, *inclusiveHgh, 
> CrackerIndex[h].Tree, cm, BUNfirst(cm), &localNodeLow2, &localNodeHgh2, NULL, 
> NULL);
>  
> -                     if (foundHgh == 0)
> -                             if ((syncpie...@1_@2(h, piece, nodeLow1, m, 
> *pbid, TRUE)) > 0)
> +                     if (foundHgh == 0){
> +                             syncs = syncpie...@1_@2(h, piece, nodeLow1, m, 
> *pbid, TRUE);
> +                             if (syncs<0)
> +                                     throw(MAL,"pcrack", "Failed to access 
> cracker index or tape during syncing.");
> +                             if (syncs > 0)
>                                       foundHgh = gethghnod...@1(*hgh, 
> *inclusiveHgh, CrackerIndex[h].Tree, cm, BUNfirst(cm), &localNodeLow2, 
> &localNodeHgh2, NULL, NULL);
> +                     }
>  
>                       foundLow = 1;
>                       base = nodeLow1->indexLocal;
> @@ -1317,13 +1342,19 @@
>  @
>  
>  @= SyncAndCrackBasedonBothBounds
> -             syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, FALSE);
> +             syncs=syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, FALSE);
> +             if (syncs<0)
> +                     throw(MAL,"pcrack", "Failed to access cracker index or 
> tape during syncing.");
> +
>               /* get the new node after the sync */
>               foundLow = getlownod...@1(*low, *inclusiveLow, 
> CrackerIndex[h].Tree, cm, BUNfirst(cm), &localNodeLow1, &localNodeHgh1, NULL, 
> NULL);
>               foundHgh = gethghnod...@1(*hgh, *inclusiveHgh, 
> CrackerIndex[h].Tree, cm, BUNfirst(cm), &localNodeLow2, &localNodeHgh2, NULL, 
> NULL);
>  
>               if (foundLow == 0 || foundHgh == 0){
> -                     if ((syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, 
> TRUE)) > 0 ){
> +                     syncs=syncpie...@1_@2(h, piece, nodeLow1, m, *pbid, 
> TRUE);
> +                     if (syncs<0)
> +                             throw(MAL,"pcrack", "Failed to access cracker 
> index or tape during syncing.");
> +                     if (syncs > 0 ){
>                               foundLow = getlownod...@1(*low, *inclusiveLow, 
> CrackerIndex[h].Tree, cm, BUNfirst(cm), &localNodeLow1, &localNodeHgh1, NULL, 
> NULL);
>                               foundHgh = gethghnod...@1(*hgh, *inclusiveHgh, 
> CrackerIndex[h].Tree, cm, BUNfirst(cm), &localNodeLow2, &localNodeHgh2, NULL, 
> NULL);
>                       }
> @@ -1341,6 +1372,8 @@
>  @= makeNewMapPiece1
>               /*printStorageInfo(); can be used to what is in the Storage 
> management structure */
>                       piece = createpiecem...@1_@2(b, tailBAT, nodeLow1, 
> nodeHgh1, m);
> +                     if (piece==NULL)
> +                             throw(MAL,"pcracking","Failed to create map 
> piece");
>                       newPiece = TRUE;
>                       
>                       localFirst = addcrackerindexincrementalsidewa...@1(h, 
> *(@1*)Tloc(c, BUNfirst(c)+nodeLow1->position), nodeLow1->inclusive, 0, 
> nodeLow1->indexLocal, cm, FALSE, TRUE, piece->batCacheid);
> @@ -1350,6 +1383,8 @@
>  
>  @= makeNewMapPiece2
>                       piece = createpiecem...@1_@2(b, tailBAT, nodeLow1, 
> nodeHgh1, m);
> +                     if (piece==NULL)
> +                             throw(MAL,"pcracking","Failed to create map 
> piece");
>                       newPiece = TRUE;
>                       localNodeLow1->first = TRUE;
>                       localNodeLow1->indexLocal = 0;
> @@ -1421,12 +1456,16 @@
>                               crkTwoLTree = TRUE;
>                       else{
>                               posl = 0;
> +                             if (nodeHgh1==NULL)
> +                                     throw(MAL,"pcrack", "Unexpected error. 
> High node is NULL.");
>                               posh = nodeHgh1->indexLocal;
>                               crkThreeTree = TRUE;
>                       }       
>                       done = TRUE;    
>               }else
>               if (nodeHgh1 == NULL && nodeHgh2 == NULL) {
> +                     if (nodeLow1==NULL)
> +                             throw(MAL,"pcrack", "Unexpected error. Low node 
> is NULL.");
>                       if (foundLow != 0){
>                               nodeLow1->first = TRUE;
>                               crkTwoRTree = TRUE;
> @@ -1442,6 +1481,8 @@
>               else    
>               /* A previous query has already created a piece for this area */
>               if (nodeLow1->first == TRUE){
> +                     if (nodeHgh1==NULL)
> +                             throw(MAL,"pcrack", "Unexpected error. High 
> node is NULL.");
>  
>                       @:makeNewMapPiece1(@1,@2)@
>  
> @@ -1463,6 +1504,8 @@
>                                       nodeLow1->first = TRUE;
>                               else 
>                               if (foundLow == 0 && foundHgh ==0){     
> +                                     if (nodeHgh1==NULL)
> +                                             throw(MAL,"pcrack", "Unexpected 
> error. High node is NULL.");
>                                       posl = nodeLow1->indexLocal+1;
>                                       posh = nodeHgh1->indexLocal;
>                                       crkThreeTree = TRUE;
> @@ -1533,6 +1576,7 @@
>       bit AnalyzeRemainingPiece         = FALSE;
>       bit crkTwoLTree, crkTwoRTree, crkThreeTree;     
>       bit CrackPiece = FALSE, SyncAndCrackBasedonFirstBound = FALSE, 
> SyncAndCrackBasedonBothBounds = FALSE, SyncAndCrackBasedonLastBound = FALSE;
> +     lng syncs=0;
>  
>          if (@3_GT(low,hgh,@4...@1))
>                  throw(MAL, "crackers.crack", "illegal range");
> @@ -1662,6 +1706,8 @@
>                       curPieceNodeLast = getNextNonLocalNode(localNodeHgh1);
>               } else 
>               if (localNodeLow1->localBound == FALSE && localNodeLow1->first 
> == FALSE){
> +                     if (localNodeLow2==NULL)        
> +                             throw(MAL,"pcrack", "Unexpected error. Low node 
> is NULL.");
>                       if 
> (*(oid*)Hloc(cm,BUNfirst(cm)+localNodeLow1->position) == 
> *(oid*)Hloc(cm,BUNfirst(cm)+localNodeLow2->position))
>                               /* Both bounds fall within a non materialized 
> area of the map */
>                               BothBoundsWithinAnExistingArea=TRUE;
> @@ -1716,14 +1762,15 @@
>          Each piece in this area needs to be synced if necessary and enrich 
> the result
>          If the hgh bound falls in a piece then we also have to crack it */
>       while(done == FALSE){
> +             if (curPieceNodeLast==NULL || curCBatNodeLast ==NULL)
> +                     throw(MAL,"pcrack", "Unexpected error. Low node is 
> NULL.");
> +
>               LastBoundWithinAnExistingArea = FALSE;
>               localNodeLow1 = curPieceNodeLast;
>               localNodeHgh1 = 
> getNextNonLocalNode(findNextPiece(localNodeLow1));
>               nodeLow1      = curCBatNodeLast;
>               nodeHgh1      = findNextPiece(nodeLow1);
>  
> -             if (localNodeLow1==NULL)
> -                     throw(MAL, "partial sideways cracking", "Unexpected 
> error while traversing cracker map. Low node is NULL.");    
>                       
>               if (localNodeHgh1==NULL){
>                       if (nodeHgh1 == NULL){
> 
> 
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> Monetdb-checkins mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/monetdb-checkins


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Monetdb-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-developers

Reply via email to