diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-07-01 15:09:07 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-07-01 15:09:07 -0600 |
commit | b880602f00bafe2b53b6536d97a48ec4d3af412e (patch) | |
tree | c8750545f45fb55bc0073036a184d4585dc13024 /nuttx/drivers/syslog | |
parent | e962ace77e7128655b4dce73b1a943ca994b9fb5 (diff) | |
download | nuttx-b880602f00bafe2b53b6536d97a48ec4d3af412e.tar.gz nuttx-b880602f00bafe2b53b6536d97a48ec4d3af412e.tar.bz2 nuttx-b880602f00bafe2b53b6536d97a48ec4d3af412e.zip |
RAMLOG: syslog_putc must set errno and return EOF on a failure
Diffstat (limited to 'nuttx/drivers/syslog')
-rw-r--r-- | nuttx/drivers/syslog/ramlog.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/nuttx/drivers/syslog/ramlog.c b/nuttx/drivers/syslog/ramlog.c index e73637f2a..4075590f2 100644 --- a/nuttx/drivers/syslog/ramlog.c +++ b/nuttx/drivers/syslog/ramlog.c @@ -42,6 +42,7 @@ #include <sys/types.h> #include <sys/ioctl.h> +#include <stdio.h> #include <stdint.h> #include <stdbool.h> #include <stdlib.h> @@ -735,10 +736,10 @@ int ramlog_sysloginit(void) int syslog_putc(int ch) { FAR struct ramlog_dev_s *priv = &g_sysdev; -#ifdef CONFIG_RAMLOG_CRLF int ret; - /* Ignore carriage returns */ +#ifdef CONFIG_RAMLOG_CRLF + /* Ignore carriage returns. But return success. */ if (ch == '\r') { @@ -754,13 +755,28 @@ int syslog_putc(int ch) { /* The buffer is full and nothing was saved. */ - return ch; + goto errout; } } #endif - (void)ramlog_addchar(priv, ch); - return ch; + /* Add the character to the RAMLOG */ + + ret = ramlog_addchar(priv, ch); + if (ret >= 0) + { + /* Return the character added on success */ + + return ch; + } + + /* On a failure, we need to return EOF and set the errno so that + * work like all other putc-like functions. + */ + +errout: + set_errno(-ret); + return EOF; } #endif |