Intended fallthrough in switch case?

62 views
Skip to first unread message

joce

unread,
Sep 4, 2009, 5:22:37 PM9/4/09
to scintilla-interest
I'm running PC-Lint on the Scintilla code base, and it reported a
potentially unintended fallthrough in a switch case.

In RESearch.cxx, RESearch::GetBackslashExpression():

There's this chunk of code (around line 420):

case 'S':
for (c = 0; c < MAXCHR; c++) {
if (c != ' ' && !(c >= 0x09 && c <= 0x0D)) {
ChSet(static_cast<unsigned char>(c));
}
}
case 'w':
for (c = 0; c < MAXCHR; c++) {
if (iswordc(static_cast<unsigned char>(c))) {
ChSet(static_cast<unsigned char>(c));
}
}
break;


Is the "missing" break for case 'S' intended or not?

Note: this is taken from version 2.01, the one currently in use in
Notepad++ trunk.

cheers,

joce.

Neil Hodgson

unread,
Sep 4, 2009, 5:37:21 PM9/4/09
to scintilla...@googlegroups.com
joce:

> I'm running PC-Lint on the Scintilla code base, and it reported a
> potentially unintended fallthrough in a switch case.

>...


>        case 'S':
>                for (c = 0; c < MAXCHR; c++) {
>                        if (c != ' ' && !(c >= 0x09 && c <= 0x0D)) {
>                                ChSet(static_cast<unsigned char>(c));
>                        }
>                }
>        case 'w':

While it isn't intended it should actually be OK. 'S' is the set of
non-space characters and 'w' is the set of word characters. All of the
'w' should already be set in 'S' unless there space characters are
allowed in words.

Fixed.

My experience with PC-Lint is that it produces a very large number
of low value warnings until you build a good suppression file so I
don't intend to fix all PC-Lint warnings.

Neil

Jocelyn Legault

unread,
Sep 4, 2009, 7:13:59 PM9/4/09
to scintilla...@googlegroups.com
Neil.

Thanks for the prompt answer. While I do try to keep a Lint-free build of Scintilla on my own system, I did not expect you to fix any Lint warnings. It's just that it's not always clear what was the intention of the author was with the fallthrough warnings that I posted this question.

BTW, I find PC-Lint to be an invaluable tool. And while it's true that it can generate a lot of warnings for stuff that is of lesser importance, I still try to keep the project I work on "Lint-free", just I I try to keep the "warning-free".  It's just so easy for an insidious error to slip though the cracks if you have tons of messages. 

Also, over the course of the years, I've manage to get a good set of what I consider meaningful warnings, and I've culled out much of the rest.  If you're interested in my options.lnt file, I'd be happy to share it with you.

cheers,

joce.
Reply all
Reply to author
Forward
0 new messages