lclint-interest message 149

From Mon Sep 15 10:20:54 1997
X-Env: ( ->
Date: Mon, 15 Sep 1997 08:03:19 +0200
From: Harald Kirsch 
Organization: IITB
X-Mailer: Mozilla 3.01Gold (X11; I; Linux 2.0.18 i586)
Mime-Version: 1.0
Subject: How do I tell lclint that ...?
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi there,

I like the idea of lclint very much, but often it is really hard
to tell it what I mean. Does anybody know how to annotate the
following code so that lclint does not complain about a memory
leak in the line

  s1 = table[0].bobo(s1, s2);

Here comes the code:

typedef char *
(*Bobo)(/*@only@*/char *s1, /*@only@*/char *s2);

typedef struct s_Bla {
  int i;
  Bobo bobo;
} Bla;

extern char *bobo1(char *, char*);
extern char *bobo2(char *, char*);

Bla table[] = {
  {1, bobo1},
  {2, bobo2}

main(int argc, char **argv)
  char *s1 = malloc(10);
  char *s2 = malloc(20);

  s1 = table[0].bobo(s1, s2);

  return 0;

For reference, here come my ~/.lclintrc

## show column position in errors?

## length of output lines
-linelen 72

## most unannotated pointers are implicitly set to `only', in particular
##  o global storage
##  o return values
##  o structure fields

## character constants like 'a' can be used as int.

## all macros not marked /*@notfunction@*/ must have a prototype

## I prefer to negate pointers, as in
##    x = malloc(..)
##    if( !x ) { ... }

	Harald Kirsch

Harald Kirsch   +----------------+ If you don't like make, have a look | IITB Karlsruhe | at

Previous Message Next Message Archive Summary LCLint Home Page David Evans
University of Virginia, Computer Science