[pacman-dev] [PATCH 1/5] graph.h: replace hardcoded values with an enum

Allan McRae allan at archlinux.org
Sun Apr 16 11:25:43 UTC 2017


On 16/04/17 07:57, Andrew Gregory wrote:
> Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
> ---

<snip>

> +enum __alpm_graph_vertex_state {
> +	ALPM_GRAPH_STATE_UNPROCESSED = 0,
> +	ALPM_GRAPH_STATE_PROCESSING = -1,
> +	ALPM_GRAPH_STATE_PROCESSED = 1
> +};
> +

Why keep the -1, 0, 1 state when switching to an enum?  I can't see a
point when it matters?

>  typedef struct __alpm_graph_t {
>  	void *data;
>  	struct __alpm_graph_t *parent; /* where did we come from? */
>  	alpm_list_t *children;
>  	alpm_list_t *childptr; /* points to a child in children list */
>  	off_t weight; /* weight of the node */
> -	signed char state; /* 0: untouched, -1: entered, other: leaving time */
> +	signed char state;

struct __alpm_graph_vertex_state state
?

>  } alpm_graph_t;
>  
>  alpm_graph_t *_alpm_graph_new(void);
> 


More information about the pacman-dev mailing list