A checked global variable is used in the function, but not listed in its

 globals clause. By default, only globals specified in .lcl files are

 checked.

 To check all globals, use +allglobals. To check globals selectively use

 /*@checked@*/ in the global declaration. (Use -globs to inhibit warning)

debug0.с:36:17: Undetected modification possible from call to unconstrained

               function sort: sort

 An unconstrained function is called in a function body where

 modifications are checked. Since the unconstrained function may modify

 anything, there may be undetected modifications in the checked function.

 (Use -modunconnomods to inhibit warning)

debug0.c:36:17: Return value (type int) ignored: sort(array, 5)

 Result returned by function call is not used. If this is intended, can

 cast result to (void) to eliminate message. (Use -retvalint to inhibit

 warning)

debug0.c:37:14: Path with no return in function declared to return int

debug0.c:6:18: Variable exported but not used outside debug0: array

 A declaration is exported, but not used outside this module. Declaration

 can use static qualifier. (Use -exportlocal to inhibit warning)

debug0.c:14:13: Function exported but not used outside debug0: sort

 debug0.c:15:17: Definition of sort

debug0.c:6:18: Variable array exported but not declared in header file

 A variable declaration is exported, but does not appear in a header

 file. (Used with exportheader.) (Use -exportheadervar to inhibit warning)

debug0.c:14:13: Function sort exported but not declared in header file

 A declaration is exported, but does not appear in a header file. (Use

 -exportheader to inhibit warning)

debug0.c:15:17: Definition of sort

Finished checking - 22 code warnings

$

Утилита выражает неудовольствие по поводу объявления функций в старом стиле (не ANSI) и несоответствия типов значений, возвращаемых функциями, и самими величинами, которые они возвращают (или нет) в действительности. Эти предупреждения не влияют на работу программы, но должны быть выведены.

Она также обнаружила две реальные ошибки в следующем фрагменте кода:

/* 18 */  int s;

/* 19 */

/* 20 */  for(; i < n & s != 0; i++) {

/* 21 */   s = 0;

Средство splint определило (выделенные цветом строки предыдущего вывода), что переменная s используется в строке 20, но не была при этом инициализирована, и что оператор & стоит на месте более обычного оператора &&. В данном случае старшинство оператора изменяет значение условия и создает проблему в программе.

Обе эти ошибки были исправлены при чтении исходного текста программы до запуска процесса отладки. Несмотря на то, что пример мало изобретателен и служит только для демонстрации, подобные ошибки регулярно возникают в реальных программах."

<p>Средства, отслеживающие вызовы функций</p>

Три утилиты — ctags, cxref и cflow — формируют часть стандарта X/Open и, следовательно, должны включаться в системы, представляемые как системы UNIX с программными средствами разработки.

Перейти на страницу:

Похожие книги