Skip to content

Commit

Permalink
test/unit/nvme: Fix dummy_cb signature
Browse files Browse the repository at this point in the history
As per typedef in nvme.h the spdk_nvme_cpl argument should be a
pointer to a const struct.

This fixes runtimer error under clang >= 17.x which now makes the
-fsanitize=function available for C and which on our end is being
enabled via -fsanitize=undefined under UBSAN.

Error in question:

 Test: test_spdk_nvme_detach ...passed
  Test: test_nvme_completion_poll_cb ...passed
  Test: test_nvme_user_copy_cmd_complete
.../root/spdk/lib/nvme/nvme.c:417:2: runtime error: call to function
dummy_cb through pointer to incorrect function type 'void (*)(void *,
const struct spdk_nvme_cpl *)'
/root/spdk/test/unit/lib/nvme/nvme.c/nvme_ut.c:584: note: dummy_cb
defined here
    #0 0x5098e0 in nvme_user_copy_cmd_complete
       /root/spdk/lib/nvme/nvme.c:417:2
    #1 0x532161 in test_nvme_user_copy_cmd_complete
       /root/spdk/test/unit/lib/nvme/nvme.c/nvme_ut.c:604:2
    #2 0x7f08c952266a  (/usr/lib64/libcunit.so.1+0x466a) (BuildId:
       d99e3b60795f2ce01ada820b4b7e3cd84d8150fe)
    #3 0x7f08c95229c7  (/usr/lib64/libcunit.so.1+0x49c7) (BuildId:
       d99e3b60795f2ce01ada820b4b7e3cd84d8150fe)
    #4 0x7f08c9523a9f in CU_run_all_tests
       (/usr/lib64/libcunit.so.1+0x5a9f) (BuildId:
d99e3b60795f2ce01ada820b4b7e3cd84d8150fe)
    #5 0x55555e in run_tests /root/spdk/lib/ut/ut.c:169:3
    #6 0x552aec in spdk_ut_run_tests /root/spdk/lib/ut/ut.c:225:8
    #7 0x522d52 in main
       /root/spdk/test/unit/lib/nvme/nvme.c/nvme_ut.c:1664:17
    #8 0x7f08c8c28149 in __libc_start_call_main
       (/usr/lib64/libc.so.6+0x28149) (BuildId:
7ea8d85df0e89b90c63ac7ed2b3578b2e7728756)
    #9 0x7f08c8c2820a in __libc_start_main@GLIBC_2.2.5
       (/usr/lib64/libc.so.6+0x2820a) (BuildId:
7ea8d85df0e89b90c63ac7ed2b3578b2e7728756)
    #10 0x42b6a4 in _start
	(/root/spdk/test/unit/lib/nvme/nvme.c/nvme_ut+0x42b6a4)
(BuildId: 6fc2caaf777030becad2d0f660ec68443f3380b4)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
/root/spdk/lib/nvme/nvme.c:417:2 in
./test/unit/unittest.sh: line 85: 75349 Aborted                 (core
dumped) $valgrind $testdir/lib/nvme/nvme.c/nvme_ut

Change-Id: Iddbd5fc0dee0ef6a6cc1f032e079f6119e76aed9
Signed-off-by: Michal Berger <[email protected]>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22025
Reviewed-by: Jim Harris <[email protected]>
Community-CI: Mellanox Build Bot
Reviewed-by: Konrad Sztyber <[email protected]>
Tested-by: SPDK CI Jenkins <[email protected]>
  • Loading branch information
mikeBashStuff authored and jimharris committed Feb 26, 2024
1 parent 8ad06ee commit b1cb736
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/unit/lib/nvme/nvme.c/nvme_ut.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ test_nvme_completion_poll_cb(void)
/* stub callback used by test_nvme_user_copy_cmd_complete() */
static struct spdk_nvme_cpl ut_spdk_nvme_cpl = {0};
static void
dummy_cb(void *user_cb_arg, struct spdk_nvme_cpl *cpl)
dummy_cb(void *user_cb_arg, const struct spdk_nvme_cpl *cpl)
{
ut_spdk_nvme_cpl = *cpl;
}
Expand Down

0 comments on commit b1cb736

Please sign in to comment.