[stgt] [PATCH 2/3] few logger fixes

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Thu Jun 3 16:23:07 CEST 2010


On Thu, 03 Jun 2010 16:23:10 +0300
Alexander Nezhinsky <alexandern at Voltaire.COM> wrote:

> added initialization and safety checks for the logarea pointer
> 
> Signed-off-by: Alexander Nezhinsky <alexandern at voltaire.com>
> ---
>  usr/log.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/usr/log.c b/usr/log.c
> index 305e14f..be9b0c2 100644
> --- a/usr/log.c
> +++ b/usr/log.c
> @@ -42,7 +42,7 @@
>  #define logdbg(file, fmt, args...) do {} while (0)
>  #endif
>  
> -static struct logarea *la;
> +static struct logarea *la = NULL;

Hmm, guaranteed to be initialized.

>  static char *log_name;
>  int is_debug = 0;
>  static pid_t pid;
> @@ -131,10 +131,13 @@ static int logarea_init (int size)
>  
>  static void free_logarea (void)
>  {
> +	if (!la)
> +		return;
>  	semctl(la->semid, 0, IPC_RMID, la->semarg);
>  	shmdt(la->buff);
>  	shmdt(la->start);
>  	shmdt(la);
> +	la = NULL;
>  }
>  
>  #if LOGDBG
> @@ -308,6 +311,9 @@ static void log_flush(void)
>  {
>  	struct sembuf ops;
>  
> +	if (!la)
> +		return;
> +
>  	while (!la->empty) {
>  		ops.sem_num = 0;
>  		ops.sem_flg = 0;
> -- 
> 1.6.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stgt" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list