Fix issues detected by CppCheck tool

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3261 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-01-19 20:02:23 +00:00
parent f389facd71
commit 60c0de010a
14 changed files with 143 additions and 55 deletions

View File

@ -12,7 +12,7 @@
<h1><big><font color="#3c34ec"> <h1><big><font color="#3c34ec">
<i>NuttX RTOS Porting Guide</i> <i>NuttX RTOS Porting Guide</i>
</font></big></h1> </font></big></h1>
<p>Last Updated: January 16, 2011</p> <p>Last Updated: January 19, 2011</p>
</td> </td>
</tr> </tr>
</table> </table>
@ -3622,6 +3622,42 @@ build
<code>CONFIG_USBHOST_ISOC_DISABLE</code>: On some architectures, selecting this setting will reduce driver size by disabling isochronous endpoint support <code>CONFIG_USBHOST_ISOC_DISABLE</code>: On some architectures, selecting this setting will reduce driver size by disabling isochronous endpoint support
</li> </li>
</ul> </ul>
<h3>USB Host HID Class Driver</h3>
<p>
Requires <code>CONFIG_USBHOST=y</code>, <code>CONFIG_USBHOST_INT_DISABLE=n</code>, <code>CONFIG_NFILE_DESCRIPTORS > 0</code>,
<code>CONFIG_SCHED_WORKQUEUE=y</code>, and <code>CONFIG_DISABLE_SIGNALS=n</code>.
</p>
<ul>
<li>
<code>CONFIG_HIDKBD_POLLUSEC</code>: Device poll rate in microseconds. Default: 100 milliseconds.
</li>
<li>
<code>CONFIG_HIDKBD_DEFPRIO</code>: Priority of the polling thread. Default: 50.
</li>
<li>
<code>CONFIG_HIDKBD_STACKSIZE</code>: Stack size for polling thread. Default: 1024
</li>
<li>
<code>CONFIG_HIDKBD_BUFSIZE</code>: Scancode buffer size. Default: 64.
</li>
<li>
<code>CONFIG_HIDKBD_NPOLLWAITERS</code>: If the poll() method is enabled, this defines the maximum number of threads that can be waiting for keyboard events. Default: 2.
</li>
<li>
<code>CONFIG_HIDKBD_RAWSCANCODES</code>: If set to <code>y</code> no conversion will be made on the raw keyboard scan codes. Default: ASCII conversion.
</li>
<li>
<code>CONFIG_HIDKBD_ALLSCANCODES</code>: If set to <code>y</code> all 231 possible scancodes will be converted to something. Default: 104 key US keyboard.
</li>
<li>
<code>CONFIG_HIDKBD_NODEBOUNCE</code>: If set to <code>y</code> normal debouncing is disabled. Default: Debounce/No repeat keys.
</li>
</ul>
<h3>USB Host HID Mass Storage Class Driver</h3>
<p>
Requires <code>CONFIG_USBHOST=y</code>, <code>CONFIG_USBHOST_BULK_DISABLE=n</code>, <code>CONFIG_NFILE_DESCRIPTORS > 0</code>,
and <code>CONFIG_SCHED_WORKQUEUE=y</code>.
</p>
<h2>Graphics related configuration settings</h3> <h2>Graphics related configuration settings</h3>
<ul> <ul>

View File

