Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - pathmgr/devmem.c -- case out of range: (2 Items)
   
pathmgr/devmem.c -- case out of range  
I was linting devmem.c and I came across an interesting problem, lint complains of the following:
file: services/system/pathmgr/devmem.c, line:286, Warning, 650, "Constant '-2147221246' out of range for operator 'case'
"

So, I looked up the C89 standard (identical to the ANSI standard, except for section numbering), and it said, under 
constraints:
"The expression of each case label shall be an integral constant expression."

This makes sense ,,, so, assuming DCMD_ALL_SETFLAGS (which is __DIOT(_DMCD_ALL, 2, int)) is a long int, it should fall 
within the correct range (-2147483647, 2147483647).
This being the case, why is the complaint being made that it is out of range for the "case" operator?

Any ideas, as to the cause of the issue, or a suggested plan of action, would be appreciated.

Thanks,
-Aaron
Re: pathmgr/devmem.c -- case out of range  
Brian, you were right.
I casted the variable coming into the switch statement to unsigned, and the warning went away.
so instead of:
switch(msg->i.dcmd){...}
I had:
switch((unsigned)msg->i.dcmd){...}

beautiful :)
Thanks.
-Aaron