fix compiler warnings, round 5
Posted: Mon Apr 28, 2014 11:08 pm
Two more: don't redefine NDEBUG when NDEBUG=1 (config=release build) and use tmpfile instead of tmpnam:
This is probably enough for now. There are a couple of warnings in physfs and expat still, but these are taken from upstream with no obvious fixes. The changes I listed so far make the build very clean.
<-- from http://www.gnu.org/software/libc/manual ... Files.htmlWarning: Between the time the pathname is constructed and the file is created another process might have created a file with the same name using tmpnam, leading to a possible security hole. The implementation generates names which can hardly be predicted, but when opening the file you should use the O_EXCL flag. Using tmpfile or mkstemp is a safe way to avoid this problem.
This is probably enough for now. There are a couple of warnings in physfs and expat still, but these are taken from upstream with no obvious fixes. The changes I listed so far make the build very clean.
Code: Select all
diff --git a/src/lpeg/lptypes.h b/src/lpeg/lptypes.h
index 90a6eff..5512e2b 100644
--- a/src/lpeg/lptypes.h
+++ b/src/lpeg/lptypes.h
@@ -9,7 +9,7 @@
#define lptypes_h
-#if !defined(LPEG_DEBUG)
+#if !defined(LPEG_DEBUG) && !defined(NDEBUG)
#define NDEBUG
#endif
diff --git a/src/luaprofiler/core_profiler.c b/src/luaprofiler/core_profiler.c
index 0e15072..f82c544 100644
--- a/src/luaprofiler/core_profiler.c
+++ b/src/luaprofiler/core_profiler.c
@@ -130,8 +130,7 @@ lprofP_STATE* lprofP_init_core_profiler(const char *_out_filename, int isto_prin
out_filename = (_out_filename) ? (_out_filename):(OUT_FILENAME);
/* the random string to build the logname is extracted */
- /* from 'tmpnam()' (the '/tmp/' part is deleted) */
- randstr = tmpnam(NULL);
+ randstr = (char *)tmpfile();
for (s = strtok(randstr, "/\\"); s; s = strtok(NULL, "/\\")) {
randstr = s;
}