Add additional C flags to your build (improving your code)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Tái cấu trúc
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- c
- Lĩnh vực
- build-system
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện đầu ra cảnh báo với các cờ trình biên dịch được liệt kê, sau đó xem xét các ví dụ trong lib/commonmarker/src/buffer.c, cmark-gfm.h, chunk.h, blocks.c và lib/whereami/whereami.c. Kiểm tra toàn bộ đầu ra của bản build để xác định các cảnh báo còn lại và quyết định cảnh báo nào phù hợp để sửa. Được xem là hoàn tất khi các cảnh báo liên quan đã được xử lý và dự án vẫn build và test thành công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Try to build with the following C flags and improve your code:
-Wall -Wextra -Wconversion -Wcast-align -Wstrict-prototypes -Wuninitialized -Wshadow -Wformat=2 -Werror=incompatible-pointer-types
You will get some nice warnings, function declarations isnt' a prototype, unused-parameters and quite a lot of sign-conversion warnings.
Maybe it's worth looking into those warnings! Those are there for a reason... Those warnings can now be spotted and fixed, improving your code quality.
Small snippet from the output (NOT the full output):
[build] ../lib/commonmarker/src/buffer.c:161:39: note: in expansion of macro ‘MIN’
[build] 161 | int result = memcmp(a->ptr, b->ptr, MIN(a->size, b->size));
[build] | ^~~
[build] ../lib/commonmarker/src/buffer.c: In function ‘cmark_strbuf_strchr’:
[build] ../lib/commonmarker/src/buffer.c:173:60: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘bufsize_t’ {aka ‘int’} may change the sign of the result [-Wsign-conversion]
[build] 173 | (unsigned char *)memchr(buf->ptr + pos, c, buf->size - pos);
[build] | ~~~~~~~~~~^~~~~
[build] ../lib/commonmarker/src/buffer.c: In function ‘cmark_strbuf_drop’:
[build] ../lib/commonmarker/src/buffer.c:211:42: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘bufsize_t’ {aka ‘int’} may change the sign of the result [-Wsign-conversion]
[build] 211 | memmove(buf->ptr, buf->ptr + n, buf->size);
[build] | ~~~^~~~~~
[build] ../lib/commonmarker/src/buffer.c: In function ‘cmark_strbuf_rtrim’:
[build] ../lib/commonmarker/src/buffer.c:222:32: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 222 | if (!cmark_isspace(buf->ptr[buf->size - 1]))
[build] | ~~~~~~~~^~~~~~~~~~~~~~~
[build] ../lib/commonmarker/src/buffer.c: In function ‘cmark_strbuf_trim’:
[build] ../lib/commonmarker/src/buffer.c:237:49: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 237 | while (i < buf->size && cmark_isspace(buf->ptr[i]))
[build] | ~~~~~~~~^~~
[build] ../lib/commonmarker/src/buffer.c: In function ‘cmark_strbuf_normalize_whitespace’:
[build] ../lib/commonmarker/src/buffer.c:252:29: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 252 | if (cmark_isspace(s->ptr[r])) {
[build] | ~~~~~~^~~
[build] ../lib/commonmarker/src/buffer.c: In function ‘cmark_strbuf_unescape’:
[build] ../lib/commonmarker/src/buffer.c:271:54: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 271 | if (buf->ptr[r] == '\\' && cmark_ispunct(buf->ptr[r + 1]))
[build] | ~~~~~~~~^~~~~~~
[build] [41/58 58% :: 0.717] Building C object lib/whereami/CMakeFiles/whereami.dir/whereami.c.o
[build] ../lib/whereami/whereami.c: In function ‘wai_getExecutablePath’:
[build] ../lib/whereami/whereami.c:204:29: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
[build] 204 | memcpy(out, resolved, length);
[build] | ^~~~~~
[build] ../lib/whereami/whereami.c: In function ‘wai_getModulePath’:
[build] ../lib/whereami/whereami.c:329:35: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
[build] 329 | memcpy(out, resolved, length);
[build] | ^~~~~~
[build] [42/58 60% :: 0.731] Building C object lib/commonmarker/src/CMakeFiles/LibCommonMarker.dir/references.c.o
[build] In file included from ../lib/commonmarker/src/references.c:1:
[build] ../lib/commonmarker/src/cmark-gfm.h:114:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
[build] 114 | cmark_mem *cmark_get_default_mem_allocator();
[build] | ^~~~~~~~~
[build] ../lib/commonmarker/src/cmark-gfm.h:120:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
[build] 120 | cmark_mem *cmark_get_arena_mem_allocator();
[build] | ^~~~~~~~~
[build] In file included from ../lib/commonmarker/src/map.h:4,
[build] from ../lib/commonmarker/src/references.h:4,
[build] from ../lib/commonmarker/src/parser.h:5,
[build] from ../lib/commonmarker/src/references.c:2:
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_ltrim’:
[build] ../lib/commonmarker/src/chunk.h:32:41: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 32 | while (c->len && cmark_isspace(c->data[0])) {
[build] | ~~~~~~~^~~
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_rtrim’:
[build] ../lib/commonmarker/src/chunk.h:42:31: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 42 | if (!cmark_isspace(c->data[c->len - 1]))
[build] | ~~~~~~~^~~~~~~~~~~~
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_strchr’:
[build] ../lib/commonmarker/src/chunk.h:57:61: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘bufsize_t’ {aka ‘int’} may change the sign of the result [-Wsign-conversion]
[build] 57 | (unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
[build] | ~~~~~~~~^~~~~~~~
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_to_cstr’:
[build] ../lib/commonmarker/src/chunk.h:68:45: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
[build] 68 | str = (unsigned char *)mem->calloc(c->len + 1, 1);
[build] | ~~~~~~~^~~
[build] ../lib/commonmarker/src/chunk.h:70:27: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘bufsize_t’ {aka ‘int’} may change the sign of the result [-Wsign-conversion]
[build] 70 | memcpy(str, c->data, c->len);
[build] | ~^~~~~
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_set_cstr’:
[build] ../lib/commonmarker/src/chunk.h:88:51: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
[build] 88 | c->data = (unsigned char *)mem->calloc(c->len + 1, 1);
[build] | ~~~~~~~^~~
[build] ../lib/commonmarker/src/chunk.h:90:33: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
[build] 90 | memcpy(c->data, str, c->len + 1);
[build] | ~~~~~~~^~~
[build] [42/58 62% :: 0.770] Linking C static library lib/whereami/libwhereami.a
[build] [42/58 63% :: 0.884] Building C object lib/commonmarker/src/CMakeFiles/LibCommonMarker.dir/blocks.c.o
[build] In file included from ../lib/commonmarker/src/syntax_extension.h:4,
[build] from ../lib/commonmarker/src/blocks.c:13:
[build] ../lib/commonmarker/src/cmark-gfm.h:114:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
[build] 114 | cmark_mem *cmark_get_default_mem_allocator();
[build] | ^~~~~~~~~
[build] ../lib/commonmarker/src/cmark-gfm.h:120:1: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
[build] 120 | cmark_mem *cmark_get_arena_mem_allocator();
[build] | ^~~~~~~~~
[build] In file included from ../lib/commonmarker/src/map.h:4,
[build] from ../lib/commonmarker/src/references.h:4,
[build] from ../lib/commonmarker/src/parser.h:5,
[build] from ../lib/commonmarker/src/blocks.c:15:
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_ltrim’:
[build] ../lib/commonmarker/src/chunk.h:32:41: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 32 | while (c->len && cmark_isspace(c->data[0])) {
[build] | ~~~~~~~^~~
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_rtrim’:
[build] ../lib/commonmarker/src/chunk.h:42:31: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 42 | if (!cmark_isspace(c->data[c->len - 1]))
[build] | ~~~~~~~^~~~~~~~~~~~
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_strchr’:
[build] ../lib/commonmarker/src/chunk.h:57:61: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘bufsize_t’ {aka ‘int’} may change the sign of the result [-Wsign-conversion]
[build] 57 | (unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
[build] | ~~~~~~~~^~~~~~~~
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_to_cstr’:
[build] ../lib/commonmarker/src/chunk.h:68:45: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
[build] 68 | str = (unsigned char *)mem->calloc(c->len + 1, 1);
[build] | ~~~~~~~^~~
[build] ../lib/commonmarker/src/chunk.h:70:27: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘bufsize_t’ {aka ‘int’} may change the sign of the result [-Wsign-conversion]
[build] 70 | memcpy(str, c->data, c->len);
[build] | ~^~~~~
[build] ../lib/commonmarker/src/chunk.h: In function ‘cmark_chunk_set_cstr’:
[build] ../lib/commonmarker/src/chunk.h:88:51: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
[build] 88 | c->data = (unsigned char *)mem->calloc(c->len + 1, 1);
[build] | ~~~~~~~^~~
[build] ../lib/commonmarker/src/chunk.h:90:33: warning: conversion to ‘size_t’ {aka ‘long unsigned int’} from ‘int’ may change the sign of the result [-Wsign-conversion]
[build] 90 | memcpy(c->data, str, c->len + 1);
[build] | ~~~~~~~^~~
[build] ../lib/commonmarker/src/blocks.c: In function ‘S_set_last_line_blank’:
[build] ../lib/commonmarker/src/blocks.c:51:20: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
[build] 51 | node->flags &= ~CMARK_NODE__LAST_LINE_BLANK;
[build] | ^
[build] ../lib/commonmarker/src/blocks.c: In function ‘remove_trailing_blank_lines’:
[build] ../lib/commonmarker/src/blocks.c:221:54: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 221 | if (c != ' ' && c != '\t' && !S_is_line_end_char(c))
[build] | ^
[build] ../lib/commonmarker/src/blocks.c:233:29: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 233 | if (!S_is_line_end_char(c))
[build] | ^
[build] ../lib/commonmarker/src/blocks.c: In function ‘finalize’:
[build] ../lib/commonmarker/src/blocks.c:284:15: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
[build] 284 | b->flags &= ~CMARK_NODE__OPEN;
[build] | ^
[build] ../lib/commonmarker/src/blocks.c:324:49: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 324 | if (S_is_line_end_char(node_content->ptr[pos]))
[build] | ~~~~~~~~~~~~~~~~~^~~~~
[build] ../lib/commonmarker/src/blocks.c: In function ‘parse_list_marker’:
[build] ../lib/commonmarker/src/blocks.c:33:32: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 33 | #define peek_at(i, n) (i)->data[n]
[build] | ~~~~~~~~~^~~
[build] ../lib/commonmarker/src/blocks.c:555:24: note: in expansion of macro ‘peek_at’
[build] 555 | if (!cmark_isspace(peek_at(input, pos))) {
[build] | ^~~~~~~
[build] ../lib/commonmarker/src/blocks.c:33:32: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 33 | #define peek_at(i, n) (i)->data[n]
[build] | ~~~~~~~~~^~~
[build] ../lib/commonmarker/src/blocks.c:562:32: note: in expansion of macro ‘peek_at’
[build] 562 | while (S_is_space_or_tab(peek_at(input, i))) {
[build] | ^~~~~~~
[build] ../lib/commonmarker/src/blocks.c:577:28: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 577 | } else if (cmark_isdigit(c)) {
[build] | ^
[build] ../lib/commonmarker/src/blocks.c:33:32: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 33 | #define peek_at(i, n) (i)->data[n]
[build] | ~~~~~~~~~^~~
[build] ../lib/commonmarker/src/blocks.c:588:42: note: in expansion of macro ‘peek_at’
[build] 588 | } while (digits < 9 && cmark_isdigit(peek_at(input, pos)));
[build] | ^~~~~~~
[build] ../lib/commonmarker/src/blocks.c:33:32: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 33 | #define peek_at(i, n) (i)->data[n]
[build] | ~~~~~~~~~^~~
[build] ../lib/commonmarker/src/blocks.c:596:26: note: in expansion of macro ‘peek_at’
[build] 596 | if (!cmark_isspace(peek_at(input, pos))) {
[build] | ^~~~~~~
[build] ../lib/commonmarker/src/blocks.c:33:32: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 33 | #define peek_at(i, n) (i)->data[n]
[build] | ~~~~~~~~~^~~
[build] ../lib/commonmarker/src/blocks.c:602:34: note: in expansion of macro ‘peek_at’
[build] 602 | while (S_is_space_or_tab(peek_at(input, i))) {
[build] | ^~~~~~~
[build] ../lib/commonmarker/src/blocks.c:33:32: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 33 | #define peek_at(i, n) (i)->data[n]
[build] | ~~~~~~~~~^~~
[build] ../lib/commonmarker/src/blocks.c:605:32: note: in expansion of macro ‘peek_at’
[build] 605 | if (S_is_line_end_char(peek_at(input, i))) {
[build] | ^~~~~~~
[build] ../lib/commonmarker/src/blocks.c: In function ‘S_parser_feed’:
[build] ../lib/commonmarker/src/blocks.c:711:30: warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result [-Wsign-conversion]
[build] 711 | if (S_is_line_end_char(*eol)) {
- Ngôn ngữ chính
- C
- Star
- 2k
- Fork
- 698
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của commonmark/cmark
-
Incorrect `parser->offset` advancement for closing fenced code blocks in `parse_code_block_prefix`Có thể đã có người làm @cpruijsen đã nhận 24 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
commonmark/cmark#590 · 3 bình luận ·
-
API documentation is missing an explanation of CMARK_NODE_CUSTOM_BLOCK and CMARK_NODE_CUSTOM_INLINEĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
commonmark/cmark#441 · 2 bình luận ·
-
Inline code languageĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
commonmark/cmark#626 · 4 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
commonmark/cmark#624 ·
-
Single-space blank line evicts a list-item continuationCó thể đã có người làm @afonsojanu đã nhận 34 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
commonmark/cmark#618 ·
Tất cả issue của commonmark/cmark
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
EchoTools/nevr-runtime#264 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[sqlcipher] update to 4.19.0Đang mởcategory:port-update
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
mypaint/libmypaint#209 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[LOGO] Keenetic OSCó thể đã có người làm @Ivan-Alone đã nhận hôm nay. Đang mởlogo request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fastfetch-cli/fastfetch#2646 ·
Maintainer thường phản hồi trong vòng 1 ngày