Kniga-Online.club
» » » » Основы программирования в Linux - Мэтью Нейл

Основы программирования в Linux - Мэтью Нейл

Читать бесплатно Основы программирования в Linux - Мэтью Нейл. Жанр: Интернет год 2004. Так же читаем полные версии (весь текст) онлайн без регистрации и SMS на сайте kniga-online.club или прочесть краткое содержание, предисловие (аннотацию), описание и ознакомиться с отзывами (комментариями) о произведении.
Перейти на страницу:

/* 17 */  int i = 0, j = 0;

/* 18 */  int s;

/* 19 */

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

/* 21 */   s = 0;

/* 22 */   for(j = 0; j < n; j++) {

/* 23 */    if(a[j].key > a[j+1].key) {

/* 24 */     item t = a[j];

/* 25 */     a[j] = a[j+1];

/* 26 */     a[j+1] = t;

/* 27 */     s++;

/* 28 */    }

/* 29 */   }

/* 30 */   n--;

/* 31 */  }

/* 32 */ }

/* 33 */

/* 34 */ main()

/* 35 */ {

/* 36 */  sort(array,5);

/* 37 */ }

В этой версии есть проблема в строке 20, где вместо предполагаемого оператора && применяется оператор &. Далее приведен отредактированный пример вывода splint, выполненной с этой версией программы. Обратите внимание на то, как она обнаруживает проблемы в строке 20 — тот факт, что вы не инициализировали переменную s и что возможны проблемы с условием из-за некорректного оператора.

[email protected]:~/BLP4e/chapter10&gt; <b>splint -strict debug0.c</b>

Splint 3.1.1 --- 19 Mar 2005

debug0.c:7:18: Read-only string literal storage used as initial value for

               unqualified storage: array[0].data = &quot;bill&quot;

A read-only string literal is assigned to a non-observer reference. (Use -readonlytrans to inhibit warning)

debug0.c:8:18: Read-only string literal storage used as initial value for

               unqualified storage: array[1].data = &quot;neil&quot;

debug0.c:9:18: Read-only string literal storage used as initial value for

               unqualified storage: array[2].data = &quot;john&quot;

debug0.с:10:18: Read-only string literal storage used as initial value for

               unqualified storage: array[3].data = &quot;rick&quot;

debug0.c:11:18: Read-only string literal storage used as initial value for

               unqualified storage: array[4].data = &quot;alex&quot;

debug0.с:14:22: Old style function declaration

 Function definition is in old style syntax. Standard prototype syntax is

 preferred. (Use -oldstyle to inhibit warning)

debug0.с: (in function sort)

<i>debug0.c:20:31: Variable s used before definition</i>

<i> An rvalue is used that may not be initialized to a value on some execution</i>

<i> path. (Use -usedef to inhibit warning)</i>

debug0.с:20:23: Left operand of &amp; is not unsigned value (boolean):

               i &lt; n &amp; s != 0

 An operand to a bitwise operator is not an unsigned values. This may have

 unexpected results depending on the signed representations. (Use

 -bitwisesigned to inhibit warning).

<i>debug0.c:20:23: Test expression for for not boolean, type unsigned int:</i>

<i>               i &lt; n &amp; s != 0</i>

<i> Test expression type is not boolean or int. (Use -predboolint to inhibit </i>

<i> warning);</i>

debug0.с:25:41: Undocumented modification of a[]: a[j] = a[j + 1]

 An externally-visible object is modified by a function with no /*@[email protected]*/

 comment. The /*@modifies ... @*/ control comment can be used to give a

 modifies list for an unspecified function. (Use -modnomods to inhibit

 warning)

debug0.c:26:41: Undocumented modification of a[]: a[j + 1] = t

debug0.c:20:23: Operands of &amp; are non-integer (boolean) (in post loop test):

               i &lt; n &amp; s != 0

 A primitive operation does not type check strictly. (Use -strictops to

 inhibit warning)

debug0.с:32:14: Path with no return in function declared to return int

 There is a path through a function declared to return a value on which there

 is no return statement. This means the execution may fall through without

 returning a meaningful result to the caller. (Use -noret to inhibit

 warning)

debug0.с:34:13: Function main declared without parameter list

 A function declaration does not have a parameter list. (Use -noparams

 to inhibit warning)

debug0.с: (in function main)

debug0.с:36:22: Undocumented use of global array

 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

 /*@[email protected]*/ in the global declaration. (Use -globs to inhibit warning)

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

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

Мэтью Нейл читать все книги автора по порядку

Мэтью Нейл - все книги автора в одном месте читать по порядку полные версии на сайте онлайн библиотеки kniga-online.club.


Основы программирования в Linux отзывы

Отзывы читателей о книге Основы программирования в Linux, автор: Мэтью Нейл. Читайте комментарии и мнения людей о произведении.


Уважаемые читатели и просто посетители нашей библиотеки! Просим Вас придерживаться определенных правил при комментировании литературных произведений.

  • 1. Просьба отказаться от дискриминационных высказываний. Мы защищаем право наших читателей свободно выражать свою точку зрения. Вместе с тем мы не терпим агрессии. На сайте запрещено оставлять комментарий, который содержит унизительные высказывания или призывы к насилию по отношению к отдельным лицам или группам людей на основании их расы, этнического происхождения, вероисповедания, недееспособности, пола, возраста, статуса ветерана, касты или сексуальной ориентации.
  • 2. Просьба отказаться от оскорблений, угроз и запугиваний.
  • 3. Просьба отказаться от нецензурной лексики.
  • 4. Просьба вести себя максимально корректно как по отношению к авторам, так и по отношению к другим читателям и их комментариям.

Надеемся на Ваше понимание и благоразумие. С уважением, администратор kniga-online.


Прокомментировать
Подтвердите что вы не робот:*
Подтвердите что вы не робот:*