Fix -DNDEBUG support

Change-Id: Ib64cef83a646bce2b0afa72b607fb9e5c306e859
This commit is contained in:
2014-08-22 19:12:17 +02:00
parent 222afb38ac
commit 3260d16f34
20 changed files with 117 additions and 23 deletions
+8 -2
View File
@@ -143,7 +143,10 @@ get_file(sqlite::database& db, const int64_t file_id)
const std::string contents(
static_cast< const char *>(raw_contents.memory), raw_contents.size);
const bool more = stmt.step();
#if defined(__minix) && !defined(NDEBUG)
const bool more =
#endif /* defined(__minix) && !defined(NDEBUG) */
stmt.step();
INV(!more);
return contents;
@@ -384,7 +387,10 @@ store::detail::get_test_program(backend& backend_, const int64_t id)
fs::path(stmt.safe_column_text("root")),
stmt.safe_column_text("test_suite_name"),
get_metadata(db, stmt.safe_column_int64("metadata_id"))));
const bool more = stmt.step();
#if defined(__minix) && !defined(NDEBUG)
const bool more =
#endif /* defined(__minix) && !defined(NDEBUG) */
stmt.step();
INV(!more);
LD(F("Loaded test program '%s'; getting test cases") %
+8
View File
@@ -41,6 +41,14 @@
namespace cmdline = utils::cmdline;
namespace text = utils::text;
#if defined(__minix) && defined(NDEBUG)
#undef PRE_MSG
#define PRE_MSG(expr, msg) \
do { \
if (!(expr)) \
utils::sanity_failure(utils::precondition, __FILE__, __LINE__, msg); \
} while (0)
#endif /* defined(__minix) && defined(NDEBUG) */
/// Constructs a generic option with both a short and a long name.
///
+4 -1
View File
@@ -272,7 +272,10 @@ datetime::timestamp::now(void)
::timeval data;
{
const int ret = ::gettimeofday(&data, NULL);
#if defined(__minix) && !defined(NDEBUG)
const int ret =
#endif /* defined(__minix) && !defined(NDEBUG) */
::gettimeofday(&data, NULL);
INV(ret != -1);
}
+4 -1
View File
@@ -203,7 +203,10 @@ cxx_exec(const fs::path& program, const process::args_vector& args) throw()
argv[1 + i] = args[i].c_str();
argv[1 + args.size()] = NULL;
const int ret = ::execv(program.c_str(),
#if defined(__minix) && !defined(NDEBUG)
const int ret =
#endif /* defined(__minix) && !defined(NDEBUG) */
::execv(program.c_str(),
(char* const*)(unsigned long)(const void*)argv);
const int original_errno = errno;
assert(ret == -1);
+8 -2
View File
@@ -164,7 +164,10 @@ mask_signals(void)
sigaddset(&mask, SIGHUP);
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGTERM);
const int ret = ::sigprocmask(SIG_BLOCK, &mask, &old_sigmask);
#if defined(__minix) && !defined(NDEBUG)
const int ret =
#endif /* defined(__minix) && !defined(NDEBUG) */
::sigprocmask(SIG_BLOCK, &mask, &old_sigmask);
INV(ret != -1);
}
@@ -173,7 +176,10 @@ mask_signals(void)
static void
unmask_signals(void)
{
const int ret = ::sigprocmask(SIG_SETMASK, &old_sigmask, NULL);
#if defined(__minix) && !defined(NDEBUG)
const int ret =
#endif /* defined(__minix) && !defined(NDEBUG) */
::sigprocmask(SIG_SETMASK, &old_sigmask, NULL);
INV(ret != -1);
}
+4 -1
View File
@@ -110,7 +110,10 @@ struct utils::sqlite::database::impl {
close(void)
{
PRE(db != NULL);
int error = ::sqlite3_close(db);
#if defined(__minix) && !defined(NDEBUG)
int error =
#endif /* defined(__minix) && !defined(NDEBUG) */
::sqlite3_close(db);
// For now, let's consider a return of SQLITE_BUSY an error. We should
// not be trying to close a busy database in our code. Maybe revisit
// this later to raise busy errors as exceptions.
+12 -1
View File
@@ -171,7 +171,10 @@ sqlite::statement::~statement(void)
void
sqlite::statement::step_without_results(void)
{
const bool data = step();
#if defined(__minix) && !defined(NDEBUG)
const bool data =
#endif /* defined(__minix) && !defined(NDEBUG) */
step();
INV_MSG(!data, "The statement should not have produced any rows, but it "
"did");
}
@@ -610,6 +613,14 @@ void
sqlite::statement::clear_bindings(void)
{
const int error = ::sqlite3_clear_bindings(_pimpl->stmt);
#if defined(__minix) && defined(NDEBUG)
#undef PRE_MSG
#define PRE_MSG(expr, msg) \
do { \
if (!(expr)) \
utils::sanity_failure(utils::precondition, __FILE__, __LINE__, msg); \
} while (0)
#endif /* defined(__minix) && defined(NDEBUG) */
PRE_MSG(error == SQLITE_OK, "SQLite3 contract has changed; it should "
"only return SQLITE_OK");
}