Fix -DNDEBUG support
Change-Id: Ib64cef83a646bce2b0afa72b607fb9e5c306e859
This commit is contained in:
parent
222afb38ac
commit
3260d16f34
20 changed files with 117 additions and 23 deletions
|
@ -987,7 +987,7 @@ _prop_object_internalize_unmap_file(
|
|||
(void) munmap(mf->poimf_xml, mf->poimf_mapsize);
|
||||
_PROP_FREE(mf, M_TEMP);
|
||||
#else
|
||||
assert(0);
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
#endif /* !_KERNEL && !_STANDALONE */
|
||||
|
|
|
@ -480,7 +480,7 @@ do { \
|
|||
/*
|
||||
* Language features.
|
||||
*/
|
||||
#if defined(__NetBSD__)
|
||||
#if defined(__NetBSD__) || defined(__minix)
|
||||
#include <sys/cdefs.h>
|
||||
#define _PROP_ARG_UNUSED __unused
|
||||
#else
|
||||
|
|
|
@ -296,7 +296,10 @@ impl::child::~child(void)
|
|||
::kill(atf_process_child_pid(&m_child), SIGTERM);
|
||||
|
||||
atf_process_status_t s;
|
||||
atf_error_t err = atf_process_child_wait(&m_child, &s);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
atf_error_t err =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
atf_process_child_wait(&m_child, &s);
|
||||
INV(!atf_is_error(err));
|
||||
atf_process_status_fini(&s);
|
||||
}
|
||||
|
|
10
external/bsd/atf/dist/atf-c/check.c
vendored
10
external/bsd/atf/dist/atf-c/check.c
vendored
|
@ -101,7 +101,10 @@ cleanup_tmpdir(const atf_fs_path_t *dir, const atf_fs_path_t *outfile,
|
|||
}
|
||||
|
||||
{
|
||||
atf_error_t err = atf_fs_rmdir(dir);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
atf_error_t err =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
atf_fs_rmdir(dir);
|
||||
INV(!atf_is_error(err));
|
||||
}
|
||||
}
|
||||
|
@ -468,7 +471,10 @@ atf_check_exec_array(const char *const *argv, atf_check_result_t *r)
|
|||
|
||||
err = atf_check_result_init(r, argv, &dir);
|
||||
if (atf_is_error(err)) {
|
||||
atf_error_t err2 = atf_fs_rmdir(&dir);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
atf_error_t err2 =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
atf_fs_rmdir(&dir);
|
||||
INV(!atf_is_error(err2));
|
||||
goto out;
|
||||
}
|
||||
|
|
7
external/bsd/atf/dist/atf-c/detail/process.c
vendored
7
external/bsd/atf/dist/atf-c/detail/process.c
vendored
|
@ -103,6 +103,7 @@ const int atf_process_stream_type_inherit = 3;
|
|||
const int atf_process_stream_type_redirect_fd = 4;
|
||||
const int atf_process_stream_type_redirect_path = 5;
|
||||
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
static
|
||||
bool
|
||||
stream_is_valid(const atf_process_stream_t *sb)
|
||||
|
@ -113,6 +114,7 @@ stream_is_valid(const atf_process_stream_t *sb)
|
|||
(sb->m_type == atf_process_stream_type_redirect_fd) ||
|
||||
(sb->m_type == atf_process_stream_type_redirect_path);
|
||||
}
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
|
||||
atf_error_t
|
||||
atf_process_stream_init_capture(atf_process_stream_t *sb)
|
||||
|
@ -604,7 +606,10 @@ do_exec(void *v)
|
|||
if (ea->m_prehook != NULL)
|
||||
ea->m_prehook();
|
||||
|
||||
const int ret = const_execvp(atf_fs_path_cstring(ea->m_prog), ea->m_argv);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
const int ret =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
const_execvp(atf_fs_path_cstring(ea->m_prog), ea->m_argv);
|
||||
const int errnocopy = errno;
|
||||
INV(ret == -1);
|
||||
fprintf(stderr, "exec(%s) failed: %s\n",
|
||||
|
|
5
external/bsd/atf/dist/atf-sh/atf-sh.cpp
vendored
5
external/bsd/atf/dist/atf-sh/atf-sh.cpp
vendored
|
@ -142,7 +142,10 @@ atf_sh::main(void)
|
|||
// Don't bother keeping track of the memory allocated by construct_argv:
|
||||
// we are going to exec or die immediately.
|
||||
|
||||
const int ret = execv(shell.c_str(), const_cast< char** >(argv));
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
const int ret =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
execv(shell.c_str(), const_cast< char** >(argv));
|
||||
INV(ret == -1);
|
||||
std::cerr << "Failed to execute " << shell << ": " << std::strerror(errno)
|
||||
<< "\n";
|
||||
|
|
10
external/bsd/file/dist/src/cdf.c
vendored
10
external/bsd/file/dist/src/cdf.c
vendored
|
@ -345,9 +345,15 @@ ssize_t
|
|||
cdf_read_sector(const cdf_info_t *info, void *buf, size_t offs, size_t len,
|
||||
const cdf_header_t *h, cdf_secid_t id)
|
||||
{
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
size_t ss = CDF_SEC_SIZE(h);
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
size_t pos = CDF_SEC_POS(h, id);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
/* MINIX: It seems even with NDEBUG, when built as a tool assert is
|
||||
* still defined on linux. */
|
||||
assert(ss == len);
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
return cdf_read(info, (off_t)pos, ((char *)buf) + offs, len);
|
||||
}
|
||||
|
||||
|
@ -355,9 +361,13 @@ ssize_t
|
|||
cdf_read_short_sector(const cdf_stream_t *sst, void *buf, size_t offs,
|
||||
size_t len, const cdf_header_t *h, cdf_secid_t id)
|
||||
{
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
size_t ss = CDF_SHORT_SEC_SIZE(h);
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
size_t pos = CDF_SHORT_SEC_POS(h, id);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
assert(ss == len);
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
if (pos > CDF_SEC_SIZE(h) * sst->sst_len) {
|
||||
DPRINTF(("Out of bounds read %" SIZE_T_FORMAT "u > %"
|
||||
SIZE_T_FORMAT "u\n",
|
||||
|
|
10
external/bsd/kyua-cli/dist/store/transaction.cpp
vendored
10
external/bsd/kyua-cli/dist/store/transaction.cpp
vendored
|
@ -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") %
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
3
external/bsd/kyua-testers/dist/atf_result.c
vendored
3
external/bsd/kyua-testers/dist/atf_result.c
vendored
|
@ -679,6 +679,9 @@ convert_result(const enum atf_status status, const int status_arg,
|
|||
}
|
||||
|
||||
assert(false);
|
||||
#if defined(__minix) && defined(NDEBUG)
|
||||
abort();
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
}
|
||||
|
||||
|
||||
|
|
6
external/bsd/kyua-testers/dist/error.c
vendored
6
external/bsd/kyua-testers/dist/error.c
vendored
|
@ -522,8 +522,10 @@ kyua_error_t
|
|||
kyua_oom_error_new(void)
|
||||
{
|
||||
// This is idempotent; no need to ensure that we call it only once.
|
||||
const bool ok = error_init(&oom_error, kyua_oom_error_type, NULL, 0,
|
||||
oom_format);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
const bool ok =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
error_init(&oom_error, kyua_oom_error_type, NULL, 0, oom_format);
|
||||
assert(ok);
|
||||
|
||||
return &oom_error;
|
||||
|
|
5
external/bsd/kyua-testers/dist/fs.c
vendored
5
external/bsd/kyua-testers/dist/fs.c
vendored
|
@ -384,7 +384,10 @@ unmount_with_umount8(const char* mount_point)
|
|||
if (pid == -1) {
|
||||
return kyua_libc_error_new(errno, "fork() failed");
|
||||
} else if (pid == 0) {
|
||||
const int ret = execlp(UMOUNT, "umount", mount_point, NULL);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
const int ret =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
execlp(UMOUNT, "umount", mount_point, NULL);
|
||||
assert(ret == -1);
|
||||
err(EXIT_FAILURE, "Failed to execute " UMOUNT);
|
||||
}
|
||||
|
|
20
external/bsd/kyua-testers/dist/run.c
vendored
20
external/bsd/kyua-testers/dist/run.c
vendored
|
@ -112,7 +112,10 @@ mask_handlers(const int operation)
|
|||
sigaddset(&mask, SIGINT);
|
||||
sigaddset(&mask, SIGHUP);
|
||||
sigaddset(&mask, SIGTERM);
|
||||
const int ret = sigprocmask(operation, &mask, NULL);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
const int ret =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
sigprocmask(operation, &mask, NULL);
|
||||
assert(ret != -1);
|
||||
}
|
||||
|
||||
|
@ -209,7 +212,10 @@ setup_signal(const int signo, void (*handler)(const int),
|
|||
sigemptyset(&sa.sa_mask);
|
||||
sa.sa_flags = SA_RESTART;
|
||||
|
||||
const int ret = sigaction(signo, &sa, old_sa);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
const int ret =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
sigaction(signo, &sa, old_sa);
|
||||
assert(ret != -1);
|
||||
}
|
||||
|
||||
|
@ -227,7 +233,10 @@ setup_timer(const int seconds, struct itimerval* old_itimerval)
|
|||
new_timer.it_interval.tv_usec = 0;
|
||||
new_timer.it_value.tv_sec = seconds;
|
||||
new_timer.it_value.tv_usec = 0;
|
||||
const int ret = setitimer(ITIMER_REAL, &new_timer, old_itimerval);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
const int ret =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
setitimer(ITIMER_REAL, &new_timer, old_itimerval);
|
||||
assert(ret != -1);
|
||||
}
|
||||
|
||||
|
@ -471,7 +480,10 @@ kyua_error_t
|
|||
kyua_run_wait(const pid_t pid, int* status, bool* timed_out)
|
||||
{
|
||||
int tmp_status;
|
||||
const pid_t waited_pid = waitpid(pid, &tmp_status, 0);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
const pid_t waited_pid =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
waitpid(pid, &tmp_status, 0);
|
||||
assert(pid == waited_pid);
|
||||
|
||||
protect();
|
||||
|
|
5
external/bsd/kyua-testers/dist/stacktrace.c
vendored
5
external/bsd/kyua-testers/dist/stacktrace.c
vendored
|
@ -126,7 +126,10 @@ run_gdb(const char* program, const char* core_name, FILE* output)
|
|||
}
|
||||
|
||||
(void)close(STDIN_FILENO);
|
||||
const int input_fd = open("/dev/null", O_RDONLY);
|
||||
#if defined(__minix) && !defined(NDEBUG)
|
||||
const int input_fd =
|
||||
#endif /* defined(__minix) && !defined(NDEBUG) */
|
||||
open("/dev/null", O_RDONLY);
|
||||
assert(input_fd == STDIN_FILENO);
|
||||
|
||||
const int output_fd = fileno(output);
|
||||
|
|
|
@ -997,7 +997,9 @@ static int tcp_get_opt(struct socket * sock, endpoint_t endpt,
|
|||
cp_grant_id_t grant)
|
||||
{
|
||||
nwio_tcpopt_t tcpopt;
|
||||
#if !defined(NDEBUG)
|
||||
struct tcp_pcb * pcb = (struct tcp_pcb *) sock->pcb;
|
||||
#endif /* !defined(NDEBUG) */
|
||||
|
||||
debug_tcp_print("socket num %ld", get_sock_num(sock));
|
||||
|
||||
|
@ -1013,7 +1015,9 @@ static int tcp_set_opt(struct socket * sock, endpoint_t endpt,
|
|||
cp_grant_id_t grant)
|
||||
{
|
||||
nwio_tcpopt_t tcpopt;
|
||||
#if !defined(NDEBUG)
|
||||
struct tcp_pcb * pcb = (struct tcp_pcb *) sock->pcb;
|
||||
#endif /* !defined(NDEBUG) */
|
||||
|
||||
debug_tcp_print("socket num %ld", get_sock_num(sock));
|
||||
|
||||
|
|
Loading…
Reference in a new issue