Fixed some typecast and function pointer problems pointed out by a
authorChristopher R. Hertel <crh@samba.org>
Tue, 14 Apr 1998 14:43:38 +0000 (14:43 +0000)
committerChristopher R. Hertel <crh@samba.org>
Tue, 14 Apr 1998 14:43:38 +0000 (14:43 +0000)
programmer in Finland.

Chris -)-----

source/ubiqx/ubi_BinTree.c
source/ubiqx/ubi_BinTree.h

index c0f527e2d7c3f7761150b74eafd275e466389166..ed565bbfbaa5c3d21faaff12f6fd55f26be0fa70 100644 (file)
  * -------------------------------------------------------------------------- **
  *
  * Log: ubi_BinTree.c,v
  * -------------------------------------------------------------------------- **
  *
  * Log: ubi_BinTree.c,v
+ * Revision 4.1  1998/03/31 06:11:57  crh
+ * Thomas Aglassinger sent E'mail pointing out errors in the
+ * dereferencing of function pointers, and a missing typecast.
+ * Thanks, Thomas!
+ *
  * Revision 4.0  1998/03/10 03:19:22  crh
  * Added the AVL field 'balance' to the ubi_btNode structure.  This means
  * that all BinTree modules now use the same basic node structure, which
  * Revision 4.0  1998/03/10 03:19:22  crh
  * Added the AVL field 'balance' to the ubi_btNode structure.  This means
  * that all BinTree modules now use the same basic node structure, which
  */
 
 static char ModuleID[] = "ubi_BinTree\n\
  */
 
 static char ModuleID[] = "ubi_BinTree\n\
-\tRevision: 4.0\n\
-\tDate: 1998/03/10 03:19:22\n\
+\tRevision: 4.1\n\
+\tDate: 1998/03/31 06:11:57\n\
 \tAuthor: crh\n";
 
 /* ========================================================================== **
 \tAuthor: crh\n";
 
 /* ========================================================================== **
@@ -198,16 +203,16 @@ static ubi_btNodePtr TreeFind( ubi_btItemPtr  findme,
    * ------------------------------------------------------------------------ **
    */
   {
    * ------------------------------------------------------------------------ **
    */
   {
-  register ubi_btNodePtr tmp_p = p;
-  ubi_btNodePtr tmp_pp         = NULL;
-  int tmp_gender               = ubi_trEQUAL;
-  int tmp_cmp;
+  register ubi_btNodePtr tmp_p      = p;
+  ubi_btNodePtr          tmp_pp     = NULL;
+  signed char            tmp_gender = ubi_trEQUAL;
+  int                    tmp_cmp;
 
   while( tmp_p
      && (ubi_trEQUAL != (tmp_cmp = ubi_trAbNormal((*CmpFunc)(findme, tmp_p)))) )
     {
     tmp_pp     = tmp_p;                 /* Keep track of previous node. */
 
   while( tmp_p
      && (ubi_trEQUAL != (tmp_cmp = ubi_trAbNormal((*CmpFunc)(findme, tmp_p)))) )
     {
     tmp_pp     = tmp_p;                 /* Keep track of previous node. */
-    tmp_gender = tmp_cmp;               /* Keep track of sex of child.  */
+    tmp_gender = (signed char)tmp_cmp;  /* Keep track of sex of child.  */
     tmp_p      = tmp_p->Link[tmp_cmp];  /* Go to child. */
     }
   *parentp = tmp_pp;                /* Return results. */
     tmp_p      = tmp_p->Link[tmp_cmp];  /* Go to child. */
     }
   *parentp = tmp_pp;                /* Return results. */
@@ -926,7 +931,7 @@ ubi_trBool ubi_btTraverse( ubi_btRootPtr   RootPtr,
 
   while( p )
     {
 
   while( p )
     {
-    EachNode( p, UserData );
+    (*EachNode)( p, UserData );
     p = ubi_btNext( p );
     }
   return( ubi_trTRUE );
     p = ubi_btNext( p );
     }
   return( ubi_trTRUE );
@@ -964,7 +969,7 @@ ubi_trBool ubi_btKillTree( ubi_btRootPtr     RootPtr,
     p = q->Link[ubi_trPARENT];
     if( p )
       p->Link[ ((p->Link[ubi_trLEFT] == q)?ubi_trLEFT:ubi_trRIGHT) ] = NULL;
     p = q->Link[ubi_trPARENT];
     if( p )
       p->Link[ ((p->Link[ubi_trLEFT] == q)?ubi_trLEFT:ubi_trRIGHT) ] = NULL;
-    FreeNode((void *)q);
+    (*FreeNode)((void *)q);
     }
 
   (void)ubi_btInitTree( RootPtr,
     }
 
   (void)ubi_btInitTree( RootPtr,
index f3c49c95e1bbd9e1c598aaa6683feac190974b3a..8a99f28045c03c8260292bc5e1f51775847a42b6 100644 (file)
  * -------------------------------------------------------------------------- **
  *
  * Log: ubi_BinTree.h,v
  * -------------------------------------------------------------------------- **
  *
  * Log: ubi_BinTree.h,v
+ * Revision 4.1  1998/03/31 06:13:47  crh
+ * Thomas Aglassinger sent E'mail pointing out errors in the
+ * dereferencing of function pointers, and a missing typecast.
+ * Thanks, Thomas!
+ *
  * Revision 4.0  1998/03/10 03:16:04  crh
  * Added the AVL field 'balance' to the ubi_btNode structure.  This means
  * that all BinTree modules now use the same basic node structure, which
  * Revision 4.0  1998/03/10 03:16:04  crh
  * Added the AVL field 'balance' to the ubi_btNode structure.  This means
  * that all BinTree modules now use the same basic node structure, which
@@ -193,7 +198,8 @@ typedef enum {
  * -------------------------------------------------------------------------- **
  */
 #define ubi_trNormalize(W) ((char)( (W) - ubi_trEQUAL ))
  * -------------------------------------------------------------------------- **
  */
 #define ubi_trNormalize(W) ((char)( (W) - ubi_trEQUAL ))
-#define ubi_trAbNormal(W)  ((char)( ((char)ubi_btSgn( W )) + ubi_trEQUAL ))
+#define ubi_trAbNormal(W)  ((char)( ((char)ubi_btSgn( (long)(W) )) \
+                                         + ubi_trEQUAL ))
 #define ubi_trRevWay(W)    ((char)( ubi_trEQUAL - ((W) - ubi_trEQUAL) ))
 
 /* -------------------------------------------------------------------------- **
 #define ubi_trRevWay(W)    ((char)( ubi_trEQUAL - ((W) - ubi_trEQUAL) ))
 
 /* -------------------------------------------------------------------------- **