From 463f35527e08b167aacc9385223d502a4956b008 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 13 Jul 2021 19:33:10 -0700 Subject: [PATCH] use an enum for CB_* constants Nothing was relying on the values of these constants and it is clearer to use an enum here. It is now more obvious to readers when one of these values is being passed between functions instead of an ambiguous int. --- lib/cgraph/cghdr.h | 6 ++---- lib/cgraph/pend.c | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/cgraph/cghdr.h b/lib/cgraph/cghdr.h index 42785ab93..e42c03c95 100644 --- a/lib/cgraph/cghdr.h +++ b/lib/cgraph/cghdr.h @@ -148,12 +148,10 @@ void agmethod_init(Agraph_t * g, void *obj); void agmethod_upd(Agraph_t * g, void *obj, Agsym_t * sym); void agmethod_delete(Agraph_t * g, void *obj); -#define CB_INITIALIZE 100 -#define CB_UPDATE 101 -#define CB_DELETION 102 +typedef enum { CB_INITIALIZE, CB_UPDATE, CB_DELETION, } cb_t; void agsyspushdisc(Agraph_t * g, Agcbdisc_t * cb, void *state, int stack); int agsyspopdisc(Agraph_t * g, Agcbdisc_t * cb, int stack); -void agrecord_callback(Agraph_t * g, Agobj_t * obj, int kind, +void agrecord_callback(Agraph_t * g, Agobj_t * obj, cb_t kind, Agsym_t * optsym); void aginitcb(Agraph_t * g, void *obj, Agcbstack_t * disc); void agupdcb(Agraph_t * g, void *obj, Agsym_t * sym, Agcbstack_t * disc); diff --git a/lib/cgraph/pend.c b/lib/cgraph/pend.c index bef93fe33..4959f8af3 100644 --- a/lib/cgraph/pend.c +++ b/lib/cgraph/pend.c @@ -61,7 +61,7 @@ static Dtdisc_t Disc = { .freef = freef, }; -static Dict_t *dictof(pendingset_t * ds, Agobj_t * obj, int kind) +static Dict_t *dictof(pendingset_t * ds, Agobj_t * obj, cb_t kind) { Dict_t **dict_ref = NULL; @@ -183,8 +183,7 @@ static void purge(Dict_t * dict, Agobj_t * obj) } } -void agrecord_callback(Agraph_t * g, Agobj_t * obj, int kind, - Agsym_t * optsym) +void agrecord_callback(Agraph_t * g, Agobj_t * obj, cb_t kind, Agsym_t * optsym) { pendingset_t *pending; Dict_t *dict; @@ -225,7 +224,7 @@ void agrecord_callback(Agraph_t * g, Agobj_t * obj, int kind, } } -static void cb(Dict_t * dict, int callback_kind) +static void cb(Dict_t * dict, cb_t callback_kind) { pending_cb_t *pcb; Agraph_t *g; -- 2.40.0