Skip to content

Commit

Permalink
Lint includes with IWYU during code scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Jan 16, 2023
1 parent 8d2c94d commit 45e8fd8
Show file tree
Hide file tree
Showing 62 changed files with 342 additions and 220 deletions.
34 changes: 34 additions & 0 deletions .github/iwyu.imp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[

{ include: [ '<bits/getopt_core.h>', private, '<getopt.h>', public ] },
{ include: [ '<bsd/libutil.h>', private, '<bsd/stdlib.h>', public ] },
{ include: [ '<bsd/sys/time.h>', private, '<sys/time.h>', public ] },
{ symbol: [ 'sig_atomic_t', private, '<signal.h>', public ] },

{ include: [ '<alsa/conf.h>', private, '<alsa/asoundlib.h>', public ] },
{ include: [ '<alsa/control.h>', private, '<alsa/asoundlib.h>', public ] },
{ include: [ '<alsa/error.h>', private, '<alsa/asoundlib.h>', public ] },
{ include: [ '<alsa/global.h>', private, '<alsa/asoundlib.h>', public ] },
{ include: [ '<alsa/input.h>', private, '<alsa/asoundlib.h>', public ] },
{ include: [ '<alsa/mixer.h>', private, '<alsa/asoundlib.h>', public ] },
{ include: [ '<alsa/output.h>', private, '<alsa/asoundlib.h>', public ] },
{ include: [ '<alsa/pcm.h>', private, '<alsa/asoundlib.h>', public ] },
{ include: [ '<alsa/pcm_ioplug.h>', private, '<alsa/pcm_external.h>', public ] },
{ include: [ '<alsa/version.h>', private, '<alsa/asoundlib.h>', public ] },

{ include: [ '"dbus/dbus-memory.h"', private, '<dbus/dbus.h>', public ] },
{ include: [ '"dbus/dbus-protocol.h"', private, '<dbus/dbus.h>', public ] },
{ include: [ '"dbus/dbus-shared.h"', private, '<dbus/dbus.h>', public ] },

{ include: [ '<fdk-aac/FDK_audio.h>', private, '<fdk-aac/aacenc_lib.h>', public ] },

{ include: [ '<glib/gtypes.h>', private, '<glib.h>', public ] },
{ include: [ '"gio/gdbusinterfaceskeleton.h"', private, '<gio/gio.h>', public ] },
{ include: [ '"gio/gdbusobjectmanagerserver.h"', private, '<gio/gio.h>', public ] },
{ include: [ '"gio/gdbusobjectskeleton.h"', private, '<gio/gio.h>', public ] },

{ include: [ '<fmt123.h>', private, '<mpg123.h>', public ] },

{ include: [ '<spandsp/plc.h>', private, '<spandsp.h>', public ] },

]
2 changes: 2 additions & 0 deletions .github/spellcheck-wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ ATRAC
BlueALSA
BlueZ
Fraunhofer
IWYU
LDAC
MPD
oFono
Expand All @@ -83,6 +84,7 @@ mutex
natively
param
params
pragma
proc
reinitialization
scalable
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/code-scanning.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,63 @@ jobs:
ignorePaths: ${{ github.workspace }}/doc/bluealsa-api.txt
scanPaths: ${{ github.workspace }}

