mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
Revert "fix(ramlog): fix initial ramlog buffer pointer overflow"
This reverts commit 76242c5ee1.
This commit is contained in:
+15
-20
@@ -94,12 +94,12 @@ static int ramlog_addchar(FAR struct ramlog_dev_s *priv, char ch);
|
||||
|
||||
static ssize_t ramlog_file_read(FAR struct file *filep, FAR char *buffer,
|
||||
size_t buflen);
|
||||
static ssize_t ramlog_file_write(FAR struct file *filep,
|
||||
FAR const char *buffer, size_t buflen);
|
||||
static ssize_t ramlog_file_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t buflen);
|
||||
static int ramlog_file_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg);
|
||||
static int ramlog_file_poll(FAR struct file *filep,
|
||||
FAR struct pollfd *fds, bool setup);
|
||||
static int ramlog_file_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||
bool setup);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@@ -431,8 +431,8 @@ static ssize_t ramlog_file_read(FAR struct file *filep, FAR char *buffer,
|
||||
|
||||
/* Otherwise, wait for something to be written to the circular
|
||||
* buffer. Increment the number of waiters so that the
|
||||
* ramlog_file_write() will note that it needs to post the
|
||||
* semaphore to wake us up.
|
||||
* ramlog_file_write() will note that it needs to post the semaphore
|
||||
* to wake us up.
|
||||
*/
|
||||
|
||||
sched_lock();
|
||||
@@ -532,8 +532,8 @@ errout_without_sem:
|
||||
* Name: ramlog_file_write
|
||||
****************************************************************************/
|
||||
|
||||
static ssize_t ramlog_file_write(FAR struct file *filep,
|
||||
FAR const char *buffer, size_t len)
|
||||
static ssize_t ramlog_file_write(FAR struct file *filep, FAR const char *buffer,
|
||||
size_t len)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct ramlog_dev_s *priv;
|
||||
@@ -550,8 +550,7 @@ static ssize_t ramlog_file_write(FAR struct file *filep,
|
||||
* Name: ramlog_file_ioctl
|
||||
****************************************************************************/
|
||||
|
||||
static int ramlog_file_ioctl(FAR struct file *filep, int cmd,
|
||||
unsigned long arg)
|
||||
static int ramlog_file_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR struct inode *inode = filep->f_inode;
|
||||
FAR struct ramlog_dev_s *priv;
|
||||
@@ -731,27 +730,22 @@ static void ramlog_initbuf(void)
|
||||
if (prev && !cur)
|
||||
{
|
||||
priv->rl_head = i;
|
||||
if (priv->rl_tail != CONFIG_RAMLOG_BUFSIZE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!prev && cur)
|
||||
{
|
||||
priv->rl_tail = i;
|
||||
if (priv->rl_head != CONFIG_RAMLOG_BUFSIZE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
prev = cur;
|
||||
}
|
||||
|
||||
out:
|
||||
priv->rl_head = priv->rl_tail = 0;
|
||||
memset(priv->rl_buffer, 0, priv->rl_bufsize);
|
||||
if (i != priv->rl_bufsize)
|
||||
{
|
||||
priv->rl_head = priv->rl_tail = 0;
|
||||
memset(priv->rl_buffer, 0, priv->rl_bufsize);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -883,6 +877,7 @@ int ramlog_putc(FAR struct syslog_channel_s *channel, int ch)
|
||||
return ch;
|
||||
}
|
||||
|
||||
|
||||
ssize_t ramlog_write(FAR struct syslog_channel_s *channel,
|
||||
FAR const char *buffer, size_t buflen)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user