-
Notifications
You must be signed in to change notification settings - Fork 711
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix compiling warnings on fedora40 #1515
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This patch addresses a compiler warning indicating that the 'prev' variable may be used uninitialized in the function dr_vports_table_del_wire. Although this warning is a false positive, it is important to resolve it to prevent potential confusion and maintain code quality. The 'while (vport)' loop is intended to start from the second element of the linked list, as the first element is already checked by a preceding condition. By initializing 'prev' to the first element and 'vport' to 'prev->next', we ensure that the loop logic remains correct and the warning is eliminated. This change does not alter the functionality of the code but enhances its clarity and robustness by ensuring all variables are properly initialized before use. Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
This commit fixes a compiler warning related to the use of calloc. ``` libibnetdisc/ibnetdisc_cache.c:560:36: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 560 | calloc(sizeof(*node->ports), node->numports + 1))) { | ^ libibnetdisc/ibnetdisc_cache.c:560:36: note: earlier argument should specify number of elements, later size of each element ``` The warning was due to transposed arguments in the calloc call, where the number of elements and the size of each element were specified in the wrong order. The correct order for calloc's arguments is: void *calloc(size_t nmemb, size_t size) Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
This commit fixes a compiler warning related to the use of calloc. ``` librdmacm/examples/cmtime.c:993:31: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 993 | nodes = calloc(sizeof *nodes, iter); | ^ librdmacm/examples/cmtime.c:993:31: note: earlier argument should specify number of elements, later size of each element ``` The warning was due to transposed arguments in the calloc call, where the number of elements and the size of each element were specified in the wrong order. The correct order for calloc's arguments is: void *calloc(size_t nmemb, size_t size) Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
This commit fixes a compiler warning related to the use of calloc. ``` rdma-core/build/pyverbs/providers/mlx5/mlx5dv.c: In function ‘__pyx_pf_7pyverbs_9providers_4mlx5_6mlx5dv_10WqeCtrlSeg___init__’: rdma-core/build/pyverbs/providers/mlx5/mlx5dv.c:48608:53: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 48608 | __pyx_v_self->__pyx_base.segment = calloc((sizeof(struct mlx5_wqe_ctrl_seg)), 1); | ^~~~~~ rdma-core/build/pyverbs/providers/mlx5/mlx5dv.c:48608:53: note: earlier argument should specify number of elements, later size of each element rdma-core/build/pyverbs/providers/mlx5/mlx5dv.c: In function ‘__pyx_pf_7pyverbs_9providers_4mlx5_6mlx5dv_10WqeDataSeg___init__’: rdma-core/build/pyverbs/providers/mlx5/mlx5dv.c:50301:53: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 50301 | __pyx_v_self->__pyx_base.segment = calloc((sizeof(struct mlx5_wqe_data_seg)), 1); | ^~~~~~ rdma-core/build/pyverbs/providers/mlx5/mlx5dv.c:50301:53: note: earlier argument should specify number of elements, later size of each element ``` The warning was due to transposed arguments in the calloc call, where the number of elements and the size of each element were specified in the wrong order. The correct order for calloc's arguments is: void *calloc(size_t nmemb, size_t size) Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
zhijianli88
changed the title
Fix compiling warnings
Fix compiling warnings on fedora40
Nov 13, 2024
zhijianli88
force-pushed
the
fix-warnings
branch
from
November 13, 2024 02:18
2b4973e
to
b78dae2
Compare
zhijianli88
commented
Nov 13, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's believed that there is something wrong/BUG in ccache
- let's open the compiling command with
make VERBOSE=1
cd /home/lizhijian/rdma-core/build/librdmacm && cc -DVERBS_DEBUG -Drspreload_EXPORTS -I/home/lizhijian/rdma-core/build/include -I/usr/include/libnl3 -I/usr/include/drm -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wmissing-prototypes -Wmissing-declarations -Wwrite-strings -Wformat=2 -Wcast-function-type -Wformat-nonliteral -Wdate-time -Wnested-externs -Wshadow -Wstrict-prototypes -Wold-style-definition -Wredundant-decls -O2 -g -DNDEBUG -std=gnu11 -fPIC -MD -MT librdmacm/CMakeFiles/rspreload.dir/preload.c.o -MF CMakeFiles/rspreload.dir/preload.c.o.d -o CMakeFiles/rspreload.dir/preload.c.o -c /home/lizhijian/rdma-core/librdmacm/preload.c
/home/lizhijian/rdma-core/librdmacm/preload.c:1175:5: warning: no previous prototype for ‘__fxstat’ [-Wmissing-prototypes]
1175 | int __fxstat(int ver, int socket, struct stat *buf)
| ^~~~~~~~
- check what is the default
cc
# whereis cc
cc: /usr/bin/cc /usr/lib64/ccache/cc
# which cc
/usr/lib64/ccache/cc
We can see, it's a built-in command of the ccache.
- change the cc to GCC version, it works well
cd /home/lizhijian/rdma-core/build/librdmacm && /usr/bin/cc -DVERBS_DEBUG -Drspreload_EXPORTS -I/home/lizhijian/rdma-core/build/include -I/usr/include/libnl3 -I/usr/include/drm -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wmissing-prototypes -Wmissing-declarations -Wwrite-strings -Wformat=2 -Wcast-function-type -Wformat-nonliteral -Wdate-time -Wnested-externs -Wshadow -Wstrict-prototypes -Wold-style-definition -Wredundant-decls -O2 -g -DNDEBUG -std=gnu11 -fPIC -MD -MT librdmacm/CMakeFiles/rspreload.dir/preload.c.o -MF CMakeFiles/rspreload.dir/preload.c.o.d -o CMakeFiles/rspreload.dir/preload.c.o -c /home/lizhijian/rdma-core/librdmacm/preload.c
<no warning>
- pre-complie the C to extend all the includes and macros, and then build it with
ccache cc
, it also works
# pre-complie
build/librdmacm# /usr/lib64/ccache/cc -DVERBS_DEBUG -Drspreload_EXPORTS -I/home/lizhijian/rdma-core/build/include -I/usr/include/libnl3 -I/usr/include/drm -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wmissing-prototypes -Wmissing-declarations -Wwrite-strings -Wformat=2 -Wcast-function-type -Wformat-nonliteral -Wdate-time -Wnested-externs -Wshadow -Wstrict-prototypes -Wold-style-definition -Wredundant-decls -O2 -g -DNDEBUG -std=gnu11 -fPIC -MD -MT librdmacm/CMakeFiles/rspreload.dir/preload.c.o -MF CMakeFiles/rspreload.dir/preload.c.o.d -c /home/lizhijian/rdma-core/librdmacm/preload.c -E -o preload.i
# compile to object file
build/librdmacm# /usr/lib64/ccache/cc -DVERBS_DEBUG -Drspreload_EXPORTS -I/home/lizhijian/rdma-core/build/include -I/usr/include/libnl3 -I/usr/include/drm -Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -Wmissing-prototypes -Wmissing-declarations -Wwrite-strings -Wformat=2 -Wcast-function-type -Wformat-nonliteral -Wdate-time -Wnested-externs -Wshadow -Wstrict-prototypes -Wold-style-definition -Wredundant-decls -O2 -g -DNDEBUG -std=gnu11 -fPIC -MD -MT librdmacm/CMakeFiles/rspreload.dir/preload.c.o -MF CMakeFiles/rspreload.dir/preload.c.o.d -c preload.i -o preload.i.o
So, it's believed that there is something wrong in the ccache cc
zhijianli88
force-pushed
the
fix-warnings
branch
from
November 14, 2024 05:46
b78dae2
to
78ddabe
Compare
Droped the fixing __fxstat patch because it's not rdma-core's problem. |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently, I updated my host to fedora40 and rebuilt the rdma-core. The compiler complained a few warnings.
gcc: gcc (GCC) 14.2.1 20240912 (Red Hat 14.2.1-3)
Thi PR intends to fix them.