[pacman-dev] [PATCH 1/3] Make alpm_graph state signedness explicit

Rikard Falkeborn rikard.falkeborn at gmail.com
Thu Dec 31 13:19:29 UTC 2015


The signedness of char is implementation defined. Since the
alpm_graph state is clearly meant to be signed, make the
signedness explicit.

This fixes bugs on systems where char is unsigned, in comparissons
of the following type:

  if(v.state == -1)

which, if state is unsigned, will never be true due to integer
promotion rules.

Fixes failing test/pacman/tests/sync012.py when compiling with -funsigned-char.

Fixes two warnings [-Wtype-limits] for comparissons with -1 when compiling
with -funsigned-char.

Signed-off-by: Rikard Falkeborn <rikard.falkeborn at gmail.com>
---
 lib/libalpm/graph.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/libalpm/graph.h b/lib/libalpm/graph.h
index fb24d73..ae0b5d9 100644
--- a/lib/libalpm/graph.h
+++ b/lib/libalpm/graph.h
@@ -29,7 +29,7 @@ typedef struct __alpm_graph_t {
 	alpm_list_t *children;
 	alpm_list_t *childptr; /* points to a child in children list */
 	off_t weight; /* weight of the node */
-	char state; /* 0: untouched, -1: entered, other: leaving time */
+	signed char state; /* 0: untouched, -1: entered, other: leaving time */
 } alpm_graph_t;
 
 alpm_graph_t *_alpm_graph_new(void);
-- 
2.6.4


More information about the pacman-dev mailing list