CSC 201 Grinnell College Spring, 2005
 
Data Representation, Memory Management, and Formal Methods
 

Laboratory Exercise on the Static Checking of C Programs

Goals

This lab provides some preliminary practice with the splint static-checking program.

Reference

The main reference for splint may found at http://www.splint.org. In particular, you will want to consult the the on-line Splint Manual.

Warm Up

At the start of the semester, we reviewed some basic elements of C programming through:

Within that presentation, Program 14 ~walker/c/examples/trap-4.c shows the Trapezoidal Rule to illustrate several elements of C-style conditionals, loops, and functions.

  1. Copy ~walker/c/examples/trap-4.c, compile and run it, and then review the code to remind yourself how it works.

  2. Run splint on this program with the command

    
        splint trap-4.c
    

    and copy the resulting output to an editor.

    Explain what is meant by the various warnings that are generated.
    (When the same warning is given in several places, you may group the multiple occurrences together with a single explanation.)

  3. Modify trap-4.c to produce a program trap-4-rev.c that performs exactly the same computation, but so that at least 4 warnings are resolved (including at least 2 different types of warnings).

Dynamic Memory

Within this course, several labs provided practice with singly-linked lists. For example, the first of these was a Laboratory Exercise on Singly-Linked Lists. Within that lab, the program namelist.c provided a simple driver for work that followed.

  1. Copy ~walker/c/lists/namelist.c to your account, and run splint on it.

splint produces several (many) warnings, some of which you have already seen from the first part of this lab. In what follows, you should focus on new warnings that might be found.

  1. Identify at least 5 new and different warnings, and explain what each means.

Your code

  1. Choose a program of yours that completes one of the following:

    Use splint on your program, giving a full listing of any warnings generated.

  2. Modify your program to resolve at least 6 (unless your program had fewer than 6 warnings, in which case you should resolve half of the warnings generated).

Work to turn in


This document is available on the World Wide Web as

     http://www.cs.grinnell.edu/~walker/courses/201.sp05/labs/lab-static-checking.shtml

created 21 January 2005
last revised 8 May 2005
Valid HTML 4.01! Valid CSS!
For more information, please contact Henry M. Walker at walker@cs.grinnell.edu.