@ -1,7 +1,7 @@
/************************************************************************************ /************************************************************************************
* arch/arm/src/dm320/dm320_boot.c * arch/arm/src/dm320/dm320_boot.c
* *
* Copyright (C) 2007, 2009-2010 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/******************************************************************************* /*******************************************************************************
* arch/arm/src/dm320/dm320_usbdev.c * arch/arm/src/dm320/dm320_usbdev.c
* *
* Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -2402,7 +2402,7 @@ void up_usbinitialize(void)
/* Perform endpoint initialization */ /* Perform endpoint initialization */
for (i = 0; i < DM320_NENDPOINTS+1; i++) for (i = 0; i < DM320_NENDPOINTS; i++)
{ {
/* Set up the standard stuff */ /* Set up the standard stuff */
@ -2423,7 +2423,7 @@ void up_usbinitialize(void)
priv->eplist[i].ep.maxpacket = g_epinfo[i].maxpacket; priv->eplist[i].ep.maxpacket = g_epinfo[i].maxpacket;
if (USB_EPIN(g_epinfo[i].addr)) if (USB_EPIN(g_epinfo[i].addr))
{ {
priv->eplist[1].in = 1; priv->eplist[i].in = 1;
} }
/* Reset the endpoint */ /* Reset the endpoint */

View File

@ -2,7 +2,7 @@
* arch/arm/src/imx/imx_boot.c * arch/arm/src/imx/imx_boot.c
* arch/arm/src/chip/imx_boot.c * arch/arm/src/chip/imx_boot.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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/z80/src/z8/z8_registerdump.c * arch/z80/src/z8/z8_registerdump.c
* *
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009,2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -130,7 +130,7 @@ void z8_registerdump(void)
regs = g_z8irqstate.regs; regs = g_z8irqstate.regs;
z8_dumpregs(regs); z8_dumpregs(regs);
z8_dumpstate(regs[XCPT_SP], regs[XCPT_PC], z8_dumpstate(regs[XCPT_SP], regs[XCPT_PC],
regs[XCPT_IRQCTL], regs[XCPT_RPFLAGS]; regs[XCPT_IRQCTL], regs[XCPT_RPFLAGS]);
break; break;
case Z8_IRQSTATE_NONE: case Z8_IRQSTATE_NONE:

View File

@ -712,12 +712,41 @@ defconfig -- This is a configuration file similar to the Linux
On some architectures, selecting this setting will reduce driver size On some architectures, selecting this setting will reduce driver size
by disabling bulk endpoint support by disabling bulk endpoint support
CONFIG_USBHOST_INT_DISABLE CONFIG_USBHOST_INT_DISABLE
On some architectures, selecting this setting will reduce driver size On some architectures, selecting this setting will reduce driver size
by disabling interrupt endpoint support by disabling interrupt endpoint support
CONFIG_USBHOST_ISOC_DISABLE CONFIG_USBHOST_ISOC_DISABLE
On some architectures, selecting this setting will reduce driver size On some architectures, selecting this setting will reduce driver size
by disabling isochronous endpoint support by disabling isochronous endpoint support
USB host HID class driver. Requires CONFIG_USBHOST=y,
CONFIG_USBHOST_INT_DISABLE=n, CONFIG_NFILE_DESCRIPTORS > 0,
CONFIG_SCHED_WORKQUEUE=y, and CONFIG_DISABLE_SIGNALS=n.
CONFIG_HIDKBD_POLLUSEC
Device poll rate in microseconds. Default: 100 milliseconds.
CONFIG_HIDKBD_DEFPRIO
Priority of the polling thread. Default: 50.
CONFIG_HIDKBD_STACKSIZE
Stack size for polling thread. Default: 1024
CONFIG_HIDKBD_BUFSIZE
Scancode buffer size. Default: 64.
CONFIG_HIDKBD_NPOLLWAITERS
If the poll() method is enabled, this defines the maximum number
of threads that can be waiting for keyboard events. Default: 2.
CONFIG_HIDKBD_RAWSCANCODES
If set to y no conversion will be made on the raw keyboard scan
codes. Default: ASCII conversion.
CONFIG_HIDKBD_ALLSCANCODES'
If set to y all 231 possible scancodes will be converted to
something. Default: 104 key US keyboard.
CONFIG_HIDKBD_NODEBOUNCE
If set to y normal debouncing is disabled. Default:
Debounce enabled (No repeat keys).
USB host mass storage class driver. Requires CONFIG_USBHOST=y,
CONFIG_USBHOST_BULK_DISABLE=n, CONFIG_NFILE_DESCRIPTORS > 0,
and CONFIG_SCHED_WORKQUEUE=y
USB serial device class driver USB serial device class driver
CONFIG_USBSER CONFIG_USBSER
Enable compilation of the USB serial driver Enable compilation of the USB serial driver

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* drivers/mtd/skeleton.c * drivers/mtd/skeleton.c
* *
* Copyright (C) 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -270,5 +270,5 @@ void skel_initialize(void)
/* Return the implementation-specific state structure as the MTD device */ /* Return the implementation-specific state structure as the MTD device */
return ((FAR struct mtd_dev_s *)&g_skeldev; return (FAR struct mtd_dev_s *)&g_skeldev;
} }

View File

@ -103,22 +103,22 @@
# define CONFIG_HIDKBD_STACKSIZE 1024 # define CONFIG_HIDKBD_STACKSIZE 1024
#endif #endif
#ifndef CONFIG_USBHID_BUFSIZE #ifndef CONFIG_HIDKBD_BUFSIZE
# define CONFIG_USBHID_BUFSIZE 64 # define CONFIG_HIDKBD_BUFSIZE 64
#endif #endif
#ifndef CONFIG_USBHID_NPOLLWAITERS #ifndef CONFIG_HIDKBD_NPOLLWAITERS
# define CONFIG_USBHID_NPOLLWAITERS 2 # define CONFIG_HIDKBD_NPOLLWAITERS 2
#endif #endif
/* The default is to support scancode mapping for the standard 104 key /* The default is to support scancode mapping for the standard 104 key
* keyboard. Setting CONFIG_USBHID_RAWSCANCODES will disable all scancode * keyboard. Setting CONFIG_HIDKBD_RAWSCANCODES will disable all scancode
* mapping; Setting CONFIG_USBHID_ALLSCANCODES will enable mapping of all * mapping; Setting CONFIG_HIDKBD_ALLSCANCODES will enable mapping of all
* scancodes; * scancodes;
*/ */
#ifndef CONFIG_USBHID_RAWSCANCODES #ifndef CONFIG_HIDKBD_RAWSCANCODES
# ifdef CONFIG_USBHID_ALLSCANCODES # ifdef CONFIG_HIDKBD_ALLSCANCODES
# define USBHID_NUMSCANCODES (USBHID_KBDUSE_MAX+1) # define USBHID_NUMSCANCODES (USBHID_KBDUSE_MAX+1)
# else # else
# define USBHID_NUMSCANCODES 104 # define USBHID_NUMSCANCODES 104
@ -198,14 +198,14 @@ struct usbhost_state_s
*/ */
#ifndef CONFIG_DISABLE_POLL #ifndef CONFIG_DISABLE_POLL
struct pollfd *fds[CONFIG_USBHID_NPOLLWAITERS]; struct pollfd *fds[CONFIG_HIDKBD_NPOLLWAITERS];
#endif #endif
/* Buffer used to collect and buffer incoming keyboard characters */ /* Buffer used to collect and buffer incoming keyboard characters */
volatile uint16_t headndx; /* Buffer head index */ volatile uint16_t headndx; /* Buffer head index */
volatile uint16_t tailndx; /* Buffer tail index */ volatile uint16_t tailndx; /* Buffer tail index */
uint8_t kbdbuffer[CONFIG_USBHID_BUFSIZE]; uint8_t kbdbuffer[CONFIG_HIDKBD_BUFSIZE];
}; };
/**************************************************************************** /****************************************************************************
@ -342,7 +342,7 @@ static struct usbhost_state_s *g_priv; /* Data passed to thread */
* controls. * controls.
*/ */
#ifndef CONFIG_USBHID_RAWSCANCODES #ifndef CONFIG_HIDKBD_RAWSCANCODES
static const uint8_t ucmap[USBHID_NUMSCANCODES] = static const uint8_t ucmap[USBHID_NUMSCANCODES] =
{ {
0, 0, 0, 0, 'A', 'B', 'C', 'D', /* 0x00-0x07: Reserved, errors, A-D */ 0, 0, 0, 0, 'A', 'B', 'C', 'D', /* 0x00-0x07: Reserved, errors, A-D */
@ -358,7 +358,7 @@ static const uint8_t ucmap[USBHID_NUMSCANCODES] =
0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */ 0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */
'\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */ '\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */
'8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */ '8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */
#ifdef CONFIG_USBHID_ALLSCANCODES #ifdef CONFIG_HIDKBD_ALLSCANCODES
0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77: F21,F22,F23,F24,Execute,Help,Menu,Select */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77: F21,F22,F23,F24,Execute,Help,Menu,Select */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x78-0x7f: Stop,Again,Undo,Cut,Copy,Paste,Find,Mute */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78-0x7f: Stop,Again,Undo,Cut,Copy,Paste,Find,Mute */
@ -393,7 +393,7 @@ static const uint8_t lcmap[USBHID_NUMSCANCODES] =
0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */ 0, 0, 0, 0, '/', '*', '-', '+', /* 0x50-0x57: LeftArrow,DownArrow,UpArrow,Num Lock,/,*,-,+ */
'\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */ '\n', '1', '2', '3', '4', '4', '6', '7', /* 0x58-0x5f: Enter,1-7 */
'8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */ '8', '9', '0', '.', 0, 0, 0, '=', /* 0x60-0x67: 8-9,0,.,Non-US \,Application,Power,= */
#ifdef CONFIG_USBHID_ALLSCANCODES #ifdef CONFIG_HIDKBD_ALLSCANCODES
0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x68-0x6f: F13,F14,F15,F16,F17,F18,F19,F20 */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77: F21,F22,F23,F24,Execute,Help,Menu,Select */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70-0x77: F21,F22,F23,F24,Execute,Help,Menu,Select */
0, 0, 0, 0, 0, 0, 0, 0, /* 0x78-0x7f: Stop,Again,Undo,Cut,Copy,Paste,Find,Mute */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0x78-0x7f: Stop,Again,Undo,Cut,Copy,Paste,Find,Mute */
@ -412,7 +412,7 @@ static const uint8_t lcmap[USBHID_NUMSCANCODES] =
0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0-0xe7: Left Ctrl,Shift,Alt,GUI, Right Ctrl,Shift,Alt,GUI */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0-0xe7: Left Ctrl,Shift,Alt,GUI, Right Ctrl,Shift,Alt,GUI */
#endif #endif
}; };
#endif /* CONFIG_USBHID_RAWSCANCODES */ #endif /* CONFIG_HIDKBD_RAWSCANCODES */
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@ -450,7 +450,7 @@ static void usbhost_pollnotify(FAR struct usbhost_state_s *priv)
{ {
int i; int i;
for (i = 0; i < CONFIG_USBHID_NPOLLWAITERS; i++) for (i = 0; i < CONFIG_HIDKBD_NPOLLWAITERS; i++)
{ {
struct pollfd *fds = priv->fds[i]; struct pollfd *fds = priv->fds[i];
if (fds) if (fds)
@ -655,7 +655,7 @@ static void usbhost_destroy(FAR void *arg)
static inline uint8_t usbhost_mapscancode(uint8_t scancode, uint8_t modifier) static inline uint8_t usbhost_mapscancode(uint8_t scancode, uint8_t modifier)
{ {
#ifndef CONFIG_USBHID_RAWSCANCODES #ifndef CONFIG_HIDKBD_RAWSCANCODES
/* Range check */ /* Range check */
if (scancode >= USBHID_NUMSCANCODES) if (scancode >= USBHID_NUMSCANCODES)
@ -831,7 +831,7 @@ static int usbhost_kbdpoll(int argc, char *argv[])
/* Increment the head index */ /* Increment the head index */
if (++head >= CONFIG_USBHID_BUFSIZE) if (++head >= CONFIG_HIDKBD_BUFSIZE)
{ {
head = 0; head = 0;
} }
@ -843,7 +843,7 @@ static int usbhost_kbdpoll(int argc, char *argv[])
if (tail == head) if (tail == head)
{ {
if (++tail >= CONFIG_USBHID_BUFSIZE) if (++tail >= CONFIG_HIDKBD_BUFSIZE)
{ {
tail = 0; tail = 0;
} }
@ -1850,7 +1850,7 @@ static ssize_t usbhost_read(FAR struct file *filep, FAR char *buffer, size_t len
/* Handle wrap-around of the tail index */ /* Handle wrap-around of the tail index */
if (++tail >= CONFIG_USBHID_BUFSIZE) if (++tail >= CONFIG_HIDKBD_BUFSIZE)
{ {
tail = 0; tail = 0;
} }
@ -1928,7 +1928,7 @@ static int usbhost_poll(FAR struct file *filep, FAR struct pollfd *fds,
* the poll structure reference * the poll structure reference
*/ */
for (i = 0; i < CONFIG_USBHID_NPOLLWAITERS; i++) for (i = 0; i < CONFIG_HIDKBD_NPOLLWAITERS; i++)
{ {
/* Find an available slot */ /* Find an available slot */
@ -1942,7 +1942,7 @@ static int usbhost_poll(FAR struct file *filep, FAR struct pollfd *fds,
} }
} }
if (i >= CONFIG_USBHID_NPOLLWAITERS) if (i >= CONFIG_HIDKBD_NPOLLWAITERS)
{ {
fds->priv = NULL; fds->priv = NULL;
ret = -EBUSY; ret = -EBUSY;

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* examples/poll/poll_main.c * examples/poll/poll_main.c
* *
* Copyright (C) 2008 Gregory Nutt. All rights reserved. * Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -95,9 +95,10 @@ int user_start(int argc, char *argv[])
pthread_t tid3; pthread_t tid3;
#endif #endif
int count; int count;
int fd1; int fd1 = -1;
int fd2; int fd2 = -1;
int ret; int ret;
int exitcode = 0;
/* Open FIFOs */ /* Open FIFOs */
@ -106,7 +107,8 @@ int user_start(int argc, char *argv[])
if (ret < 0) if (ret < 0)
{ {
message("user_start: mkfifo failed: %d\n", errno); message("user_start: mkfifo failed: %d\n", errno);
return 1; exitcode = 1;
goto errout;
} }
message("\nuser_start: Creating FIFO %s\n", FIFO_PATH2); message("\nuser_start: Creating FIFO %s\n", FIFO_PATH2);
@ -114,7 +116,8 @@ int user_start(int argc, char *argv[])
if (ret < 0) if (ret < 0)
{ {
message("user_start: mkfifo failed: %d\n", errno); message("user_start: mkfifo failed: %d\n", errno);
return 2; exitcode = 2;
goto errout;
} }
/* Open the FIFOs for blocking, write */ /* Open the FIFOs for blocking, write */
@ -124,7 +127,8 @@ int user_start(int argc, char *argv[])
{ {
message("user_start: Failed to open FIFO %s for writing, errno=%d\n", message("user_start: Failed to open FIFO %s for writing, errno=%d\n",
FIFO_PATH1, errno); FIFO_PATH1, errno);
return 2; exitcode = 3;
goto errout;
} }
fd2 = open(FIFO_PATH2, O_WRONLY); fd2 = open(FIFO_PATH2, O_WRONLY);
@ -132,7 +136,8 @@ int user_start(int argc, char *argv[])
{ {
message("user_start: Failed to open FIFO %s for writing, errno=%d\n", message("user_start: Failed to open FIFO %s for writing, errno=%d\n",
FIFO_PATH2, errno); FIFO_PATH2, errno);
return 2; exitcode = 4;
goto errout;
} }
/* Start the listeners */ /* Start the listeners */
@ -143,7 +148,8 @@ int user_start(int argc, char *argv[])
if (ret != 0) if (ret != 0)
{ {
message("user_start: Failed to create poll_listener thread: %d\n", ret); message("user_start: Failed to create poll_listener thread: %d\n", ret);
return 3; exitcode = 5;
goto errout;
} }
message("user_start: Starting select_listener thread\n"); message("user_start: Starting select_listener thread\n");
@ -152,7 +158,8 @@ int user_start(int argc, char *argv[])
if (ret != 0) if (ret != 0)
{ {
message("user_start: Failed to create select_listener thread: %d\n", ret); message("user_start: Failed to create select_listener thread: %d\n", ret);
return 3; exitcode = 6;
goto errout;
} }
#ifdef HAVE_NETPOLL #ifdef HAVE_NETPOLL
@ -184,14 +191,16 @@ int user_start(int argc, char *argv[])
if (nbytes < 0) if (nbytes < 0)
{ {
message("user_start: Write to fd1 failed: %d\n", errno); message("user_start: Write to fd1 failed: %d\n", errno);
return 4; exitcode = 7;
goto errout;
} }
nbytes = write(fd2, buffer, strlen(buffer)); nbytes = write(fd2, buffer, strlen(buffer));
if (nbytes < 0) if (nbytes < 0)
{ {
message("user_start: Write fd2 failed: %d\n", errno); message("user_start: Write fd2 failed: %d\n", errno);
return 4; exitcode = 8;
goto errout;
} }
message("\nuser_start: Sent '%s' (%d bytes)\n", buffer, nbytes); message("\nuser_start: Sent '%s' (%d bytes)\n", buffer, nbytes);
@ -204,6 +213,17 @@ int user_start(int argc, char *argv[])
sleep(WRITER_DELAY); sleep(WRITER_DELAY);
} }
errout:
if (fd1 >= 0)
{
close(fd1);
}
if (fd2 >= 0)
{
close(fd2);
}
fflush(stdout); fflush(stdout);
return 0; return exitcode;
} }

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* graphics/nxbe/nxbe_closewindow.c * graphics/nxbe/nxbe_closewindow.c
* *
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -86,17 +86,19 @@
void nxbe_closewindow(struct nxbe_window_s *wnd) void nxbe_closewindow(struct nxbe_window_s *wnd)
{ {
FAR struct nxbe_state_s *be = wnd->be; FAR struct nxbe_state_s *be;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
if (!wnd) if (!wnd)
{ {
return; return;
} }
#endif
be = wnd->be;
/* The background window should never be closed */ /* The background window should never be closed */
DEBUGASSERT(wnd != &be->bkgd); DEBUGASSERT(wnd != &be->bkgd);
#endif
/* Is there a window above the one being closed? */ /* Is there a window above the one being closed? */

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* graphics/nxbe/nxbe_colormap.c * graphics/nxbe/nxbe_colormap.c
* *
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009,2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -98,7 +98,7 @@ int nxbe_configure(FAR NX_DRIVERTYPE *dev, FAR struct nxbe_state_s *be)
size = 3 * CONFIG_NX_NCOLORS * sizeof(uint16_t); size = 3 * CONFIG_NX_NCOLORS * sizeof(uint16_t);
alloc = (uint8_t*)malloc(size); alloc = (uint8_t*)malloc(size);
if (alloc < 0) if (alloc == NULL)
{ {
return -ENOMEM; return -ENOMEM;
} }

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* graphics/nxsu/nxsu_reportposition.c * graphics/nxsu/nxsu_reportposition.c
* *
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009,2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -79,7 +79,7 @@
void nxfe_reportposition(FAR struct nxbe_window_s *wnd) void nxfe_reportposition(FAR struct nxbe_window_s *wnd)
{ {
FAR struct nxbe_state_s *be = wnd->be; FAR struct nxbe_state_s *be;
struct nxgl_size_s size; struct nxgl_size_s size;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
@ -88,6 +88,7 @@ void nxfe_reportposition(FAR struct nxbe_window_s *wnd)
return; return;
} }
#endif #endif
be = wnd->be;
/* This is very awkward in single user mode, but at least it is compatible. /* This is very awkward in single user mode, but at least it is compatible.
* with the way things are done in multiple user mode. * with the way things are done in multiple user mode.

View File

@ -1445,9 +1445,9 @@ char *__dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
#endif #endif
if (j < 0 || (j == 0 && !mode if (j < 0 || (j == 0 && !mode
#ifndef ROUND_BIASED #ifndef ROUND_BIASED
&& (!(word1(d) & 1))) && (!(word1(d) & 1))
#endif #endif
) ))
{ {
if ((j_1 > 0)) if ((j_1 > 0))
{ {

View File

@ -1,7 +1,7 @@
/************************************************************ /************************************************************
* mm/mm_memalign.c * mm/mm_memalign.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> * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -100,7 +100,7 @@ FAR void *memalign(size_t alignment, size_t size)
/* Then malloc that size */ /* Then malloc that size */
rawchunk = (size_t)malloc(allocsize); rawchunk = (size_t)malloc(allocsize);
if (!rawchunk) if (rawchunk == NULL)
{ {
return NULL; return NULL;
} }