mirror of
https://github.com/sysprog21/lkmpg.git
synced 2025-02-23 07:47:58 +08:00

Smatch[1][2] is a pluggable static analysis for C. It may help us find out the potential problem of the example code. Doing with smatch, if set the --file-output flag, it will generate the {}.c.smatch report for each c file. This will make a little bit complicated to collect all the report messages. So, here we stay at the default setting, stdout for the smatch messages. For more information, see: - https://lwn.net/Articles/696624/ - https://elinux.org/images/d/d3/Bargmann.pdf Also, fix the warning from Smatch: Smatch failed: 1 warning(s), 1 error(s) lkmpg/examples/procfs2.c:57 procfile_write() error: buffer overflow 'procfs_buffer' 1024 <= 1024 lkmpg/examples/kbleds.c:58 kbleds_init() warn: argument 5 to %lx specifier is cast from pointer Furthermore, the effect of the write operation in procfs2.c is too implied. So after writing, print the buffer every time. Close #122 [1] https://github.com/error27/smatch [2] https://repo.or.cz/w/smatch.git