Merge pull request #371 from signalwire/switch_log

[Core] scan-build: Fix "The result of the '<<' expression is undefined" in switch_log_str2mask().
This commit is contained in:
Andrey Volk 2020-02-16 01:31:59 +04:00 committed by GitHub
commit 7a3605e984
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 1 deletions

View File

@ -304,6 +304,30 @@ SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level_t level)
return LEVELS[level];
}
static int switch_log_to_mask(switch_log_level_t level)
{
switch (level) {
case SWITCH_LOG_DEBUG:
return (1<<7);
case SWITCH_LOG_INFO:
return (1<<6);
case SWITCH_LOG_NOTICE:
return (1<<5);
case SWITCH_LOG_WARNING:
return (1<<4);
case SWITCH_LOG_ERROR:
return (1<<3);
case SWITCH_LOG_CRIT:
return (1<<2);
case SWITCH_LOG_ALERT:
return (1<<1);
case SWITCH_LOG_CONSOLE:
return (1<<0);
default:
return 0;
}
}
SWITCH_DECLARE(uint32_t) switch_log_str2mask(const char *str)
{
int argc = 0, x = 0;
@ -321,8 +345,9 @@ SWITCH_DECLARE(uint32_t) switch_log_str2mask(const char *str)
break;
} else {
level = switch_log_str2level(argv[x]);
if (level != SWITCH_LOG_INVALID) {
mask |= (1 << level);
mask |= switch_log_to_mask(level);
}
}
}