linuxdeepin / open-source-students

8 stars 5 forks source link

音乐(deepin-music)解决cppcheck等代码静态检查出的问题 #8

Closed myml closed 2 years ago

myml commented 2 years ago

项目地址 https://github.com/linuxdeepin/deepin-music

Zongyin-Hao commented 2 years ago

尝试cppcheck, 参数为cppcheck --project=compile_commands.json --library=qt.cfg > cppcheck.txt 2>&1, 检测到7个error, 分别是:

1. [/home/hzy/hzy/projects/deepin/deepin-music/Build/src/libdmusic/dmusic_autogen/EWIEGA46WW/moc_ffmpegdynamicinstance.cpp:14]: (error) #error "The header file 'ffmpegdynamicinstance.h' doesn't include <QObject>."
2. [/home/hzy/hzy/projects/deepin/deepin-music/Build/src/music-player/deepin-music_autogen/TAC5DWH4SE/moc_medialibrary.cpp:14]: (error) #error "The header file 'medialibrary.h' doesn't include <QObject>."
3. [/usr/include/vlc/plugins/vlc_common.h:514]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
4. [/usr/include/vlc/plugins/vlc_arrays.h:509]: (error) Memory leak: ppsz_ret
5. [/usr/include/vlc/plugins/vlc_arrays.h:347]: (error) Common realloc mistake: 'pp' nulled but not freed upon failure
6. [/usr/include/vlc/plugins/vlc_block.h:336]: (error) Address of local auto-variable assigned to a function parameter.
7. [/home/hzy/hzy/projects/deepin/deepin-music/Build/src/libmusic-plugin/music-plugin_autogen/XBG7L5Z4V6/moc_service.cpp:14]: (error) #error "The header file 'service.h' doesn't include <QObject>."

其中1, 2, 7可能是误报, 3,4,5,6是/usr/include下的问题, 不是源码层面的error. 是否需要修复待确认

myml commented 2 years ago

尝试cppcheck, 参数为cppcheck --project=compile_commands.json --library=qt.cfg > cppcheck.txt 2>&1, 检测到7个error, 分别是:

1. [/home/hzy/hzy/projects/deepin/deepin-music/Build/src/libdmusic/dmusic_autogen/EWIEGA46WW/moc_ffmpegdynamicinstance.cpp:14]: (error) #error "The header file 'ffmpegdynamicinstance.h' doesn't include <QObject>."
2. [/home/hzy/hzy/projects/deepin/deepin-music/Build/src/music-player/deepin-music_autogen/TAC5DWH4SE/moc_medialibrary.cpp:14]: (error) #error "The header file 'medialibrary.h' doesn't include <QObject>."
3. [/usr/include/vlc/plugins/vlc_common.h:514]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
4. [/usr/include/vlc/plugins/vlc_arrays.h:509]: (error) Memory leak: ppsz_ret
5. [/usr/include/vlc/plugins/vlc_arrays.h:347]: (error) Common realloc mistake: 'pp' nulled but not freed upon failure
6. [/usr/include/vlc/plugins/vlc_block.h:336]: (error) Address of local auto-variable assigned to a function parameter.
7. [/home/hzy/hzy/projects/deepin/deepin-music/Build/src/libmusic-plugin/music-plugin_autogen/XBG7L5Z4V6/moc_service.cpp:14]: (error) #error "The header file 'service.h' doesn't include <QObject>."

其中1, 2, 7可能是误报, 3,4,5,6是/usr/include下的问题, 不是源码层面的error. 是否需要修复待确认

Build目录下的不需要处理,include 也先不处理吧,可以再选一个项目。 感兴趣的话可以在实习之后向vlc提pr

Zongyin-Hao commented 2 years ago

好的. 我又试了一下自己注入的简单错误cppcheck是能检测出来的, 应该不是配置有问题. 后面我试试其他项目, 另外也会找几个路径敏感的静态分析工具试试.