Updated comments

This commit is contained in:
Gregory Nutt 2014-11-29 17:39:40 -06:00
parent 1fa790cf8e
commit 7ad7163bd3
5 changed files with 33 additions and 8 deletions

View File

@ -69,7 +69,7 @@
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
* -1 on failure withi errno set properly:
* -1 on failure with errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.

View File

@ -638,7 +638,7 @@ int close_blockdriver(FAR struct inode *inode);
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
* -1 on failure withi errno set properly:
* -1 on failure with errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.

View File

@ -84,7 +84,7 @@ extern "C"
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
* -1 on failure withi errno set properly:
* -1 on failure with errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.

View File

@ -76,7 +76,20 @@ config LIBC_IOCTL_VARIADIC
WARNING: Use of this option could cause subtle system errors is
the third argument is omitted or if the sizeof the thread argument
is anything other than sizeof (unsigned long).
is anything other than sizeof (unsigned long). Most small integers
will be promoted to 'int'. The following assertion appears in ioctl():
DEBUGASSERT(sizeof(int) == sizeof(unsigned long) &&
sizeof(FAR void *) == sizeof(unsigned long));
Do not enable this option if the above is not true. 32-bit ARM
should pass this test with all three types having sizeof(type) == 4
bytes. 'float' should also be tested. But 'long long' and 'double'
are out of the question! Don't event try to pass them.
And what will happen if no third argument is passed? In most cases,
this should just result in a garbage value for arg. But you may
discover cases where something worse happens!
config LIB_RAND_ORDER
int "Order of the random number generate"

View File

@ -42,6 +42,7 @@
#include <sys/ioctl.h>
#include <stdarg.h>
#include <errno.h>
#include <assert.h>
#include <nuttx/fs/fs.h>
@ -66,7 +67,7 @@
*
* Return:
* >=0 on success (positive non-zero values are cmd-specific)
* -1 on failure withi errno set properly:
* -1 on failure with errno set properly:
*
* EBADF
* 'fd' is not a valid descriptor.
@ -84,15 +85,26 @@
int ioctl(int fd, int req, ...)
{
va_list ap;
unsigned long arg;
va_list ap;
/* Get the unsigned long argument.
*
* REVISIT: This could cause of the crash down the road if the actual size
* of the argument is anything other than sizeof(unsigned long);
* REVISIT: This could be the cause of the crash down the road if the
* actual size of the argument is anything other than sizeof(unsigned long).
* Most small integers will be promoted to 'int'. ARM should pass the
* following test with all three types having sizeof(type) == 4 bytes.
* 'float' should also be tested. But 'long long' and 'double' are out of
* the question! Don't try to pass them.
*
* And what will happen if no third argument is passed? In most cases,
* this should just result in a garbage value for arg. But you may
* discover cases where something worse happens!
*/
DEBUGASSERT(sizeof(int) == sizeof(unsigned long) &&
sizeof(FAR void *) == sizeof(unsigned long));
va_start(ap, req);
arg = va_arg(ap, unsigned long);
va_end(ap);