Fix bad conditional compilation that breaks THTTPD and dup2()

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3511 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-04-16 01:04:17 +00:00
parent 1399504d90
commit 843af193c2
7 changed files with 25 additions and 15 deletions

View file

@ -1695,6 +1695,7 @@
file
* sched/clock_uptime() and lib/time/lib_time.c: Add support for 1 second uptime
interface.
* net/net_dup2.c and include/nuttx/net.h: The conditional compilation for
'#if CONFIG_NFILE_DESCRIPTOR > 0' was wrong in both of these files. It should
be '#if CONFIG_NFILE_DESCRIPTORS > 0'. This causes a dup2() failure in THTTPD
and a failure to get a CGI page. The consequence can be a very serious bug!

View file

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
<p>Last Updated: April 14, 2011</p>
<p>Last Updated: April 15, 2011</p>
</td>
</tr>
</table>
@ -2222,10 +2222,16 @@ nuttx-6.2 2011-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;
UART2 and UART3.
* nuttx/clock.h: Replace all references to the global variable g_system_timer
with clock_systemtimer() (currently just a macro that that returns g_system_timer).
= * lib/string/strrch.c: Would fail if the searched-for character were the first
* lib/string/strrch.c: Would fail if the searched-for character were the first
character in the string.
* tools/version.sh and mkversion.c: Tools to manage a NuttX version number
file
* sched/clock_uptime() and lib/time/lib_time.c: Add support for 1 second uptime
interface.
* net/net_dup2.c and include/nuttx/net.h: The conditional compilation for
'#if CONFIG_NFILE_DESCRIPTOR > 0' was wrong in both of these files. It should
be '#if CONFIG_NFILE_DESCRIPTORS > 0'. This causes a dup2() failure in THTTPD
and a failure to get a CGI page. The consequence can be a very serious bug!
apps-6.1 2011-xx-xx Gregory Nutt &lt;spudmonkey@racsa.co.cr&gt;

View file

@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_dup2.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -38,6 +38,7 @@
****************************************************************************/
#include <nuttx/config.h>
#include <unistd.h>
#include <sched.h>
#include <errno.h>
@ -79,7 +80,7 @@ int dup2(int fildes1, int fildes2)
if ((unsigned int)fildes1 >= CONFIG_NFILE_DESCRIPTORS)
{
/* Not a vailid file descriptor. Did we get a valid socket descriptor? */
/* Not a valid file descriptor. Did we get a valid socket descriptor? */
if ((unsigned int)fildes1 < (CONFIG_NFILE_DESCRIPTORS+CONFIG_NSOCKET_DESCRIPTORS))
{

View file

@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_filedup.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -43,6 +43,7 @@
#include <errno.h>
#include <nuttx/fs.h>
#include "fs_internal.h"
#if CONFIG_NFILE_DESCRIPTORS > 0
@ -109,7 +110,7 @@ int file_dup(int fildes, int minfd)
if (fildes2 < 0)
{
errno = EMFILE;
inode_release(list->fl_files[fildes].f_inode);
inode_release(list->fl_files[fildes].f_inode);
return ERROR;
}
return fildes2;

View file

@ -1,7 +1,7 @@
/****************************************************************************
* fs/fs_filedup2.c
*
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -42,6 +42,7 @@
#include <unistd.h>
#include <sched.h>
#include <errno.h>
#include "fs_internal.h"
#if CONFIG_NFILE_DESCRIPTORS > 0
@ -109,8 +110,8 @@ int dup2(int fildes1, int fildes2)
if ((unsigned int)fildes2 >= CONFIG_NFILE_DESCRIPTORS)
{
errno = EBADF;
return ERROR;
errno = EBADF;
return ERROR;
}
return files_dup(&list->fl_files[fildes1], &list->fl_files[fildes2]);

View file

@ -177,7 +177,7 @@ EXTERN int net_dup(int sockfd, int minsd);
* this function (when both file and socket descriptors are supported)
*/
#if CONFIG_NFILE_DESCRIPTOR > 0
#if CONFIG_NFILE_DESCRIPTORS > 0
EXTERN int net_dup2(int sockfd1, int sockfd2);
#else
# define net_dup2(sockfd1, sockfd2) dup2(sockfd1, sockfd2)

View file

@ -1,7 +1,7 @@
/****************************************************************************
* net/net_dup2.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@ -63,7 +63,7 @@
*
****************************************************************************/
#if CONFIG_NFILE_DESCRIPTOR > 0
#if CONFIG_NFILE_DESCRIPTORS > 0
int net_dup2(int sockfd1, int sockfd2)
#else
int dup2(int sockfd1, int sockfd2)