lwl-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwl-general] lwl_write_log behavior when handle is NULL


From: itoi
Subject: [lwl-general] lwl_write_log behavior when handle is NULL
Date: Thu, 25 Nov 2004 14:15:49 -0500 (EST)

Hello, LWL developers,

I have been using LWL for the last couple of months, and I find it very
useful and stable.  Thank you very much for your great work.

I would like to make one suggestion.  In:

        lwl_write_log(handle, priority, format)

when handle is NULL, LWL crashes with segmentation fault.  This is an
understandable behavior, but I think there are some cases you don't want
this to happen.  For example, let's say library code which does
lwl_write_log() is shared by two programs.  The first program wants to
log, but the second one doesn't.  Right now, there does not seem to be an
easy way for the second one to say "I don't want to log" to LWL.

I suggest lwl_write_log() to just return when the handle is NULL.  This
way, the only thing the second program has to do is to make sure handle is
NULL when it calls lwl_write_log().

Returning without doing anything is a nicer behavior than segfault, too.

I attach the diff at the end of this e-mail.

Thank you for your consideration.

--
"And one last thing.  You can never get open if you don't want to."

Naomaru Itoi


bash-2.05b$ diff -c  lwl.c.org lwl.c
*** lwl.c.org   2002-12-18 08:20:49.000000000 -0800
--- lwl.c       2004-11-25 10:59:55.000000000 -0800
***************
*** 109,114 ****
--- 109,118 ----
    int n;
    FILE *default_file;

+   if (h == NULL) {
+       return;
+   }
+
    if (h->log_level < pri)
      {
        return;






reply via email to

[Prev in Thread] Current Thread [Next in Thread]