Microsoft Auto Code Review (OACR)

Microsoft Auto Code Review (known by the acronym OACR) is a set of tools that use static analysis to find potential defects in your driver source code. OACR can help find bugs, suggest code improvements, and speed up the development process. OACR integrates PREfast for Drivers into the WDK build environment. OACR runs in the background and intercepts the build commands and stores them in a queue and waits for the computer to become inactive. OACR runs without slowing down a regular build and without adding another step to the build process.

Configuring OACR for Your Project

OACR organizes its code analysis and reporting based on projects. For example, a project could be a specific driver or application, and would include everything built under the same directory tree. You can use a configuration file to control the settings for a project. OACR is integrated with the WDK build environment and it defines a default project, so you can begin to use OACR without having to do any extra work.

For information about turning OACR on or off, and to control and name your own projects, see Configuring Microsoft Auto Code Review (OACR). For information about OACR command options and configuration files, see Microsoft Auto Code Review (OACR) Reference.

Getting Started with OACR

By default, OACR is configured to check files in a low priority background process. OACR automatically starts when you open a Build environment window. The OACR Monitor is a taskbar bar applet that indicates the status of all OACR activity. The OACR Monitor is automatically started when needed. All OACR activity runs as low priority, so there is never a need to close the applet.

If OACR has not found any potential problems with the code that would cause a warning or error, the OACR Monitor is green:

Green icon indicating no problems found

If OACR finds potential problems with the code, the OACR Monitor is yellow, indicating that there are warnings that need to be examined:

Yellow icon indicating warnings found

If OACR finds potentially serious problems with the code, the OACR Monitor is red, indicating that there are warnings that are considered critical errors that should be examined:

Red icon indicating errors found

Viewing and Fixing Warnings and Errors

If the OACR Monitor reports problems with the code, follow these steps:

  1. Right-click the OACR Monitor in the taskbar and click View Warnings (or View Errors) from the shortcut menu.

    The View Warnings and View Errors menus list the names of the projects where problems were found.

  2. Click the name of the project to open the PREfast Defect Viewer.

Note   The default name of the project for anything built under the Windows DDK directory (%BASEDIR%) is WDKSamples: buildflavor. For example, if you open a Win7 x86 Free Build Window and build one of the samples in the WDK, under the src subdirectory, the name of the project would be WDKSamples:x86fre. Similarly, anything built outside of the %BASEDIR% of the WDK takes the name root:buildflavor, for example, root:x86fre.

For information about the viewer and about the warning messages listed, see Browsing the Message List. OACR conveniently integrates the PREfast Defect Viewer into the build environment. Use the Defect Viewer to review the warning messages and to display an annotated view of your source code. The annotated view shows precisely where the errors appear in your code.

Use the context-sensitive Help for the PREfast for Drivers Warnings to understand and fix the problems. Repeat the cycle of fixing and rebuilding until no warnings are found.

The code analysis tools can generate a lot of data. To improve the results of the code analysis, you can take steps to suppress or work around certain conditions that PREfast flags as warnings. For information, see Minimizing Noise.

 

 

Send comments about this topic to Microsoft

Build date: 5/3/2011

Show: