Skip to content

Commit 965fc71

Browse files
committed
Fix gcc warnings. Return error if castling status != 0.
1 parent e8b79f7 commit 965fc71

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/apps/fathom.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ int main(int argc, char **argv)
714714
}
715715
printf("%d moves returned from DTZ probe\n",moves.size);
716716
char str[20];
717-
for (int i = 0; i < moves.size; i++) {
717+
for (unsigned i = 0; i < moves.size; i++) {
718718
struct TbRootMove *m = &(moves.moves[i]);
719719
move_parts_to_str(pos, TB_MOVE_FROM(m->move),
720720
TB_MOVE_TO(m->move),
@@ -732,7 +732,7 @@ int main(int argc, char **argv)
732732
return -1;
733733
}
734734
printf("%d moves returned from WDL probe\n",moves.size);
735-
for (int i = 0; i < moves.size; i++) {
735+
for (unsigned i = 0; i < moves.size; i++) {
736736
struct TbRootMove *m = &(moves.moves[i]);
737737
move_parts_to_str(pos, TB_MOVE_FROM(m->move),
738738
TB_MOVE_TO(m->move),

src/tbchess.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,17 +298,17 @@ static const uint64_t anti2board_table[15] =
298298
0x0001020408102040ull,
299299
};
300300

301-
static inline size_t diag2index(uint64_t b, unsigned d)
301+
static inline size_t diag2index(uint64_t b)
302302
{
303303
b *= 0x0101010101010101ull;
304304
b >>= 56;
305305
b >>= 1;
306306
return (size_t)b;
307307
}
308308

309-
static inline size_t anti2index(uint64_t b, unsigned a)
309+
static inline size_t anti2index(uint64_t b)
310310
{
311-
return diag2index(b, a);
311+
return diag2index(b);
312312
}
313313

314314
#define diag(s) square2diag_table[(s)]
@@ -322,8 +322,8 @@ static uint64_t bishop_attacks(unsigned sq, uint64_t occ)
322322
unsigned d = diag(sq), a = anti(sq);
323323
uint64_t d_occ = occ & (diag2board(d) & ~BOARD_EDGE);
324324
uint64_t a_occ = occ & (anti2board(a) & ~BOARD_EDGE);
325-
size_t d_idx = diag2index(d_occ, d);
326-
size_t a_idx = anti2index(a_occ, a);
325+
size_t d_idx = diag2index(d_occ);
326+
size_t a_idx = anti2index(a_occ);
327327
uint64_t d_attacks = diag_attacks_table[sq][d_idx];
328328
uint64_t a_attacks = anti_attacks_table[sq][a_idx];
329329
return d_attacks | a_attacks;

src/tbprobe.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,11 @@ static unsigned lsb(uint64_t b) {
185185

186186
#if _BYTE_ORDER == _BIG_ENDIAN
187187

188+
/* (unused)
188189
static uint64_t from_le_u64(uint64_t input) {
189190
return bswap64(input);
190191
}
192+
*/
191193

192194
static uint32_t from_le_u32(uint32_t input) {
193195
return bswap32(input);
@@ -205,15 +207,18 @@ static uint32_t from_be_u32(uint32_t x) {
205207
return x;
206208
}
207209

208-
static uint16_t from_be_u16(uint16_t x) {
210+
/* (unused)
211+
static uint16_t from_be_u16(uint16_t x) {
209212
return x;
210-
}
213+
}*/
211214

212215
#else
213216

217+
/* (unused)
214218
static uint64_t from_le_u64(uint64_t x) {
215219
return x;
216220
}
221+
*/
217222

218223
static uint32_t from_le_u32(uint32_t x) {
219224
return x;
@@ -231,9 +236,11 @@ static uint32_t from_be_u32(uint32_t input) {
231236
return bswap32(input);
232237
}
233238

239+
/* (unused)
234240
static uint16_t from_be_u16(const uint16_t input) {
235241
return bswap16(input);
236242
}
243+
*/
237244

238245
#endif
239246

@@ -585,6 +592,7 @@ int tb_probe_root_dtz(
585592
(uint8_t)ep,
586593
turn
587594
};
595+
if (castling != 0) return 0;
588596
return root_probe_dtz(&pos, hasRepeated, useRule50, results);
589597
}
590598

@@ -617,6 +625,7 @@ int tb_probe_root_wdl(
617625
(uint8_t)ep,
618626
turn
619627
};
628+
if (castling != 0) return 0;
620629
return root_probe_wdl(&pos, useRule50, results);
621630
}
622631

@@ -1742,7 +1751,7 @@ int probe_table(const Pos *pos, int s, int *success, const int type)
17421751
int p[TB_PIECES];
17431752
size_t idx;
17441753
int t = 0;
1745-
uint8_t flags;
1754+
uint8_t flags = 0; // initialize to fix GCC warning
17461755

17471756
if (!be->hasPawns) {
17481757
if (type == DTZ) {

0 commit comments

Comments
 (0)