Skip to content

Commit

Permalink
stdio.h:Remove unnecessary header file
Browse files Browse the repository at this point in the history
Error: net/telnet.c:725:11: error: implicit declaration of function 'lib_free' [-Werror=implicit-function-declaration]
  725 |           lib_free(devpath);
      |           ^~~~~~~~

Error: /github/workspace/sources/nuttx/libs/libc/netdb/lib_netdb.h:117:1: error: unknown type name 'bool'
  117 | bool convert_hostent(FAR const struct hostent_s *in,
      | ^~~~

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
  • Loading branch information
anjiahao1 committed Nov 14, 2024
1 parent 1d1ef52 commit 4f7067a
Show file tree
Hide file tree
Showing 15 changed files with 75 additions and 54 deletions.
1 change: 1 addition & 0 deletions drivers/net/telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <nuttx/signal.h>
#include <nuttx/mutex.h>
#include <nuttx/fs/fs.h>
#include <nuttx/lib/lib.h>
#include <nuttx/net/net.h>
#include <nuttx/net/telnet.h>

Expand Down
52 changes: 1 addition & 51 deletions include/nuttx/fs/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include <sys/uio.h>
#include <sys/types.h>

#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdbool.h>
Expand Down Expand Up @@ -424,33 +424,6 @@ struct inode

#define FSNODE_SIZE(n) (sizeof(struct inode) + (n))

/* Definitions for custom stream operations with fopencookie. The
* implementation is as defined in Standard C library (libc). The only
* difference is that we use off_t instead of off64_t. This means
* off_t is int64_t if CONFIG_FS_LARGEFILE is defined and int32_t if not.
*
* These callbacks can either lead to custom functions if fopencookie is used
* or to standard file system functions if not.
*/

typedef CODE ssize_t cookie_read_function_t(FAR void *cookie, FAR char *buf,
size_t size);
typedef CODE ssize_t cookie_write_function_t(FAR void *cookie,
FAR const char *buf,
size_t size);
typedef CODE off_t cookie_seek_function_t(FAR void *cookie,
FAR off_t *offset,
int whence);
typedef CODE int cookie_close_function_t(FAR void *cookie);

typedef struct cookie_io_functions_t
{
FAR cookie_read_function_t *read;
FAR cookie_write_function_t *write;
FAR cookie_seek_function_t *seek;
FAR cookie_close_function_t *close;
} cookie_io_functions_t;

/* This is the underlying representation of an open file. A file
* descriptor is an index into an array of such types. The type associates
* the file descriptor to the file state and to a set of inode operations.
Expand Down Expand Up @@ -542,29 +515,6 @@ struct filelist
*/

#ifdef CONFIG_FILE_STREAM
struct file_struct
{
sq_entry_t fs_entry; /* Entry of file stream */
rmutex_t fs_lock; /* Recursive lock */
cookie_io_functions_t fs_iofunc; /* Callbacks to user / system functions */
FAR void *fs_cookie; /* Pointer to file descriptor / cookie struct */
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
FAR char *fs_bufstart; /* Pointer to start of buffer */
FAR char *fs_bufend; /* Pointer to 1 past end of buffer */
FAR char *fs_bufpos; /* Current position in buffer */
FAR char *fs_bufread; /* Pointer to 1 past last buffered read char. */
# if CONFIG_STDIO_BUFFER_SIZE > 0
char fs_buffer[CONFIG_STDIO_BUFFER_SIZE];
# endif
#endif
uint16_t fs_oflags; /* Open mode flags */
uint8_t fs_flags; /* Stream flags */
#if CONFIG_NUNGET_CHARS > 0
uint8_t fs_nungotten; /* The number of characters buffered for ungetc */
char fs_ungotten[CONFIG_NUNGET_CHARS];
#endif
};

struct streamlist
{
mutex_t sl_lock; /* For thread safety */
Expand Down
1 change: 0 additions & 1 deletion include/nuttx/lib/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ extern "C"
/* Functions contained in lib_getstreams.c **********************************/

FAR struct streamlist *lib_get_streams(void);
FAR struct file_struct *lib_get_stream(int fd);
#endif /* CONFIG_FILE_STREAM */

/* Functions defined in lib_srand.c *****************************************/
Expand Down
1 change: 1 addition & 0 deletions include/pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <unistd.h> /* For getpid */
#include <signal.h> /* Needed for sigset_t, includes this file */
#include <time.h> /* Needed for struct timespec */
#include <sched.h>

#ifdef CONFIG_PTHREAD_SPINLOCKS
/* The architecture specific spinlock.h header file must provide the
Expand Down
58 changes: 56 additions & 2 deletions include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#include <stdarg.h>
#include <time.h>

#include <nuttx/fs/fs.h>
#include <nuttx/lib/lib.h>
#include <nuttx/mutex.h>
#include <nuttx/queue.h>

/****************************************************************************
* Pre-processor Definitions
Expand Down Expand Up @@ -109,8 +109,58 @@
* Public Type Definitions
****************************************************************************/

/* Definitions for custom stream operations with fopencookie. The
* implementation is as defined in Standard C library (libc). The only
* difference is that we use off_t instead of off64_t. This means
* off_t is int64_t if CONFIG_FS_LARGEFILE is defined and int32_t if not.
*
* These callbacks can either lead to custom functions if fopencookie is used
* or to standard file system functions if not.
*/

typedef CODE ssize_t cookie_read_function_t(FAR void *cookie, FAR char *buf,
size_t size);
typedef CODE ssize_t cookie_write_function_t(FAR void *cookie,
FAR const char *buf,
size_t size);
typedef CODE off_t cookie_seek_function_t(FAR void *cookie,
FAR off_t *offset,
int whence);
typedef CODE int cookie_close_function_t(FAR void *cookie);

typedef struct cookie_io_functions_t
{
FAR cookie_read_function_t *read;
FAR cookie_write_function_t *write;
FAR cookie_seek_function_t *seek;
FAR cookie_close_function_t *close;
} cookie_io_functions_t;

/* Streams */

struct file_struct
{
sq_entry_t fs_entry; /* Entry of file stream */
rmutex_t fs_lock; /* Recursive lock */
cookie_io_functions_t fs_iofunc; /* Callbacks to user / system functions */
FAR void *fs_cookie; /* Pointer to file descriptor / cookie struct */
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
FAR char *fs_bufstart; /* Pointer to start of buffer */
FAR char *fs_bufend; /* Pointer to 1 past end of buffer */
FAR char *fs_bufpos; /* Current position in buffer */
FAR char *fs_bufread; /* Pointer to 1 past last buffered read char. */
# if CONFIG_STDIO_BUFFER_SIZE > 0
char fs_buffer[CONFIG_STDIO_BUFFER_SIZE];
# endif
#endif
uint16_t fs_oflags; /* Open mode flags */
uint8_t fs_flags; /* Stream flags */
#if CONFIG_NUNGET_CHARS > 0
uint8_t fs_nungotten; /* The number of characters buffered for ungetc */
char fs_ungotten[CONFIG_NUNGET_CHARS];
#endif
};

typedef struct file_struct FILE;

/****************************************************************************
Expand Down Expand Up @@ -263,6 +313,10 @@ int remove(FAR const char *path);
* apps/system/popen for implementation.
*/

#ifdef CONFIG_FILE_STREAM
FAR struct file_struct *lib_get_stream(int fd);
#endif

#ifndef __KERNEL__
int pclose(FILE *stream);
FILE *popen(FAR const char *command, FAR const char *mode) popen_like;
Expand Down
2 changes: 2 additions & 0 deletions libs/libc/locale/lib_iconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <stdint.h>
#include <locale.h>

#include <nuttx/lib/lib.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions libs/libc/misc/lib_ftok.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <string.h>
#include <stdio.h>

#include <nuttx/lib/lib.h>

/****************************************************************************
* Public Functions
****************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions libs/libc/netdb/lib_netdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

#include <netdb.h>
#include <stdio.h>
#include <stdbool.h>

#ifdef CONFIG_LIBC_NETDB

Expand Down
1 change: 1 addition & 0 deletions libs/libc/sched/sched_dumpstack.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <sys/types.h>

#include <stdio.h>
#include <sched.h>
#include <debug.h>

/****************************************************************************
Expand Down
2 changes: 2 additions & 0 deletions libs/libc/signal/sig_psignal.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include <errno.h>
#include <unistd.h>

#include <nuttx/sched.h>

/* Uses streams... not available to kernel code */

#ifndef __KERNEL__
Expand Down
2 changes: 2 additions & 0 deletions libs/libc/stdio/lib_fgetwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <errno.h>
#include <string.h>

#include <nuttx/lib/lib.h>

#ifdef CONFIG_FILE_STREAM

/****************************************************************************
Expand Down
2 changes: 2 additions & 0 deletions libs/libc/stdio/lib_remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <unistd.h>
#include <stdio.h>

#include <nuttx/lib/lib.h>

/****************************************************************************
* Public Functions
****************************************************************************/
Expand Down
2 changes: 2 additions & 0 deletions libs/libc/stdio/lib_ungetwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <fcntl.h>
#include <string.h>

#include <nuttx/lib/lib.h>

#ifdef CONFIG_FILE_STREAM

/****************************************************************************
Expand Down
1 change: 1 addition & 0 deletions libs/libc/stdio/lib_vasprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
****************************************************************************/

#include <nuttx/streams.h>
#include <nuttx/lib/lib.h>

/****************************************************************************
* Pre-processor Definitions
Expand Down
1 change: 1 addition & 0 deletions libs/libc/unistd/lib_getpass.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
****************************************************************************/

#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
Expand Down

0 comments on commit 4f7067a

Please sign in to comment.