Use an early return for detecting log levels
Reduced nesting is generally more readable
@@ -108,7 +108,10 @@ static char log_buff[LOG_SIZE];
*/
static void gpi_log_native_v(const char *name, enum gpi_log_levels level, const char *pathname, const char *funcname, long lineno, const char *msg, va_list argp)
{
- if (level >= GPIInfo) {
+ if (level < GPIInfo) {
+ return;
+ }
+
int n = vsnprintf(log_buff, LOG_SIZE, msg, argp);
if (n < 0 || n >= LOG_SIZE) {
@@ -132,7 +135,6 @@ static void gpi_log_native_v(const char *name, enum gpi_log_levels level, const
fprintf(stdout, "\n");
fflush(stdout);
}
-}
static void gpi_log_native(const char *name, enum gpi_log_levels level, const char *pathname, const char *funcname, long lineno, const char *msg, ...)
{
