From 1563462c06bfc09a0d5d1959f7bd2fbfb7e470fc Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Mon, 17 Aug 2026 13:28:24 +0300 Subject: [PATCH] sched: Fix stdio initialization of standard streams when buffering is disabled When stdio buffering is disabled, fgetc/getchar on stdin always returned EOF because fs_cookie and fs_oflags were left uninitialized and lib_fread_unlocked bails out on (fs_oflags & O_RDOK) == 0. Fix this by moving the initialization of the fs_cookie and fs_oflags outside the CONFIG check; these fields need to be initialized regardless of CONFIG_STDIO_DISABLE_BUFFERING. In addition, initializing stream[i].fs_iofunc pointers to NULL is redundant since the task group is allocated with kmm_zalloc/group_zalloc. Zero allocation was already assumed on fs_flags, so remove the unnecessary code. Signed-off-by: Jukka Laitinen --- sched/tls/task_initinfo.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sched/tls/task_initinfo.c b/sched/tls/task_initinfo.c index 8bdf5bd8e6e..20953aaa6a6 100644 --- a/sched/tls/task_initinfo.c +++ b/sched/tls/task_initinfo.c @@ -77,6 +77,7 @@ static void task_init_stream(FAR struct streamlist *list) stream[i].fs_flags |= __FS_FLAG_LBF; /* Line buffering */ # endif /* CONFIG_STDIO_LINEBUFFER */ +#endif /* !CONFIG_STDIO_DISABLE_BUFFERING && CONFIG_STDIO_BUFFER_SIZE > 0 */ /* Save the file description and open flags. Setting the * file descriptor locks this stream. @@ -84,14 +85,6 @@ static void task_init_stream(FAR struct streamlist *list) stream[i].fs_cookie = (FAR void *)(intptr_t)i; stream[i].fs_oflags = i ? O_WRONLY : O_RDONLY; - - /* Assign custom callbacks to NULL. */ - - stream[i].fs_iofunc.read = NULL; - stream[i].fs_iofunc.write = NULL; - stream[i].fs_iofunc.seek = NULL; - stream[i].fs_iofunc.close = NULL; -#endif /* !CONFIG_STDIO_DISABLE_BUFFERING && CONFIG_STDIO_BUFFER_SIZE > 0 */ } } #endif