On Tue, Mar 12, 2024 at 10:22:06PM +0800, 李书畅 wrote: > Hello Dan, please ignore my previous two e-mails, which are summarized in this one. The current situation is as follows: > I went directly into the NtyCo subdirectory NtyCo/core, changed the gcc to cgcc in the makefile and ran: > > sudo make > > the output (sparse show me the warnings) : > > /home/lsc20011130/smatch/cgcc -c nty_epoll.c -o /nty_epoll.o > /home/lsc20011130/smatch/cgcc -c nty_coroutine.c -o /nty_coroutine.o > nty_coroutine.c:258:6: warning: symbol 'nty_coroutine_renice' was not declared. Should it be static? > nty_coroutine.c:279:6: warning: symbol 'nty_coroutine_detach' was not declared. Should it be static? > /home/lsc20011130/smatch/cgcc -c nty_socket.c -o /nty_socket.o > nty_socket.c:421:9: error: symbol 'recvfrom' redeclared with different type (originally declared at /usr/include/sys/socket.h:163) - incompatible argument 5 (different base types) > nty_socket.c:504:9: error: symbol 'sendto' redeclared with different type (originally declared at /usr/include/sys/socket.h:152) - incompatible argument 5 (different base types) > nty_socket.c:529:5: error: symbol 'accept' redeclared with different type (originally declared at /usr/include/sys/socket.h:232) - incompatible argument 2 (different base types) > nty_socket.c:579:5: error: symbol 'connect' redeclared with different type (originally declared at /usr/include/sys/socket.h:126) - incompatible argument 2 (different base types) > /home/lsc20011130/smatch/cgcc -c nty_schedule.c -o /nty_schedule.o > nty_schedule.c:82:1: warning: symbol '_nty_coroutine_rbtree_sleep_RB_INSERT_COLOR' was not declared. Should it be static? > nty_schedule.c:82:1: warning: symbol '_nty_coroutine_rbtree_sleep_RB_REMOVE_COLOR' was not declared. Should it be static? > nty_schedule.c:82:1: warning: symbol '_nty_coroutine_rbtree_sleep_RB_REMOVE' was not declared. Should it be static? > nty_schedule.c:82:1: warning: symbol '_nty_coroutine_rbtree_sleep_RB_INSERT' was not declared. Should it be static? > nty_schedule.c:82:1: warning: symbol '_nty_coroutine_rbtree_sleep_RB_FIND' was not declared. Should it be static? > nty_schedule.c:82:1: warning: symbol '_nty_coroutine_rbtree_sleep_RB_NFIND' was not declared. Should it be static? > nty_schedule.c:82:1: warning: symbol '_nty_coroutine_rbtree_sleep_RB_NEXT' was not declared. Should it be static? > nty_schedule.c:82:1: warning: symbol '_nty_coroutine_rbtree_sleep_RB_PREV' was not declared. Should it be static? > nty_schedule.c:82:1: warning: symbol '_nty_coroutine_rbtree_sleep_RB_MINMAX' was not declared. Should it be static? > nty_schedule.c:83:1: warning: symbol '_nty_coroutine_rbtree_wait_RB_INSERT_COLOR' was not declared. Should it be static? > nty_schedule.c:83:1: warning: symbol '_nty_coroutine_rbtree_wait_RB_REMOVE_COLOR' was not declared. Should it be static? > nty_schedule.c:83:1: warning: symbol '_nty_coroutine_rbtree_wait_RB_REMOVE' was not declared. Should it be static? > nty_schedule.c:83:1: warning: symbol '_nty_coroutine_rbtree_wait_RB_INSERT' was not declared. Should it be static? > nty_schedule.c:83:1: warning: symbol '_nty_coroutine_rbtree_wait_RB_FIND' was not declared. Should it be static? > nty_schedule.c:83:1: warning: symbol '_nty_coroutine_rbtree_wait_RB_NFIND' was not declared. Should it be static? > nty_schedule.c:83:1: warning: symbol '_nty_coroutine_rbtree_wait_RB_NEXT' was not declared. Should it be static? > nty_schedule.c:83:1: warning: symbol '_nty_coroutine_rbtree_wait_RB_PREV' was not declared. Should it be static? > nty_schedule.c:83:1: warning: symbol '_nty_coroutine_rbtree_wait_RB_MINMAX' was not declared. Should it be static? > nty_schedule.c:122:34: warning: missing braces around initializer > nty_schedule.c:121:15: warning: symbol 'nty_schedule_search_wait' was not declared. Should it be static? > nty_schedule.c:135:34: warning: missing braces around initializer > nty_schedule.c:181:6: warning: symbol 'nty_schedule_cancel_wait' was not declared. Should it be static? > nty_schedule.c:185:6: warning: symbol 'nty_schedule_free' was not declared. Should it be static? > nty_schedule.c:201:5: warning: symbol 'nty_schedule_create' was not declared. Should it be static? > > but if I run : > sudo make CHECK="/home/lsc20011130/smatch/smatch --info", instead of sudo make > the output (all the waring disappear): > > /home/lsc20011130/smatch/cgcc -c nty_epoll.c -o /nty_epoll.o > /home/lsc20011130/smatch/cgcc -c nty_coroutine.c -o /nty_coroutine.o > /home/lsc20011130/smatch/cgcc -c nty_socket.c -o /nty_socket.o > /home/lsc20011130/smatch/cgcc -c nty_schedule.c -o /nty_schedule.o > > I would like to know if this is normal? I'm not familiar with static > analysis, so forgive me if I ask some simple and silly questions. > Feel free to ask questions. In this case, what you're seeing is not normal at all. If the cgcc script is able to run sparse then it's able to run smatch. The --info option should produce output for every function so it should definitely produce output here. The only thing I can think of is that maybe it's because smatch outputs to stdout and sparse outputs to stderr? What about if you pass --file-output to smatch? CHECK="/home/lsc20011130/smatch/smatch --info --file-output" That should create a bunch of files that end in foo.c.smatch, foo.c.smatch.sql and foo.c.smatch.caller_info regards, dan carpenter