Opened 5 years ago

Closed 5 years ago

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

WW #3

Reported by: vorobeva.aleksandra Owned by: Артур Гулецкий (huletski)
Component: WW_intrusive_list Version: 2.0
Keywords: Cc:

Description

Пока ничего не работает

Change History (4)

comment:1 Changed 5 years ago by Артур Гулецкий (huletski)

Type: ожидается проверкаожидаются исправления

Решение не собирается:

{lab_03}[2194]$ pwd && svn up && svn status
/home/hfx/dvl/cpp19/vorobeva.aleksandra/lab_03
Updating '.':
At revision 1247.
{lab_03}[2195]$ make
mkdir obj
gcc -c -Wall -Wextra -Werror -fsanitize=address -Iinclude -c src/main.c -o obj/main.o
src/main.c: In function ‘remove_point’:
src/main.c:5:41: error: initialization of ‘struct intrusive_node *’ from incompatible pointer type ‘struct point *’ [-Werror=incompatible-pointer-types]
    5 | #define container_of(ptr, type, member) (type*)((char*)(ptr) - offsetof(type, member))
      |                                         ^
src/main.c:23:33: note: in expansion of macro ‘container_of’
   23 |   struct intrusive_node *item = container_of(list->head->prev, struct point, node);
      |                                 ^~~~~~~~~~~~
src/main.c:24:12: error: ‘struct intrusive_node’ has no member named ‘x’
   24 |   if ((item->x) == x && (item->y) == y){
      |            ^~
src/main.c:24:30: error: ‘struct intrusive_node’ has no member named ‘y’
   24 |   if ((item->x) == x && (item->y) == y){
      |                              ^~
src/main.c: In function ‘show_all_points’:
src/main.c:5:41: error: initialization of ‘struct intrusive_node *’ from incompatible pointer type ‘struct point *’ [-Werror=incompatible-pointer-types]
    5 | #define container_of(ptr, type, member) (type*)((char*)(ptr) - offsetof(type, member))
      |                                         ^
src/main.c:36:33: note: in expansion of macro ‘container_of’
   36 |   struct intrusive_node *item = container_of(list->head->prev, struct point, node);
      |                                 ^~~~~~~~~~~~
src/main.c:37:26: error: ‘struct intrusive_node’ has no member named ‘x’
   37 |   printf("(%d %d) ", item->x, item->y);
      |                          ^~
src/main.c:37:35: error: ‘struct intrusive_node’ has no member named ‘y’
   37 |   printf("(%d %d) ", item->x, item->y);
      |                                   ^~
src/main.c: In function ‘remove_all_points’:
src/main.c:5:41: error: initialization of ‘struct intrusive_node *’ from incompatible pointer type ‘struct point *’ [-Werror=incompatible-pointer-types]
    5 | #define container_of(ptr, type, member) (type*)((char*)(ptr) - offsetof(type, member))
      |                                         ^
src/main.c:44:33: note: in expansion of macro ‘container_of’
   44 |   struct intrusive_node *item = container_of(list->head->prev, struct point, node);
      |                                 ^~~~~~~~~~~~
src/main.c:44:26: error: unused variable ‘item’ [-Werror=unused-variable]
   44 |   struct intrusive_node *item = container_of(list->head->prev, struct point, node);
      |                          ^~~~
cc1: all warnings being treated as errors
Makefile:9: recipe for target 'obj/main.o' failed
make: *** [obj/main.o] Error 1

Кроме того, я не увидел код обработки команд (e.g. add, len и т.п.). Отступы в коде тоже надо привести к одному стилю.

comment:2 Changed 5 years ago by vorobeva.aleksandra

Version: 1.02.0

comment:3 Changed 5 years ago by vorobeva.aleksandra

Type: ожидаются исправленияожидается проверка

comment:4 Changed 5 years ago by Артур Гулецкий (huletski)

Resolution: задача сдана
Status: assignedclosed

Решение не собирается:

{lab_03}[2454]$ pwd && svn status && svn up
/home/hfx/dvl/cpp19/vorobeva.aleksandra/lab_03
Updating '.':
At revision 1327.
{lab_03}[2455]$ make
mkdir obj
gcc -std=c11 -Wall -Wextra -Werror -fsanitize=address -g -Iinclude -c src/main.c -o obj/main.o
src/main.c: In function ‘add_point’:
src/main.c:16:13: error: ‘point_’ is used uninitialized in this function [-Werror=uninitialized]
   16 |  *ptr_point = point_;
      |  ~~~~~~~~~~~^~~~~~~~
cc1: all warnings being treated as errors
Makefile:9: recipe for target 'obj/main.o' failed
make: *** [obj/main.o] Error 1

Замечания:

  • решение не собирается -> -1.5; инструкция копирования неинициализированной переменной на стеке в неинициализированную память лишняя (да и смысла в ней нет) -> -1;
  • решение реализовать список так, чтобы следующий элемент можно было получить, используя node->prev, конечно, оригинально, но принято, все же, организовывать список так, чтобы _следующий_ элемент можно было получить по node->next;
  • функция remove_node содержит ошибку (последний элемент может не удаляться) (вашу логику реализации быстро я не понял, просто переписал функцию для того, чтобы починить проблему) -> -1;
  • в некоторых местах не соблюдается единый стиль отступов (например, main.c:40) -> -0.5;
  • main.c:61. Считывать команду надо, используя ограничение на максимально число считываемых символов "%9s");
  • main.c:26. Скобки вокруг item->x избыточны и затрудняют чтение кода.

Итог: 8/12.

Note: See TracTickets for help on using tickets.