Fabio M. Di Nitto wrote:
> This patch fixes one exit path error handling in logsys_format_set
> and add 2 error checks when returning from
> logsys_config_file_set_unlocked.
>
> Fabio
>
> Index: exec/logsys.c
> ===================================================================
...
> @@ -1248,13 +1253,14 @@
>
>       if (format) {
>               format_buffer = strdup(format);
> -             if (format_buffer == NULL) {
> -                     ret = -1;
> -             }
>       } else {
>               format_buffer = strdup("[%6s] %b");
>       }
>
> +     if (format_buffer == NULL) {
> +             ret = -1;
> +     }
> +
>       pthread_mutex_unlock (&logsys_config_mutex);
>       return ret;
>  }

That looks correct.
With your changes, logsys_format_set has these lines
inside the lock/unlock statements:

        if (format_buffer) {
                free(format_buffer);
                format_buffer = NULL;
        }

        if (format) {
                format_buffer = strdup(format);
        } else {
                format_buffer = strdup("[%6s] %b");
        }

        if (format_buffer == NULL) {
                ret = -1;
        }

I find the following easier to read,
and it's functionally equivalent:

        free(format_buffer);
        format_buffer = strdup(format ? format : "[%6s] %b");
        if (format_buffer == NULL) {
                ret = -1;
        }
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to