You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/01/13 18:16:20 UTC
[incubator-nuttx] branch master updated: syslog: Fix in file channel initialization.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 0c41611 syslog: Fix in file channel initialization.
0c41611 is described below
commit 0c41611429d85fa348442eb74bbea72ff77d9437
Author: Fotis Panagiotopoulos <f....@amco.gr>
AuthorDate: Thu Jan 13 14:45:44 2022 +0200
syslog: Fix in file channel initialization.
---
drivers/syslog/syslog_consolechannel.c | 24 +++++++++---------------
drivers/syslog/syslog_devchannel.c | 24 +++++++++---------------
drivers/syslog/syslog_filechannel.c | 30 ++++++++----------------------
3 files changed, 26 insertions(+), 52 deletions(-)
diff --git a/drivers/syslog/syslog_consolechannel.c b/drivers/syslog/syslog_consolechannel.c
index 9fcd426..4636346 100644
--- a/drivers/syslog/syslog_consolechannel.c
+++ b/drivers/syslog/syslog_consolechannel.c
@@ -42,14 +42,6 @@
#define OPEN_MODE (S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR)
/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/* Handle to the SYSLOG channel */
-
-FAR static struct syslog_channel_s *g_syslog_console_channel;
-
-/****************************************************************************
* Public Functions
****************************************************************************/
@@ -81,24 +73,26 @@ FAR static struct syslog_channel_s *g_syslog_console_channel;
FAR struct syslog_channel_s *syslog_console_channel(void)
{
+ FAR struct syslog_channel_s *console_channel;
+
/* Initialize the character driver interface */
- g_syslog_console_channel = syslog_dev_initialize("/dev/console",
- OPEN_FLAGS, OPEN_MODE);
- if (g_syslog_console_channel == NULL)
+ console_channel = syslog_dev_initialize("/dev/console",
+ OPEN_FLAGS, OPEN_MODE);
+ if (console_channel == NULL)
{
return NULL;
}
/* Use the character driver as the SYSLOG channel */
- if (syslog_channel(g_syslog_console_channel) != OK)
+ if (syslog_channel(console_channel) != OK)
{
- syslog_dev_uninitialize(g_syslog_console_channel);
- g_syslog_console_channel = NULL;
+ syslog_dev_uninitialize(console_channel);
+ console_channel = NULL;
}
- return g_syslog_console_channel;
+ return console_channel;
}
#endif /* CONFIG_SYSLOG_CONSOLE */
diff --git a/drivers/syslog/syslog_devchannel.c b/drivers/syslog/syslog_devchannel.c
index 00b534d..b0f1626 100644
--- a/drivers/syslog/syslog_devchannel.c
+++ b/drivers/syslog/syslog_devchannel.c
@@ -42,14 +42,6 @@
#define OPEN_MODE (S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR)
/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/* Handle to the SYSLOG channel */
-
-FAR static struct syslog_channel_s *g_syslog_dev_channel;
-
-/****************************************************************************
* Public Functions
****************************************************************************/
@@ -78,24 +70,26 @@ FAR static struct syslog_channel_s *g_syslog_dev_channel;
FAR struct syslog_channel_s *syslog_dev_channel(void)
{
+ FAR struct syslog_channel_s *dev_channel;
+
/* Initialize the character driver interface */
- g_syslog_dev_channel = syslog_dev_initialize(CONFIG_SYSLOG_DEVPATH,
- OPEN_FLAGS, OPEN_MODE);
- if (g_syslog_dev_channel == NULL)
+ dev_channel = syslog_dev_initialize(CONFIG_SYSLOG_DEVPATH,
+ OPEN_FLAGS, OPEN_MODE);
+ if (dev_channel == NULL)
{
return NULL;
}
/* Use the character driver as the SYSLOG channel */
- if (syslog_channel(g_syslog_dev_channel) != OK)
+ if (syslog_channel(dev_channel) != OK)
{
- syslog_dev_uninitialize(g_syslog_dev_channel);
- g_syslog_dev_channel = NULL;
+ syslog_dev_uninitialize(dev_channel);
+ dev_channel = NULL;
}
- return g_syslog_dev_channel;
+ return dev_channel;
}
#endif /* CONFIG_SYSLOG_CHAR */
diff --git a/drivers/syslog/syslog_filechannel.c b/drivers/syslog/syslog_filechannel.c
index ddc27aa..a5cd35f 100644
--- a/drivers/syslog/syslog_filechannel.c
+++ b/drivers/syslog/syslog_filechannel.c
@@ -50,14 +50,6 @@
#define OPEN_MODE (S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR)
/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/* Handle to the SYSLOG channel */
-
-FAR static struct syslog_channel_s *g_syslog_file_channel;
-
-/****************************************************************************
* Private Functions
****************************************************************************/
@@ -175,6 +167,8 @@ end:
FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath)
{
+ FAR struct syslog_channel_s *file_channel;
+
/* Reset the default SYSLOG channel so that we can safely modify the
* SYSLOG device. This is an atomic operation and we should be safe
* after the default channel has been selected.
@@ -185,13 +179,6 @@ FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath)
sched_lock();
- /* Uninitialize any driver interface that may have been in place */
-
- if (g_syslog_file_channel != NULL)
- {
- syslog_dev_uninitialize(g_syslog_file_channel);
- }
-
/* Rotate the log file, if needed. */
#if CONFIG_SYSLOG_FILE_ROTATIONS > 0
@@ -206,9 +193,8 @@ FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath)
/* Then initialize the file interface */
- g_syslog_file_channel = syslog_dev_initialize(devpath, OPEN_FLAGS,
- OPEN_MODE);
- if (g_syslog_file_channel == NULL)
+ file_channel = syslog_dev_initialize(devpath, OPEN_FLAGS, OPEN_MODE);
+ if (file_channel == NULL)
{
goto errout_with_lock;
}
@@ -217,15 +203,15 @@ FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath)
* screwed.
*/
- if (syslog_channel(g_syslog_file_channel) != OK)
+ if (syslog_channel(file_channel) != OK)
{
- syslog_dev_uninitialize(g_syslog_file_channel);
- g_syslog_file_channel = NULL;
+ syslog_dev_uninitialize(file_channel);
+ file_channel = NULL;
}
errout_with_lock:
sched_unlock();
- return g_syslog_file_channel;
+ return file_channel;
}
#endif /* CONFIG_SYSLOG_FILE */