posix: syslog: Fix uninitialized variable error

Seen this in compiler

lib/posix/options/syslog.c: In function 'setlogmask':
lib/posix/options/syslog.c:66:16: error: 'oldpri' may be used uninitialized
   66 |         return oldpri;
      |                ^~~~~~
lib/posix/options/syslog.c:59:13: note: 'oldpri' was declared here
   59 |         int oldpri;
      |             ^~~~~~
lib/posix/options/syslog.c: In function 'vsyslog':
lib/posix/options/syslog.c:83:33: error: 'mask' may be used uninitialized
   83 |         if ((BIT(level) & mask) == 0) {
      |             ~~~~~~~~~~~~~~~~~~~~^~~~
lib/posix/options/syslog.c:71:17: note: 'mask' was declared here
   71 |         uint8_t mask;
      |                 ^~~~

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
Jukka Rissanen 2024-03-08 17:03:46 +02:00 committed by Chris Friedt
parent 826ac0755b
commit 71fd9b2e07
1 changed files with 2 additions and 2 deletions

View File

@ -56,7 +56,7 @@ void syslog(int priority, const char *format, ...)
int setlogmask(int maskpri)
{
int oldpri;
int oldpri = -1;
K_SPINLOCK(&syslog_lock) {
oldpri = syslog_mask;
@ -68,7 +68,7 @@ int setlogmask(int maskpri)
void vsyslog(int priority, const char *format, va_list ap)
{
uint8_t mask;
uint8_t mask = 0;
int level = syslog_priority_to_zephyr_log_level(priority);
if (level < 0) {