提交 bf65f53f 编写于 作者: F Filip Navara 提交者: Anthony Liguori

Remove setvbuf(<handle>, NULL, _IOLBF, 0) calls for Win32

On Win32 the setvbuf function requires the last parameter to be size between 2 and INT_MAX bytes, so the calls always failed. Since the whole point of the calls is to set line-buffered mode for the file handle and that's not supported on Win32 anyway, conditionally remove them.
Signed-off-by: NFilip Navara <filip.navara@gmail.com>
Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
上级 8fde6546
...@@ -1491,7 +1491,8 @@ void cpu_set_log(int log_flags) ...@@ -1491,7 +1491,8 @@ void cpu_set_log(int log_flags)
static char logfile_buf[4096]; static char logfile_buf[4096];
setvbuf(logfile, logfile_buf, _IOLBF, sizeof(logfile_buf)); setvbuf(logfile, logfile_buf, _IOLBF, sizeof(logfile_buf));
} }
#else #elif !defined(_WIN32)
/* Win32 doesn't support line-buffering and requires size >= 2 */
setvbuf(logfile, NULL, _IOLBF, 0); setvbuf(logfile, NULL, _IOLBF, 0);
#endif #endif
log_append = 1; log_append = 1;
......
...@@ -5755,7 +5755,10 @@ int main(int argc, char **argv, char **envp) ...@@ -5755,7 +5755,10 @@ int main(int argc, char **argv, char **envp)
exit(1); exit(1);
} }
#ifndef _WIN32
/* Win32 doesn't support line-buffering and requires size >= 2 */
setvbuf(stdout, NULL, _IOLBF, 0); setvbuf(stdout, NULL, _IOLBF, 0);
#endif
init_timers(); init_timers();
if (init_timer_alarm() < 0) { if (init_timer_alarm() < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册