From: Marco Costalba Date: Thu, 18 Sep 2008 08:53:14 +0000 (+0100) Subject: Document where we want a uint16_t instead of a uint64_t X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=94929c36bd6cf484d9f110188b58e7bcccc2f544 Document where we want a uint16_t instead of a uint64_t This patch removes some conversion warnings and better describe where we are going to expect a small integer. Signed-off-by: Marco Costalba --- diff --git a/src/book.cpp b/src/book.cpp index bd2f4818..fcc8c0d4 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -340,7 +340,7 @@ namespace { uint64_t book_color_key(const Position &pos); uint64_t read_integer(FILE *file, int size); - + uint16_t read_small_integer(FILE *file, int size); } @@ -485,10 +485,10 @@ void Book::read_entry(BookEntry& entry, int n) const { } entry.key = read_integer(bookFile, 8); - entry.move = read_integer(bookFile, 2); - entry.count = read_integer(bookFile, 2); - entry.n = read_integer(bookFile, 2); - entry.sum = read_integer(bookFile, 2); + entry.move = read_small_integer(bookFile, 2); + entry.count = read_small_integer(bookFile, 2); + entry.n = read_small_integer(bookFile, 2); + entry.sum = read_small_integer(bookFile, 2); } @@ -555,7 +555,7 @@ namespace { uint64_t read_integer(FILE *file, int size) { - uint64_t n = 0ULL;; + uint64_t n = 0ULL; int i; int b; @@ -575,4 +575,12 @@ namespace { return n; } + uint16_t read_small_integer(FILE *file, int size) { + + assert(size > 0 && size <= 5); // 16 bit integer + uint64_t n = read_integer(file, size); + assert(n == (uint16_t)n); + return (uint16_t)n; + } + }