1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Added -Wshadow option and fixed resulting warnings

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2011-04-04 09:53:44 +02:00
parent f7ef48b478
commit 04108d4541
8 changed files with 34 additions and 35 deletions

View file

@ -228,11 +228,11 @@ endif
CXXFLAGS = -g -Wall -Wcast-qual -fno-exceptions -fno-rtti $(EXTRACXXFLAGS)
ifeq ($(comp),gcc)
CXXFLAGS += -ansi -pedantic -Wno-long-long -Wextra
CXXFLAGS += -ansi -pedantic -Wno-long-long -Wextra -Wshadow
endif
ifeq ($(comp),mingw)
CXXFLAGS += -Wno-long-long -Wextra
CXXFLAGS += -Wextra -Wshadow
endif
ifeq ($(comp),icc)

View file

@ -367,8 +367,8 @@ Book::~Book() {
void Book::close() {
if (is_open())
ifstream::close();
if (bookFile.is_open())
bookFile.close();
bookName = "";
}
@ -381,17 +381,17 @@ void Book::open(const string& fileName) {
// Close old file before opening the new
close();
ifstream::open(fileName.c_str(), ifstream::in | ifstream::binary);
bookFile.open(fileName.c_str(), ifstream::in | ifstream::binary);
// Silently return when asked to open a non-exsistent file
if (!is_open())
if (!bookFile.is_open())
return;
// Get the book size in number of entries
seekg(0, ios::end);
bookSize = long(tellg()) / sizeof(BookEntry);
bookFile.seekg(0, ios::end);
bookSize = long(bookFile.tellg()) / sizeof(BookEntry);
if (!good())
if (!bookFile.good())
{
cerr << "Failed to open book file " << fileName << endl;
exit(EXIT_FAILURE);
@ -408,7 +408,7 @@ void Book::open(const string& fileName) {
Move Book::get_move(const Position& pos, bool findBestMove) {
if (!is_open() || bookSize == 0)
if (!bookFile.is_open() || bookSize == 0)
return MOVE_NONE;
BookEntry entry;
@ -512,11 +512,11 @@ BookEntry Book::read_entry(int idx) {
BookEntry e;
seekg(idx * sizeof(BookEntry), ios_base::beg);
bookFile.seekg(idx * sizeof(BookEntry), ios_base::beg);
*this >> e.key >> e.move >> e.count >> e.learn;
if (!good())
if (!bookFile.good())
{
cerr << "Failed to read book entry at index " << idx << endl;
exit(EXIT_FAILURE);

View file

@ -38,9 +38,7 @@ struct BookEntry {
uint32_t learn;
};
class Book : private std::ifstream {
Book(const Book&); // just decleared..
Book& operator=(const Book&); // ..to avoid a warning
class Book {
public:
Book();
~Book();
@ -60,14 +58,15 @@ private:
BookEntry read_entry(int idx);
int find_entry(uint64_t key);
std::ifstream bookFile;
std::string bookName;
int bookSize;
RKISS RKiss;
};
// Yes, we indulge a bit here ;-)
template<int n> inline uint64_t Book::get_int() { return 256 * get_int<n-1>() + get(); }
template<> inline uint64_t Book::get_int<1>() { return get(); }
template<int n> inline uint64_t Book::get_int() { return 256 * get_int<n-1>() + bookFile.get(); }
template<> inline uint64_t Book::get_int<1>() { return bookFile.get(); }
#endif // !defined(BOOK_H_INCLUDED)

View file

@ -37,7 +37,7 @@ public:
Value value(Piece p, Square to) const;
void update(Piece p, Square to, Value bonus);
Value gain(Piece p, Square to) const;
void update_gain(Piece p, Square to, Value gain);
void update_gain(Piece p, Square to, Value g);
static const Value MaxValue = Value(1 << 29); // To avoid an overflow
@ -63,8 +63,8 @@ inline Value History::gain(Piece p, Square to) const {
return maxGains[p][to];
}
inline void History::update_gain(Piece p, Square to, Value gain) {
maxGains[p][to] = Max(gain, maxGains[p][to] - 1);
inline void History::update_gain(Piece p, Square to, Value g) {
maxGains[p][to] = Max(g, maxGains[p][to] - 1);
}
#endif // !defined(HISTORY_H_INCLUDED)

View file

@ -160,7 +160,7 @@ void Position::detach() {
/// string. This function is not very robust - make sure that input FENs are
/// correct (this is assumed to be the responsibility of the GUI).
void Position::from_fen(const string& fen, bool c960) {
void Position::from_fen(const string& fen, bool isChess960) {
/*
A FEN string defines a particular position using only the ASCII character set.
@ -255,7 +255,7 @@ void Position::from_fen(const string& fen, bool c960) {
castleRightsMask[make_square(initialQRFile, RANK_1)] ^= WHITE_OOO;
castleRightsMask[make_square(initialQRFile, RANK_8)] ^= BLACK_OOO;
isChess960 = c960;
chess960 = isChess960;
find_checkers();
st->key = compute_key();
@ -368,16 +368,16 @@ const string Position::to_fen() const {
if (st->castleRights != CASTLES_NONE)
{
if (can_castle_kingside(WHITE))
fen += isChess960 ? char(toupper(file_to_char(initialKRFile))) : 'K';
fen += chess960 ? char(toupper(file_to_char(initialKRFile))) : 'K';
if (can_castle_queenside(WHITE))
fen += isChess960 ? char(toupper(file_to_char(initialQRFile))) : 'Q';
fen += chess960 ? char(toupper(file_to_char(initialQRFile))) : 'Q';
if (can_castle_kingside(BLACK))
fen += isChess960 ? file_to_char(initialKRFile) : 'k';
fen += chess960 ? file_to_char(initialKRFile) : 'k';
if (can_castle_queenside(BLACK))
fen += isChess960 ? file_to_char(initialQRFile) : 'q';
fen += chess960 ? file_to_char(initialQRFile) : 'q';
} else
fen += '-';

View file

@ -303,7 +303,7 @@ private:
int castleRightsMask[64];
StateInfo startState;
File initialKFile, initialKRFile, initialQRFile;
bool isChess960;
bool chess960;
int startPosPlyCounter;
int threadID;
int64_t nodes;
@ -524,7 +524,7 @@ inline bool Position::has_pawn_on_7th(Color c) const {
}
inline bool Position::is_chess960() const {
return isChess960;
return chess960;
}
inline bool Position::move_is_capture(Move m) const {

View file

@ -159,23 +159,23 @@ Option::Option(int def, int minv, int maxv) : type("spin"), idx(Options.size()),
/// the GUI to check for option's limits, but we could receive the new value
/// directly from the user by teminal window. So let's check the bounds anyway.
void Option::set_value(const string& value) {
void Option::set_value(const string& v) {
assert(!type.empty());
if (value.empty())
if (v.empty())
return;
if ( (type == "check" || type == "button")
!= (value == "true" || value == "false"))
!= (v == "true" || v == "false"))
return;
if (type == "spin")
{
int v = atoi(value.c_str());
if (v < minValue || v > maxValue)
int val = atoi(v.c_str());
if (val < minValue || val > maxValue)
return;
}
currentValue = value;
currentValue = v;
}

View file

@ -32,7 +32,7 @@ public:
Option(bool defaultValue, std::string type = "check");
Option(int defaultValue, int minValue, int maxValue);
void set_value(const std::string& value);
void set_value(const std::string& v);
template<typename T> T value() const;
private: