Charles Binford wrote:
> Mark, James - thanks for you quick replies.  First, let's not get 
> distracted by queue.h.  It already has the CONSTCOND in it.  I'm 
> thinking it is probably OK if/when I get my environment setup 
> correctly.  I'm assuming the issue here is incorrect environment or lint 
> flags...

I am unable to duplicate your problem, using the same lint tool and 
arguments (modulo include directories).  So I don't think your 
environment is at fault, but rather I suspect something in your chain of 
include files.

You might consider abstracting the function that's giving you the error, 
  and gradually adding scope until you isolate the problem.

> 9:35 mjnelson at mrliberal [~/tmp] {4:0}% cat e.c
> #include <note.h>
> #define MYMACRO do { ; NOTE(CONSTCOND) } while (0)
> 
> void main(void) {
>       MYMACRO;
> 
>       do {
>               ;
>       NOTE(CONSTCOND)
>       } while (0);
> 
>       NOTE(CONSTCOND) while (1) { ; }
> }
> 9:35 mjnelson at mrliberal [~/tmp] {5:0}% 
> /ws/onnv-tools/SUNWspro/SS12/bin/lint -axsm -errtags=yes -s -Xc99=%all 
> -errsecurity=core -c e.c
> 9:35 mjnelson at mrliberal [~/tmp] {6:0}% 

...and using <sys/note.h> and _NOTE makes no difference.

So unless you're running into a redefinition of the NOTE() macro, in 
which case changing to <sys/note.h> and _NOTE() might help, I can't do 
much more research without a workspace pointer.  Code snippets aren't 
particularly useful here, when you're providing the well-formed and 
believed-to-be-correct parts.

Otherwise, all I can say is "it works for me, using the same tool and 
arguments," which hasn't solved your problem.

--Mark




