From: Lionel Sambuc Date: Fri, 22 Aug 2014 17:11:59 +0000 (+0200) Subject: Fix -DNDEBUG support X-Git-Tag: v3.3.0~55 X-Git-Url: http://zhaoyanbai.com/repos/doxygen.log?a=commitdiff_plain;h=3260d16f34636651fb9ef891a1ffe03fd23b513d;p=minix.git Fix -DNDEBUG support Change-Id: Ib64cef83a646bce2b0afa72b607fb9e5c306e859 --- diff --git a/common/lib/libprop/prop_object.c b/common/lib/libprop/prop_object.c index 9f93e902e..7d61a778c 100644 --- a/common/lib/libprop/prop_object.c +++ b/common/lib/libprop/prop_object.c @@ -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 */ diff --git a/common/lib/libprop/prop_object_impl.h b/common/lib/libprop/prop_object_impl.h index b854524b0..413d87417 100644 --- a/common/lib/libprop/prop_object_impl.h +++ b/common/lib/libprop/prop_object_impl.h @@ -480,7 +480,7 @@ do { \ /* * Language features. */ -#if defined(__NetBSD__) +#if defined(__NetBSD__) || defined(__minix) #include #define _PROP_ARG_UNUSED __unused #else diff --git a/external/bsd/atf/dist/atf-c++/detail/process.cpp b/external/bsd/atf/dist/atf-c++/detail/process.cpp index f7ae6d49d..cd508ee08 100644 --- a/external/bsd/atf/dist/atf-c++/detail/process.cpp +++ b/external/bsd/atf/dist/atf-c++/detail/process.cpp @@ -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); } diff --git a/external/bsd/atf/dist/atf-c/check.c b/external/bsd/atf/dist/atf-c/check.c index d7a908d3c..5a012e185 100644 --- a/external/bsd/atf/dist/atf-c/check.c +++ b/external/bsd/atf/dist/atf-c/check.c @@ -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; } diff --git a/external/bsd/atf/dist/atf-c/detail/process.c b/external/bsd/atf/dist/atf-c/detail/process.c index 9782cd3a3..a16d02040 100644 --- a/external/bsd/atf/dist/atf-c/detail/process.c +++ b/external/bsd/atf/dist/atf-c/detail/process.c @@ -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", diff --git a/external/bsd/atf/dist/atf-sh/atf-sh.cpp b/external/bsd/atf/dist/atf-sh/atf-sh.cpp index d7bc7fc82..f533ea879 100644 --- a/external/bsd/atf/dist/atf-sh/atf-sh.cpp +++ b/external/bsd/atf/dist/atf-sh/atf-sh.cpp @@ -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"; diff --git a/external/bsd/file/dist/src/cdf.c b/external/bsd/file/dist/src/cdf.c index de680b859..0af946662 100644 --- a/external/bsd/file/dist/src/cdf.c +++ b/external/bsd/file/dist/src/cdf.c @@ -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", diff --git a/external/bsd/kyua-cli/dist/store/transaction.cpp b/external/bsd/kyua-cli/dist/store/transaction.cpp index bf24d82ed..4db671c0a 100644 --- a/external/bsd/kyua-cli/dist/store/transaction.cpp +++ b/external/bsd/kyua-cli/dist/store/transaction.cpp @@ -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") % diff --git a/external/bsd/kyua-cli/dist/utils/cmdline/options.cpp b/external/bsd/kyua-cli/dist/utils/cmdline/options.cpp index a086f8477..fede3db59 100644 --- a/external/bsd/kyua-cli/dist/utils/cmdline/options.cpp +++ b/external/bsd/kyua-cli/dist/utils/cmdline/options.cpp @@ -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. /// diff --git a/external/bsd/kyua-cli/dist/utils/datetime.cpp b/external/bsd/kyua-cli/dist/utils/datetime.cpp index d1afbd45e..a69b113a2 100644 --- a/external/bsd/kyua-cli/dist/utils/datetime.cpp +++ b/external/bsd/kyua-cli/dist/utils/datetime.cpp @@ -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); } diff --git a/external/bsd/kyua-cli/dist/utils/process/child.cpp b/external/bsd/kyua-cli/dist/utils/process/child.cpp index 2c7f16287..4a8a3fa20 100644 --- a/external/bsd/kyua-cli/dist/utils/process/child.cpp +++ b/external/bsd/kyua-cli/dist/utils/process/child.cpp @@ -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); diff --git a/external/bsd/kyua-cli/dist/utils/signals/interrupts.cpp b/external/bsd/kyua-cli/dist/utils/signals/interrupts.cpp index 98a769571..49f018221 100644 --- a/external/bsd/kyua-cli/dist/utils/signals/interrupts.cpp +++ b/external/bsd/kyua-cli/dist/utils/signals/interrupts.cpp @@ -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); } diff --git a/external/bsd/kyua-cli/dist/utils/sqlite/database.cpp b/external/bsd/kyua-cli/dist/utils/sqlite/database.cpp index b073c258c..1d234c22a 100644 --- a/external/bsd/kyua-cli/dist/utils/sqlite/database.cpp +++ b/external/bsd/kyua-cli/dist/utils/sqlite/database.cpp @@ -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. diff --git a/external/bsd/kyua-cli/dist/utils/sqlite/statement.cpp b/external/bsd/kyua-cli/dist/utils/sqlite/statement.cpp index f5a9eef9b..facf015c9 100644 --- a/external/bsd/kyua-cli/dist/utils/sqlite/statement.cpp +++ b/external/bsd/kyua-cli/dist/utils/sqlite/statement.cpp @@ -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"); } diff --git a/external/bsd/kyua-testers/dist/atf_result.c b/external/bsd/kyua-testers/dist/atf_result.c index fb0741897..1665cbbbd 100644 --- a/external/bsd/kyua-testers/dist/atf_result.c +++ b/external/bsd/kyua-testers/dist/atf_result.c @@ -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) */ } diff --git a/external/bsd/kyua-testers/dist/error.c b/external/bsd/kyua-testers/dist/error.c index 40fe47b1a..3a159c854 100644 --- a/external/bsd/kyua-testers/dist/error.c +++ b/external/bsd/kyua-testers/dist/error.c @@ -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; diff --git a/external/bsd/kyua-testers/dist/fs.c b/external/bsd/kyua-testers/dist/fs.c index ff1519431..c670c263c 100644 --- a/external/bsd/kyua-testers/dist/fs.c +++ b/external/bsd/kyua-testers/dist/fs.c @@ -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); } diff --git a/external/bsd/kyua-testers/dist/run.c b/external/bsd/kyua-testers/dist/run.c index 4ed1e048b..5fda9e7e8 100644 --- a/external/bsd/kyua-testers/dist/run.c +++ b/external/bsd/kyua-testers/dist/run.c @@ -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(); diff --git a/external/bsd/kyua-testers/dist/stacktrace.c b/external/bsd/kyua-testers/dist/stacktrace.c index c4020a1f1..5014370bd 100644 --- a/external/bsd/kyua-testers/dist/stacktrace.c +++ b/external/bsd/kyua-testers/dist/stacktrace.c @@ -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); diff --git a/minix/net/lwip/tcp.c b/minix/net/lwip/tcp.c index 82632ce8e..1f4fc3d14 100644 --- a/minix/net/lwip/tcp.c +++ b/minix/net/lwip/tcp.c @@ -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));