1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
From: Khem Raj <raj.khem@gmail.com>
palisade: Fix warnings with clang on arm
ARM treats 'char' as unsigned char when 'char' is not qualified with
'signed' or 'unsigned' explicitly.
This results in warnings e.g.
palisade.c:531:22: error: comparison of constant -1 with expression of
type 'clue' (aka 'char') is always false
[-Werror,-Wtautological-constant-out-of-range-compare]
if (clues[i] == EMPTY) continue;
Therefore, typcast the contant to char in such places to be explicit
Upstream-Status: Submitted [email discussion with upstream]
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Index: git/palisade.c
===================================================================
--- git.orig/palisade.c
+++ git/palisade.c
@@ -46,7 +46,7 @@ struct game_params {
int w, h, k;
};
-typedef char clue;
+typedef signed char clue;
typedef unsigned char borderflag;
typedef struct shared_state {
@@ -242,7 +242,7 @@ typedef struct solver_ctx {
* thing is done. See how it is propagated across multiple squares.]
*/
-#define EMPTY (~0)
+#define EMPTY ((clue)-1)
#define BIT(i) (1 << (i))
#define BORDER(i) BIT(i)
@@ -622,7 +622,7 @@ static char *new_game_desc(const game_pa
{
int w = params->w, h = params->h, wh = w*h, k = params->k;
- clue *numbers = snewn(wh + 1, clue), *p;
+ clue *numbers = snewn(wh + 1, clue);
borderflag *rim = snewn(wh, borderflag);
borderflag *scratch_borders = snewn(wh, borderflag);
@@ -682,7 +682,8 @@ static char *new_game_desc(const game_pa
sfree(shuf);
sfree(dsf);
- p = numbers;
+ char *output = snewn(wh + 1, char), *p = output;
+
r = 0;
for (i = 0; i < wh; ++i) {
if (numbers[i] != EMPTY) {
@@ -699,7 +700,8 @@ static char *new_game_desc(const game_pa
}
*p++ = '\0';
- return sresize(numbers, p - numbers, clue);
+ sfree(numbers);
+ return sresize(output, p - output, char);
}
static const char *validate_desc(const game_params *params, const char *desc)
|