]> git.ozlabs.org Git - ccan/commitdiff
aga: Error codes
authorDavid Gibson <david@gibson.dropbear.id.au>
Tue, 3 Nov 2015 03:20:14 +0000 (14:20 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Tue, 3 Nov 2015 03:20:14 +0000 (14:20 +1100)
Add an enum to record error codes for aga routines.  The current
algorithms, dfs and bfs don't have any error conditions except those
reported by callbacks.  So, for now, the only code is "no error", but this
will be expanded in future.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
ccan/aga/aga.c
ccan/aga/aga.h

index f27f9f3034e7a34c6efc0f6a830769d3f28e3d08..c1880ec54278f13c66b28ded097a25a997611d34 100644 (file)
@@ -15,7 +15,7 @@ void aga_init_graph_(struct aga_graph *g,
                     aga_edge_info_fn edge_info)
 {
        g->sequence = 0;
-       g->error = 0;
+       g->error = AGA_ERR_NONE;
 
        g->first_edge = first_edge;
        g->next_edge = next_edge;
@@ -54,7 +54,7 @@ bool aga_check_state(const struct aga_graph *g)
 void aga_finish(struct aga_graph *g)
 {
        assert(g->sequence & 1);
-       g->error = 0;
+       g->error = AGA_ERR_NONE;
        g->sequence++;
 }
 
index aa4126a79768d5afe55e9ada39c71b34b684c1b6..867515030a560501ed0c158ec63c406a39a335c7 100644 (file)
@@ -195,6 +195,18 @@ void aga_init_graph_(struct aga_graph *g,
                                (aga_edge_info_fn)(eifn_));             \
        } while (0)
 
+/**
+ * enum aga_error - Error codes for aga routines
+ *
+ * These error codes are returned by aga_error() for errors detected
+ * within aga itself (rather than errors reported by supplied
+ * callbacks, which should be negative
+ */
+enum aga_error {
+       /* No error */
+       AGA_ERR_NONE = 0,
+};
+
 /**
  * aga_error - Determine error state of a graph
  * @g: the graph