[rtems commit] newlib01: Use fopen() instead of freopen()
Sebastian Huber
sebh at rtems.org
Fri Jun 30 12:57:41 UTC 2017
Module: rtems
Branch: master
Commit: 9b07f5efe364bc52b80eff83389ee4bf4a1e0c40
Changeset: http://git.rtems.org/rtems/commit/?id=9b07f5efe364bc52b80eff83389ee4bf4a1e0c40
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Jun 26 08:20:15 2017 +0200
newlib01: Use fopen() instead of freopen()
With global stdio streams, a freopen() would close the global stream
object.
Update #3012.
---
testsuites/libtests/newlib01/init.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/testsuites/libtests/newlib01/init.c b/testsuites/libtests/newlib01/init.c
index f9d3936..af2dc35 100644
--- a/testsuites/libtests/newlib01/init.c
+++ b/testsuites/libtests/newlib01/init.c
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <rtems.h>
+#include <rtems/console.h>
#include <rtems/imfs.h>
#include <rtems/libcsupport.h>
@@ -62,13 +63,13 @@ static void wait(void)
static void worker_task(rtems_task_argument arg)
{
test_context *ctx = &test_instance;
- FILE *file = freopen(&file_path[0], "r+", stdout);
char buf[1] = { 'x' };
size_t n;
- rtems_test_assert(file != NULL);
+ stdout = fopen(&file_path[0], "r+");
+ rtems_test_assert(stdout != NULL);
- n = fwrite(&buf[0], sizeof(buf), 1, file);
+ n = fwrite(&buf[0], sizeof(buf), 1, stdout);
rtems_test_assert(n == 1);
rtems_test_assert(ctx->current == OPEN);
@@ -244,9 +245,16 @@ static void test(void)
rtems_status_code sc;
int rv;
rtems_resource_snapshot snapshot;
+ FILE *file;
ctx->main_task_id = rtems_task_self();
+ /* Fill dynamic file pool in Newlib _GLOBAL_REENT */
+ file = fopen(CONSOLE_DEVICE_NAME, "r+");
+ rtems_test_assert(file != NULL);
+ rv = fclose(file);
+ rtems_test_assert(rv == 0);
+
rtems_resource_snapshot_take(&snapshot);
rv = IMFS_make_generic_node(
More information about the vc
mailing list