Commit 5e01674b authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by Hiroshi Mimaki

Should not use `assert` with expressions with side-effect; ref #4981

`assert()` can be completely removed when `NDEBUG` is set.
parent b652a4ff
...@@ -53,7 +53,6 @@ mkdtemp(char *temp) ...@@ -53,7 +53,6 @@ mkdtemp(char *temp)
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h> #include <unistd.h>
#include <sys/un.h> #include <sys/un.h>
#include <assert.h>
#include <fcntl.h> #include <fcntl.h>
#endif #endif
...@@ -117,10 +116,8 @@ mrb_io_test_io_setup(mrb_state *mrb, mrb_value self) ...@@ -117,10 +116,8 @@ mrb_io_test_io_setup(mrb_state *mrb, mrb_value self)
char *tmpdir; char *tmpdir;
wd_save = open(".", O_DIRECTORY); wd_save = open(".", O_DIRECTORY);
tmpdir = getenv("TMPDIR"); tmpdir = getenv("TMPDIR");
if (tmpdir) if (tmpdir) chdir(tmpdir);
assert(!chdir(tmpdir)); else chdir("/tmp");
else
assert(!chdir("/tmp"));
} }
#endif #endif
...@@ -220,7 +217,7 @@ mrb_io_test_io_cleanup(mrb_state *mrb, mrb_value self) ...@@ -220,7 +217,7 @@ mrb_io_test_io_cleanup(mrb_state *mrb, mrb_value self)
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
if(!socket_available_p) { if(!socket_available_p) {
assert(!fchdir(wd_save)); fchdir(wd_save);
close(wd_save); close(wd_save);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment