1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43: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) CXXFLAGS = -g -Wall -Wcast-qual -fno-exceptions -fno-rtti $(EXTRACXXFLAGS)
ifeq ($(comp),gcc) ifeq ($(comp),gcc)
CXXFLAGS += -ansi -pedantic -Wno-long-long -Wextra CXXFLAGS += -ansi -pedantic -Wno-long-long -Wextra -Wshadow
endif endif
ifeq ($(comp),mingw) ifeq ($(comp),mingw)
CXXFLAGS += -Wno-long-long -Wextra CXXFLAGS += -Wextra -Wshadow
endif endif
ifeq ($(comp),icc) ifeq ($(comp),icc)

View file

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

View file

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

View file

@ -37,7 +37,7 @@ public:
Value value(Piece p, Square to) const; Value value(Piece p, Square to) const;
void update(Piece p, Square to, Value bonus); void update(Piece p, Square to, Value bonus);
Value gain(Piece p, Square to) const; 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 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]; return maxGains[p][to];
} }
inline void History::update_gain(Piece p, Square to, Value gain) { inline void History::update_gain(Piece p, Square to, Value g) {
maxGains[p][to] = Max(gain, maxGains[p][to] - 1); maxGains[p][to] = Max(g, maxGains[p][to] - 1);
} }
#endif // !defined(HISTORY_H_INCLUDED) #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 /// string. This function is not very robust - make sure that input FENs are
/// correct (this is assumed to be the responsibility of the GUI). /// 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. 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_1)] ^= WHITE_OOO;
castleRightsMask[make_square(initialQRFile, RANK_8)] ^= BLACK_OOO; castleRightsMask[make_square(initialQRFile, RANK_8)] ^= BLACK_OOO;
isChess960 = c960; chess960 = isChess960;
find_checkers(); find_checkers();
st->key = compute_key(); st->key = compute_key();
@ -368,16 +368,16 @@ const string Position::to_fen() const {
if (st->castleRights != CASTLES_NONE) if (st->castleRights != CASTLES_NONE)
{ {
if (can_castle_kingside(WHITE)) 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)) 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)) if (can_castle_kingside(BLACK))
fen += isChess960 ? file_to_char(initialKRFile) : 'k'; fen += chess960 ? file_to_char(initialKRFile) : 'k';
if (can_castle_queenside(BLACK)) if (can_castle_queenside(BLACK))
fen += isChess960 ? file_to_char(initialQRFile) : 'q'; fen += chess960 ? file_to_char(initialQRFile) : 'q';
} else } else
fen += '-'; fen += '-';

View file

@ -303,7 +303,7 @@ private:
int castleRightsMask[64]; int castleRightsMask[64];
StateInfo startState; StateInfo startState;
File initialKFile, initialKRFile, initialQRFile; File initialKFile, initialKRFile, initialQRFile;
bool isChess960; bool chess960;
int startPosPlyCounter; int startPosPlyCounter;
int threadID; int threadID;
int64_t nodes; int64_t nodes;
@ -524,7 +524,7 @@ inline bool Position::has_pawn_on_7th(Color c) const {
} }
inline bool Position::is_chess960() const { inline bool Position::is_chess960() const {
return isChess960; return chess960;
} }
inline bool Position::move_is_capture(Move m) const { 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 /// 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. /// 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()); assert(!type.empty());
if (value.empty()) if (v.empty())
return; return;
if ( (type == "check" || type == "button") if ( (type == "check" || type == "button")
!= (value == "true" || value == "false")) != (v == "true" || v == "false"))
return; return;
if (type == "spin") if (type == "spin")
{ {
int v = atoi(value.c_str()); int val = atoi(v.c_str());
if (v < minValue || v > maxValue) if (val < minValue || val > maxValue)
return; return;
} }
currentValue = value; currentValue = v;
} }

View file

@ -32,7 +32,7 @@ public:
Option(bool defaultValue, std::string type = "check"); Option(bool defaultValue, std::string type = "check");
Option(int defaultValue, int minValue, int maxValue); 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; template<typename T> T value() const;
private: private: