DBG(0, ...)

From: Petter Reinholdtsen (pere@hungry.com)
Date: Mon May 14 2001 - 01:16:35 PDT

  • Next message: Petter Reinholdtsen: "Re: [dev] Status of pnm.c-bad?"

    I believe there is a misfeature in the DBG() functions. Peter Fales
    pointed out to me that the following code in a backend

      DBG(0, "foo");

    will print out "foo" even if SANE_DEBUG_BACKEND is not set. I believe
    this is wrong. I believe DBG() should not print anything unless
    debugging is enabled for that specific backend. I suggest applying
    this patch to fix it. Is there anything I haven't thought about?

    The patch changes the default level to be (in practise, not in
    reality) -1, instead of the previous default level 0.

    Index: sanei/sanei_init_debug.c
    ===================================================================
    RCS file: /cvsroot/external/sane/sane-backends/sanei/sanei_init_debug.c,v
    retrieving revision 1.3
    diff -u -w -r1.3 sanei_init_debug.c
    --- sanei_init_debug.c 2000/10/23 14:59:57 1.3
    +++ sanei_init_debug.c 2001/05/14 08:14:53
    @@ -87,7 +87,7 @@
       if (!val)
         return;
     
    - *var = atoi (val);
    + *var = atoi (val) + 1;
     
       DBG (0, "Setting debug level of %s to %d.\n", backend, *var);
     }
    @@ -98,7 +98,7 @@
     {
       char *msg;
     
    - if (max_level >= level)
    + if (max_level >= level + 1)
         {
           if ( 1 == isfdtype(fileno(stderr), S_IFSOCK) )
            {

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com
    



    This archive was generated by hypermail 2b29 : Mon May 14 2001 - 01:02:42 PDT