> Turning to my specific code.  Yes, I included note.h.  Here are snippets 
> from my source code and the lint output.
> 
> ...
> #include <door.h>
> *#include <note.h>*
> #include <lib/hsm.h>
> ...
> static void *
> pm_housekeeping(void *arg)
> {
>     pm_session_t        *sess = (pm_session_t *)arg;
>     pm_xml_context_t    *xml_cxt = sess->xml_cxt;
>     int            xml_entries = 0;
>     int            doc_size;
> 
>     NOTE(CONSTCOND) while (1) {    /* <<<< line 856 */
>         pthread_mutex_lock(&sess->xml_cxt->fill_mutex);
> 
> and partial output from 'make lint'......
> /ws/onnv-tools/SUNWspro/SS12/bin/lint -axsm 
> -DTEXT_DOMAIN=\"SUNW_OST_OSCMD\" -D_TS_ERRNO  
> -I/cb/admONlint/proto/root_i386/usr/include    -DDEBUG 
> -I/cb/admONlint/usr/src/common/dmapi -I. -I../common 
> -I/cb/admONlint/usr/src/lib/hsm/include 
> -I/cb/admONlint/usr/src/lib/hsm/libhsmdb/common -I/usr/include/pgsql 
> -I/cb/admONlint/usr/src/lib/hsm/libhsmtrc/common 
> -I/cb/admONlint/usr/src/lib/hsm/libhsmcfg/common 
> -I/cb/admONlint/usr/src/lib/hsm/libhsmut/common 
> -I/cb/admONlint/usr/src/lib/hsm/libpm/common 
> -I/cb/admONlint/usr/src/lib/hsm/libpmapi/common 
> -I/cb/admONlint/usr/src/lib/hsm/libhsmwl/common -I/usr/include/libxml2 
> -I/hsm_tools/share/imq4.1/include 
> -I/cb/admONlint/usr/src/lib/hsm/libhsmmms/common 
> -I/cb/admONlint/usr/src/common/mms/mms 
> -I/cb/admONlint/usr/src/lib/hsm/libhsmmsg/common -errtags=yes -s 
> -erroff=E_PTRDIFF_OVERFLOW -erroff=E_ASSIGN_NARROW_CONV 
> -U__PRAGMA_REDEFINE_EXTNAME -Xc99=%all -errsecurity=core 
> -erroff=E_SEC_CREAT_WITHOUT_EXCL -erroff=E_SEC_FORBIDDEN_WARN_CREAT 
> -erroff=E_ASSIGN_INT_TO_SMALL_INT -erroff=E_CAST_INT_CONST_TO_SMALL_INT 
> -erroff=E_CAST_INT_TO_SMALL_INT -erroff=E_CAST_TO_PTR_FROM_INT 
> -erroff=E_COMP_INT_WITH_LARGE_INT -erroff=E_INTEGRAL_CONST_EXP_EXPECTED 
> -erroff=E_PASS_INT_TO_SMALL_INT -erroff=E_PTR_CONV_LOSES_BITS -c 
> ../common/pm_event.c                                                          
>                                                                      
> 
> "../common/pm_event.c", line 783: warning: constant in conditional 
> context (E_CONSTANT_CONDITION)
> "../common/pm_event.c", line 856: warning: constant in conditional 
> context (E_CONSTANT_CONDITION)
> 
> Charles
> 
> Mark J. Nelson wrote:
>>>> I'm working on the ADM project which will be delivered into ON in the
>>>> future.  I'm trying to get my code "lint clean" but am having some
>>>> troubles with a few constructs.  Is this page on lint directives
>>>> valid for ON? http://docs.sun.com/app/docs/doc/819-5265/bjaih?a=view
>>>>       
>>
>> Yes.
>>
>>   
>>>> I've been trying to fix the "constant in conditional" error.  Per the
>>>> above web site the NOTE(CONSTCOND) syntax is the preferred syntax,
>>>> and /* CONSTCOND */ is the old method.  I have a file where:
>>>>
>>>>     NOTE(CONSTCOND) while (1) {
>>>>
>>>> Gives and error, yet
>>>>
>>>>     /* CONSTCOND */
>>>>     while (1) {
>>>>
>>>> works fine.
>>>>       
>>
>> Did you include the directive
>>
>>      #include <note.h>
>>
>> in this file, as directed in the second paragraph of the documentation 
>> you referenced?
>>
>>   
>>>> I have other code using marcos with the 'do {xxxx } while (0)' syntax
>>>> and I can't get ANY form of the CONSTCOND to work. I'm even getting
>>>> errors when I use the macros in /usr/include/sys/queue.h.
>>>>       
>>
>> This is kind of ugly, but the following really DOES work:
>>
>>   
>>> #include <note.h>
>>> #define MYMACRO do { ; NOTE(CONSTCOND) } while (0)
>>>
>>> void main(void) {
>>>     MYMACRO;
>>> }
>>>     
>>
>> If you're doing this in a macro, then you MUST use the NOTE(CONSTCOND) 
>> notation, instead of the /* CONSTCOND */ comment, because the 
>> preprocessor will strip the comment when it expands the macro.
>>
>>   
>>> There's not much we can do about <sys/queue.h> unless you want to
>>> fix upstream (in whichever *BSD we found it) and then sync up.
>>>     
>>
>> I agree.
>>
>>   
>>>> I'm doing 'make lint' from my $SRC/cmd/hsm directory.  The Makefile
>>>> there includes the top level Makefile.master, which has a bunch of
>>>> lint flags defined.
>>>>
>>>> My lint version is:
>>>> /ws/onnv-tools/SUNWspro/SS12/bin/lint -V
>>>> lint: Sun C 5.9 SunOS_i386 Patch 124868-07 2008/10/07
>>>>
>>>> Any suggestions are greatly appreciated.
>>>>       
>>
>> See above.  What James suggests below is probably also acceptable, but 
>> is a blanket exception, rather than the preferred per-usage notation.
>>
>>   
>>> What I ended up doing for fwflash was to add
>>>
>>> -erroff=E_CONSTANT_CONDITION
>>>
>>> to $SRC/cmd/fwflash/Makefile.com's LINTFLAGS definition.
>>>
>>> It's ugly and annoying, but it works and was acceptable
>>> to my RTI advocate :-) 
>>>     
>>
>> Hm; wonder who that could have been?
>>
>> --Mark
>> _______________________________________________
>> on-discuss mailing list
>> on-discuss at opensolaris.org
>> http://mail.opensolaris.org/mailman/listinfo/on-discuss
>>   


Reply via email to