From 7c18bfddade8d5c4fd8a06190427ad2c9949c3f9 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 13 Aug 2008 00:32:32 +0000 Subject: [PATCH] Fix read()/write() prototype git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@820 42af7a65-404d-4744-a932-0658087f49c3 --- ChangeLog | 2 ++ Documentation/NuttX.html | 2 ++ Documentation/NuttxUserGuide.html | 16 ++++++++-------- fs/fs_read.c | 2 +- fs/fs_write.c | 4 ++-- include/unistd.h | 28 ++++++++++++++-------------- 6 files changed, 29 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98ecf7778c..6378c34cec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -402,4 +402,6 @@ * Removed duplicate getenv() implementation in /lib * Correct detection of End-of-File in fgets * Implement sh and crude script handler in NSH + * Fix prototype of read() and write(). Need to use ssize_t and size_t, not + int and unsigned int. diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index 6356422c5c..72b61cb91a 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -1036,6 +1036,8 @@ nuttx-0.3.13 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> * Removed duplicate getenv() implementation in /lib * Correct detection of End-of-File in fgets * Implement sh and crude script handler in NSH + * Fix prototype of read() and write(). Need to use ssize_t and size_t, not + int and unsigned int. pascal-0.1.3 2008-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html index a6e6ea90d0..e5cb13eb3b 100644 --- a/Documentation/NuttxUserGuide.html +++ b/Documentation/NuttxUserGuide.html @@ -5917,18 +5917,18 @@ interface of the same name.

2.11.3 Directory Operations

diff --git a/fs/fs_read.c b/fs/fs_read.c index 7500d35994..51d10830a7 100644 --- a/fs/fs_read.c +++ b/fs/fs_read.c @@ -53,7 +53,7 @@ * Global Functions ****************************************************************************/ -int read(int fd, FAR void *buf, unsigned int nbytes) +ssize_t read(int fd, FAR void *buf, size_t nbytes) { FAR struct filelist *list; int ret = EBADF; diff --git a/fs/fs_write.c b/fs/fs_write.c index 28fa8664cc..19652ad592 100644 --- a/fs/fs_write.c +++ b/fs/fs_write.c @@ -58,7 +58,7 @@ * Global Functions ****************************************************************************/ -/******************************************************************************************** +/*************************************************************************** * Function: write * * Description: @@ -108,7 +108,7 @@ * ********************************************************************************************/ -int write(int fd, FAR const void *buf, unsigned int nbytes) +ssize_t write(int fd, FAR const void *buf, size_t nbytes) { #if CONFIG_NFILE_DESCRIPTORS > 0 FAR struct filelist *list; diff --git a/include/unistd.h b/include/unistd.h index e2b88686fa..ae34e3d6aa 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -120,32 +120,32 @@ EXTERN int optopt; /* unrecognized option character */ /* Task Control Interfaces */ -EXTERN pid_t getpid(void); -EXTERN void _exit(int status) noreturn_function; +EXTERN pid_t getpid(void); +EXTERN void _exit(int status) noreturn_function; EXTERN unsigned int sleep(unsigned int seconds); -EXTERN void usleep(unsigned long usec); +EXTERN void usleep(unsigned long usec); /* File descriptor operations */ -EXTERN int close(int fd); -EXTERN int dup(int fd); -EXTERN int dup2(int fd1, int fd2); -EXTERN int fsync(int fd); -EXTERN off_t lseek(int fd, off_t offset, int whence); -EXTERN int read(int fd, FAR void *buf, unsigned int nbytes); -EXTERN int write(int fd, FAR const void *buf, unsigned int nbytes); +EXTERN int close(int fd); +EXTERN int dup(int fd); +EXTERN int dup2(int fd1, int fd2); +EXTERN int fsync(int fd); +EXTERN off_t lseek(int fd, off_t offset, int whence); +EXTERN ssize_t read(int fd, FAR void *buf, size_t nbytes); +EXTERN ssize_t write(int fd, FAR const void *buf, size_t nbytes); /* Special devices */ -EXTERN int pipe(int filedes[2]); +EXTERN int pipe(int filedes[2]); /* File path operations */ -EXTERN int unlink(FAR const char *pathname); -EXTERN int rmdir(FAR const char *pathname); +EXTERN int unlink(FAR const char *pathname); +EXTERN int rmdir(FAR const char *pathname); /* Other */ -EXTERN int getopt(int argc, FAR char *const argv[], FAR const char *optstring); +EXTERN int getopt(int argc, FAR char *const argv[], FAR const char *optstring); #undef EXTERN #if defined(__cplusplus)