Whamcloud - gitweb
tests: use make rules to run tests in parallel
[tools/e2fsprogs.git] / e2fsck / dict.c
index 2765254..90c4d84 100644 (file)
 
 #define NDEBUG
 
+#ifdef __GNUC__
+#define EXT2FS_ATTR(x) __attribute__(x)
+#else
+#define EXT2FS_ATTR(x)
+#endif
+
+#include "config.h"
 #include <stdlib.h>
 #include <stddef.h>
 #include <assert.h>
@@ -33,7 +40,7 @@ static const char rcsid[] = "$Id: dict.c,v 1.40.2.7 2000/11/13 01:36:44 kaz Exp
 /*
  * These macros provide short convenient names for structure members,
  * which are embellished with dict_ prefixes so that they are
- * properly confined to the documented namespace. It's legal for a 
+ * properly confined to the documented namespace. It's legal for a
  * program which uses dict to define, for instance, a macro called ``parent''.
  * Such a macro would interfere with the dnode_t struct definition.
  * In general, highly portable and reusable C modules which expose their
@@ -144,7 +151,7 @@ static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil)
  * dict_next() successor function, verifying that the key of each node is
  * strictly lower than that of its successor, if duplicates are not allowed,
  * or lower or equal if duplicates are allowed.  This function is used for
- * debugging purposes. 
+ * debugging purposes.
  */
 #ifndef NDEBUG
 static int verify_bintree(dict_t *dict)
@@ -203,7 +210,7 @@ static unsigned int verify_redblack(dnode_t *nil, dnode_t *root)
        if (root->color != dnode_black)
            return 0;
        return height_left + 1;
-    } 
+    }
     return 1;
 }
 
@@ -343,7 +350,7 @@ dict_t *dict_init(dict_t *dict, dictcount_t maxcount, dict_comp_t comp)
 }
 
 #ifdef E2FSCK_NOTUSED
-/* 
+/*
  * Initialize a dictionary in the likeness of another dictionary
  */
 
@@ -383,7 +390,7 @@ static void dict_clear(dict_t *dict)
  * debugging purposes, and should be placed in assert statements.   Just because
  * this function succeeds doesn't mean that the tree is not corrupt. Certain
  * corruptions in the tree may simply cause undefined behavior.
- */ 
+ */
 
 int dict_verify(dict_t *dict)
 {
@@ -440,7 +447,7 @@ int dict_similar(const dict_t *left, const dict_t *right)
 
 /*
  * Locate a node in the dictionary having the given key.
- * If the node is not found, a null a pointer is returned (rather than 
+ * If the node is not found, a null a pointer is returned (rather than
  * a pointer that dictionary's nil sentinel node), otherwise a pointer to the
  * located node is returned.
  */
@@ -505,9 +512,9 @@ dnode_t *dict_lower_bound(dict_t *dict, const void *key)
                tentative = root;
                root = root->left;
            }
-       } 
+       }
     }
-    
+
     return tentative;
 }
 
@@ -537,9 +544,9 @@ dnode_t *dict_upper_bound(dict_t *dict, const void *key)
                tentative = root;
                root = root->right;
            }
-       } 
+       }
     }
-    
+
     return tentative;
 }
 #endif
@@ -721,10 +728,10 @@ dnode_t *dict_delete(dict_t *dict, dnode_t *delete)
 
        child = (delete->left != nil) ? delete->left : delete->right;
 
-       child->parent = delparent = delete->parent;         
+       child->parent = delparent = delete->parent;
 
        if (delete == delparent->left) {
-           delparent->left = child;    
+           delparent->left = child;
        } else {
            assert (delete == delparent->right);
            delparent->right = child;
@@ -963,12 +970,12 @@ int dict_contains(dict_t *dict, dnode_t *node)
     return verify_dict_has_node(dict_nil(dict), dict_root(dict), node);
 }
 
-static dnode_t *dnode_alloc(void *context)
+static dnode_t *dnode_alloc(void *context EXT2FS_ATTR((unused)))
 {
     return malloc(sizeof *dnode_alloc(NULL));
 }
 
-static void dnode_free(dnode_t *node, void *context)
+static void dnode_free(dnode_t *node, void *context EXT2FS_ATTR((unused)))
 {
     free(node);
 }
@@ -1052,18 +1059,18 @@ void dict_load_next(dict_load_t *load, dnode_t *newnode, const void *key)
 {
     dict_t *dict = load->dictptr;
     dnode_t *nil = &load->nilnode;
-   
+
     assert (!dnode_is_in_a_dict(newnode));
     assert (dict->nodecount < dict->maxcount);
 
-    #ifndef NDEBUG
+#ifndef NDEBUG
     if (dict->nodecount > 0) {
        if (dict->dupes)
            assert (dict->compare(nil->left->key, key) <= 0);
        else
            assert (dict->compare(nil->left->key, key) < 0);
     }
-    #endif
+#endif
 
     newnode->key = key;
     nil->right->left = newnode;
@@ -1158,7 +1165,7 @@ void dict_merge(dict_t *dest, dict_t *source)
     dict_load_t load;
     dnode_t *leftnode = dict_first(dest), *rightnode = dict_first(source);
 
-    assert (dict_similar(dest, source));       
+    assert (dict_similar(dest, source));
 
     if (source == dest)
        return;
@@ -1184,20 +1191,20 @@ void dict_merge(dict_t *dest, dict_t *source)
     copyleft:
        {
            dnode_t *next = dict_next(dest, leftnode);
-           #ifndef NDEBUG
+#ifndef NDEBUG
            leftnode->left = NULL;      /* suppress assertion in dict_load_next */
-           #endif
+#endif
            dict_load_next(&load, leftnode, leftnode->key);
            leftnode = next;
            continue;
        }
-       
+
     copyright:
        {
            dnode_t *next = dict_next(source, rightnode);
-           #ifndef NDEBUG
+#ifndef NDEBUG
            rightnode->left = NULL;
-           #endif
+#endif
            dict_load_next(&load, rightnode, rightnode->key);
            rightnode = next;
            continue;
@@ -1220,7 +1227,7 @@ typedef char input_t[256];
 
 static int tokenize(char *string, ...)
 {
-    char **tokptr; 
+    char **tokptr;
     va_list arglist;
     int tokcount = 0;
 
@@ -1284,7 +1291,7 @@ static void construct(dict_t *d)
     dnode_t *dn;
     char *tok1, *tok2, *val;
     const char *key;
-    char *help = 
+    char *help =
        "p                      turn prompt on\n"
        "q                      finish construction\n"
        "a <key> <val>          add new entry\n";