Slashdot Mirror


Automated Linux Error Checking

Caydel writes "In a recent message to the Linux Kernel Mailing List (LKML), Ben Chelf, CTO of Coverity, Inc. announced an internal framework to continually scan open source projects for source defects and provide the results of their analysis back to the developers of those projects. The linux kernel is one of 32 open source projects monitored by Coverity. Coverity is looking for a few group-nominated maintainers to access the reports, in order to patch the bugs found before they are announced to the general public. For those not familiar with Coverity, they are a small company out of Stanford who monitor source code correctness through automatic static source code analysis."

2 of 25 comments (clear)

  1. static_analysis++ by tcopeland · · Score: 4, Interesting
    I've worked on an open source Java code analysis project for the past few years; static analysis can be a very handy tool. Having an automated check for things that aren't even bugs, but are just overly wordy code blocks:
    public boolean foo(int x) {
      if (x>2) {
        return true;
      } else {
        return false;
      }
    }
    is quite helpful. Changing the above code to "return x>2" will save four bytes and will read a bit smoother, too. There are many other examples of this sort of thing.

    Lots more on all that in my book - there's a downloadable free chapter there on using static analysis to improve JUnit tests if you want to get a feel for things.

    1. Re:static_analysis++ by tcopeland · · Score: 5, Informative
      > I'd like to know how you figured that code would have saved you "4 bytes"

      Good question:
      $ cat Bar.java Bar1.java && javac Bar.java Bar1.java && ls -l Bar*.class
      public class Bar {
        public boolean foo(int x) {
          if (x>2) {
            return true;
          } else {
            return false;
          }
        }
      }
      public class Bar1 {
        public boolean foo(int x) {
          return x>2;
        }
      }
      -rw-rw-r-- 1 tom tom 244 Mar 6 11:53 Bar1.class
      -rw-rw-r-- 1 tom tom 248 Mar 6 11:53 Bar.class

      That's JDK 1.4 on Linux, perhaps newer javac versions do a better job...