include-what-you-use:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Install Dependencies
run: |
sudo apt update
# XXX: iwyu package depends on clang-14, but is built with clang-13
sudo apt install --yes --quiet --no-install-recommends \
bear \
iwyu libclang-13-dev \
libasound2-dev \
libbluetooth-dev \
libbsd-dev \
libdbus-1-dev \
libfdk-aac-dev \
libglib2.0-dev \
libmp3lame-dev \
libmpg123-dev \
libncurses5-dev \
libreadline-dev \
libsbc-dev \
libspandsp-dev
- uses: actions/checkout@v3
- name: Create Build Environment
run: |
mkdir -p ${{ github.workspace }}/{build,m4}
autoreconf --install
- name: Configure GNU Automake
working-directory: ${{ github.workspace }}/build
run: |
${{ github.workspace }}/configure \
--enable-aac \
--enable-debug \
--enable-debug-time \
--enable-faststream \
--enable-mp3lame \
--enable-mpg123 \
--enable-msbc \
--enable-ofono \
--enable-upower \
--enable-aplay \
--enable-cli \
--enable-rfcomm \
--enable-a2dpconf \
--enable-hcitop
- name: Build
working-directory: ${{ github.workspace }}/build
run: bear -- make check TESTS=
- name: Run IWYU Check
run: |
iwyu_tool -p ${{ github.workspace }}/build -- \
-Xiwyu --mapping_file=${{ github.workspace }}/.github/iwyu.imp \
-Xiwyu --keep=*/config.h \
-Xiwyu --no_fwd_decls
markdown-lint:
strategy:
fail-fast: false
Expand Down
5 changes: 0 additions & 5 deletions src/a2dp-aac.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

#include "a2dp-aac.h"

#if ENABLE_AAC

#include <errno.h>
#include <endian.h>
#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>
Expand Down Expand Up @@ -591,5 +588,3 @@ int a2dp_aac_transport_start(struct ba_transport *t) {
g_assert_not_reached();
return -1;
}

#endif
7 changes: 1 addition & 6 deletions src/a2dp-aptx-hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@
*/

#include "a2dp-aptx-hd.h"
/* IWYU pragma: no_include "config.h" */

#if ENABLE_APTX_HD

#include <endian.h>
#include <errno.h>
#include <pthread.h>
#include <stdbool.h>
Expand All @@ -27,7 +25,6 @@
#include "codec-aptx.h"
#include "io.h"
#include "rtp.h"
#include "utils.h"
#include "shared/a2dp-codecs.h"
#include "shared/defs.h"
#include "shared/ffb.h"
Expand Down Expand Up @@ -347,5 +344,3 @@ int a2dp_aptx_hd_transport_start(struct ba_transport *t) {
g_assert_not_reached();
return -1;
}

#endif
6 changes: 1 addition & 5 deletions src/a2dp-aptx.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
*/

#include "a2dp-aptx.h"

#if ENABLE_APTX
/* IWYU pragma: no_include "config.h" */

#include <errno.h>
#include <pthread.h>
Expand All @@ -25,7 +24,6 @@
#include "a2dp.h"
#include "codec-aptx.h"
#include "io.h"
#include "utils.h"
#include "shared/a2dp-codecs.h"
#include "shared/defs.h"
#include "shared/ffb.h"
Expand Down Expand Up @@ -309,5 +307,3 @@ int a2dp_aptx_transport_start(struct ba_transport *t) {
g_assert_not_reached();
return -1;
}

#endif
5 changes: 0 additions & 5 deletions src/a2dp-faststream.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "a2dp-faststream.h"

#if ENABLE_FASTSTREAM

#include <errno.h>
#include <pthread.h>
#include <stdbool.h>
Expand All @@ -27,7 +25,6 @@
#include "a2dp.h"
#include "codec-sbc.h"
#include "io.h"
#include "utils.h"
#include "shared/a2dp-codecs.h"
#include "shared/defs.h"
#include "shared/ffb.h"
Expand Down Expand Up @@ -335,5 +332,3 @@ int a2dp_faststream_transport_start(struct ba_transport *t) {
g_assert_not_reached();
return -1;
}

#endif
8 changes: 2 additions & 6 deletions src/a2dp-lc3plus.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
*/

#include "a2dp-lc3plus.h"
/* IWYU pragma: no_include "config.h" */

#if ENABLE_LC3PLUS

#include <endian.h>
#include <errno.h>
#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

Expand All @@ -28,7 +27,6 @@
#include "a2dp.h"
#include "audio.h"
#include "bluealsa-config.h"
#include "codec-sbc.h"
#include "io.h"
#include "rtp.h"
#include "utils.h"
Expand Down Expand Up @@ -609,5 +607,3 @@ int a2dp_lc3plus_transport_start(struct ba_transport *t) {
g_assert_not_reached();
return -1;
}

