how to check missing breaks in switch case blocks

K

kernus

I want to know how to do a static code analysis with my C code in
Perl, instead of splint.

anyone give and ideas or some perl scripts?

thanks in advance.
 
S

smallpond

I want to know how to do a static code analysis with my C code in
Perl, instead of splint.

anyone give and ideas or some perl scripts?

thanks in advance.

Since falling through to the next case is legal in C
and C syntax does not provide any kind of explicit
indication your task is hopeless.

Other than break, common last lines of a case include
goto, continue and return - all perfectly valid.
Putting a break after any of these would be likely to
generate an unreachable statement warning.

My advice is to port your application to perl which is
known for its clean, maintainable syntax.

Here is a free rexexp for checking for using '=' when you
meant '==' in an if statement. Enjoy.

/\Wif\W.*[^=><!]=[^=].*\)/
 
S

sln

I want to know how to do a static code analysis with my C code in
Perl, instead of splint.

anyone give and ideas or some perl scripts?

thanks in advance.

You know, that phrase 'code analysis' reminds me of the phrase
'engine repair'. I guess in both cases, a lot has to be taken apart
first.

By the time you develop a C/C++ parser in Perl, I have a feeling
you won't be asking that question.

-sln
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top