Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#408 closed ожидается проверка (задача сдана)

WW #5

Reported by: Tarabonda German Owned by: Дмитрий Свиридкин
Component: WW_c_io Version: 2.0
Keywords: Cc:

Description


Change History (3)

comment:1 Changed 5 years ago by Дмитрий Свиридкин

Owner: changed from Дмитрий Свиридкин to Tarabonda German
Type: ожидается проверкаожидаются исправления

Как вы компилировали-то? У вас UB из-за отсутствующих предобъявлений. И указатели на функции с разными сигнатурами кастятся. Так делать нельзя.

src/clist.c:22:34: warning: unused parameter ‘list’ [-Wunused-parameter]

void remove_node(intrusive_list *list, intrusive_node *node) {

~

gcc -Wall -Wextra -Iinclude -c src/main.c -o obj/main.o
src/main.c: In function ‘my_print’:
src/main.c:7:23: warning: implicit declaration of function ‘get_point’; did you mean ‘add_point’? [-Wimplicit-function-declaration]

point_node *dot = get_point(node);


add_point

src/main.c:7:23: warning: initialization of ‘point_node *’ {aka ‘struct point_node *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
src/main.c: In function ‘my_count’:
src/main.c:11:31: warning: unused parameter ‘node’ [-Wunused-parameter]

void my_count(intrusive_node *node, int *counter){

~

src/main.c: In function ‘save_text’:
src/main.c:16:23: warning: initialization of ‘point_node *’ {aka ‘struct point_node *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]

point_node *dot = get_point(node);


src/main.c: In function ‘save_bin’:
src/main.c:21:23: warning: initialization of ‘point_node *’ {aka ‘struct point_node *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]

point_node *dot = get_point(node);


src/main.c: In function ‘main’:
src/main.c:57:22: warning: passing argument 2 of ‘apply’ from incompatible pointer type [-Wincompatible-pointer-types]

apply(l, save_text, fouttext);


In file included from include/point_list.h:4,

from src/main.c:4:

include/clist.h:22:41: note: expected ‘void (*)(intrusive_node *, void *)’ {aka ‘void (*)(struct intrusive_node *, void *)’} but argument is of type ‘void (*)(intrusive_node *, FILE *)’ {aka ‘void (*)(struct intrusive_node *, struct _IO_FILE *)’}

void apply(intrusive_list *list, void (*op)(intrusive_node *node, void *data), void *data);

~

src/main.c:65:22: warning: passing argument 2 of ‘apply’ from incompatible pointer type [-Wincompatible-pointer-types]

apply(l, save_bin, foutbin);

~

In file included from include/point_list.h:4,

from src/main.c:4:

include/clist.h:22:41: note: expected ‘void (*)(intrusive_node *, void *)’ {aka ‘void (*)(struct intrusive_node *, void *)’} but argument is of type ‘void (*)(intrusive_node *, FILE *)’ {aka ‘void (*)(struct intrusive_node *, struct _IO_FILE *)’}

void apply(intrusive_list *list, void (*op)(intrusive_node *node, void *data), void *data);

~

src/main.c:73:22: warning: passing argument 2 of ‘apply’ from incompatible pointer type [-Wincompatible-pointer-types]

apply(l, my_count, &k);

~

In file included from include/point_list.h:4,

from src/main.c:4:

include/clist.h:22:41: note: expected ‘void (*)(intrusive_node *, void *)’ {aka ‘void (*)(struct intrusive_node *, void *)’} but argument is of type ‘void (*)(intrusive_node *, int *)’ {aka ‘void (*)(struct intrusive_node *, int *)’}

void apply(intrusive_list *list, void (*op)(intrusive_node *node, void *data), void *data);

~

src/main.c:78:22: warning: passing argument 2 of ‘apply’ from incompatible pointer type [-Wincompatible-pointer-types]

apply(l, my_print, argv[4]);

~

In file included from include/point_list.h:4,

from src/main.c:4:

include/clist.h:22:41: note: expected ‘void (*)(intrusive_node *, void *)’ {aka ‘void (*)(struct intrusive_node *, void *)’} but argument is of type ‘void (*)(intrusive_node *, char *)’ {aka ‘void (*)(struct intrusive_node *, char *)’}

void apply(intrusive_list *list, void (*op)(intrusive_node *node, void *data), void *data);

~

src/main.c:105:22: warning: passing argument 2 of ‘apply’ from incompatible pointer type [-Wincompatible-pointer-types]

apply(l, save_text, fouttext);


In file included from include/point_list.h:4,

from src/main.c:4:

include/clist.h:22:41: note: expected ‘void (*)(intrusive_node *, void *)’ {aka ‘void (*)(struct intrusive_node *, void *)’} but argument is of type ‘void (*)(intrusive_node *, FILE *)’ {aka ‘void (*)(struct intrusive_node *, struct _IO_FILE *)’}

void apply(intrusive_list *list, void (*op)(intrusive_node *node, void *data), void *data);

~

src/main.c:113:22: warning: passing argument 2 of ‘apply’ from incompatible pointer type [-Wincompatible-pointer-types]

apply(l, save_bin, foutbin);

~

In file included from include/point_list.h:4,

from src/main.c:4:

include/clist.h:22:41: note: expected ‘void (*)(intrusive_node *, void *)’ {aka ‘void (*)(struct intrusive_node *, void *)’} but argument is of type ‘void (*)(intrusive_node *, FILE *)’ {aka ‘void (*)(struct intrusive_node *, struct _IO_FILE *)’}

void apply(intrusive_list *list, void (*op)(intrusive_node *node, void *data), void *data);

~

src/main.c:121:22: warning: passing argument 2 of ‘apply’ from incompatible pointer type [-Wincompatible-pointer-types]

apply(l, my_count, &k);

~

In file included from include/point_list.h:4,

from src/main.c:4:

include/clist.h:22:41: note: expected ‘void (*)(intrusive_node *, void *)’ {aka ‘void (*)(struct intrusive_node *, void *)’} but argument is of type ‘void (*)(intrusive_node *, int *)’ {aka ‘void (*)(struct intrusive_node *, int *)’}

void apply(intrusive_list *list, void (*op)(intrusive_node *node, void *data), void *data);

~

src/main.c:126:22: warning: passing argument 2 of ‘apply’ from incompatible pointer type [-Wincompatible-pointer-types]

apply(l, my_print, argv[4]);

~

In file included from include/point_list.h:4,

from src/main.c:4:

include/clist.h:22:41: note: expected ‘void (*)(intrusive_node *, void *)’ {aka ‘void (*)(struct intrusive_node *, void *)’} but argument is of type ‘void (*)(intrusive_node *, char *)’ {aka ‘void (*)(struct intrusive_node *, char *)’}

void apply(intrusive_list *list, void (*op)(intrusive_node *node, void *data), void *data);

~

src/main.c:39:14: warning: unused parameter ‘argc’ [-Wunused-parameter]

int main(int argc, char *argv[]) {


В main копипаста в разных ветках if

Чтение из файлов стоит вынести в отдельные функции

6.5/10

comment:2 Changed 4 years ago by Tarabonda German

Owner: changed from Tarabonda German to Дмитрий Свиридкин
Type: ожидаются исправленияожидается проверка
Version: 1.02.0

comment:3 Changed 4 years ago by Дмитрий Свиридкин

Resolution: задача сдана
Status: assignedclosed
  1. style = (char *)style; эта строчка ничего не делает
  1. Файл на запись вы всегда открываете как текствый
  1. {{{ if (f)

fclose(f); }}} Это, конечно, замечательно, но вы сначала в файл пишете / читаете, а потом уже проверяете, что он открылся.

  1. число аргументов командной строки надо бы проверять

8/10

Last edited 4 years ago by Дмитрий Свиридкин (previous) (diff)
Note: See TracTickets for help on using tickets.