#endif
5 changes: 0 additions & 5 deletions src/a2dp-ldac.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@

#include "a2dp-ldac.h"

#if ENABLE_LDAC

#include <errno.h>
#include <endian.h>
#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>
Expand Down Expand Up @@ -408,5 +405,3 @@ int a2dp_ldac_transport_start(struct ba_transport *t) {
g_assert_not_reached();
return -1;
}

#endif
6 changes: 1 addition & 5 deletions src/a2dp-mpeg.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@
*/

#include "a2dp-mpeg.h"

#if ENABLE_MPEG
/* IWYU pragma: no_include "config.h" */

#include <errno.h>
#include <endian.h>
#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>
Expand Down Expand Up @@ -614,5 +612,3 @@ int a2dp_mpeg_transport_start(struct ba_transport *t) {
g_assert_not_reached();
return -1;
}

#endif
3 changes: 1 addition & 2 deletions src/a2dp-sbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
*/

#include "a2dp-sbc.h"
/* IWYU pragma: no_include "config.h" */

#include <endian.h>
#include <errno.h>
#include <pthread.h>
#include <stdbool.h>
Expand All @@ -28,7 +28,6 @@
#include "codec-sbc.h"
#include "io.h"
#include "rtp.h"
#include "utils.h"
#include "shared/a2dp-codecs.h"
#include "shared/defs.h"
#include "shared/ffb.h"
Expand Down
30 changes: 22 additions & 8 deletions src/a2dp.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

#include "a2dp.h"
/* IWYU pragma: no_include "config.h" */

#include <errno.h>
#include <limits.h>
Expand All @@ -18,19 +19,32 @@

#include <glib.h>

#include "a2dp-aac.h"
#include "a2dp-aptx-hd.h"
#include "a2dp-aptx.h"
#include "a2dp-faststream.h"
#include "a2dp-lc3plus.h"
#include "a2dp-ldac.h"
#include "a2dp-mpeg.h"
#if ENABLE_AAC
# include "a2dp-aac.h"
#endif
#if ENABLE_APTX
# include "a2dp-aptx.h"
#endif
#if ENABLE_APTX_HD
# include "a2dp-aptx-hd.h"
#endif
#if ENABLE_FASTSTREAM
# include "a2dp-faststream.h"
#endif
#if ENABLE_LC3PLUS
# include "a2dp-lc3plus.h"
#endif
#if ENABLE_LDAC
# include "a2dp-ldac.h"
#endif
#if ENABLE_MPEG
# include "a2dp-mpeg.h"
#endif
#include "a2dp-sbc.h"
#include "bluealsa-config.h"
#include "codec-sbc.h"
#include "hci.h"
#include "shared/a2dp-codecs.h"
#include "shared/defs.h"
#include "shared/log.h"

struct a2dp_codec * const a2dp_codecs[] = {
Expand Down
3 changes: 2 additions & 1 deletion src/asound/bluealsa-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# include <config.h>
#endif

#include <alloca.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
Expand All @@ -26,7 +27,7 @@
#include <strings.h>
#include <sys/eventfd.h>
#include <sys/ioctl.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>

#include <alsa/asoundlib.h>
Expand Down
2 changes: 1 addition & 1 deletion src/ba-adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
*/

#include "ba-adapter.h"
/* IWYU pragma: no_include "config.h" */

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>

Expand Down
3 changes: 2 additions & 1 deletion src/ba-adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
# include <config.h>
#endif

#include <stdint.h>
#include <pthread.h>

#include <glib.h>

#include <bluetooth/bluetooth.h>
#include <bluetooth/bluetooth.h> /* IWYU pragma: keep */
#include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h>

Expand Down
Loading

0 comments on commit 45e8fd8

Please sign in to comment.