1. 15 Feb, 2024 1 commit
  2. 13 Feb, 2024 3 commits
    • Takashi Iwai's avatar
      ALSA: seq: fix function cast warnings · d7bf7380
      Takashi Iwai authored
      clang-16 points out a control flow integrity (kcfi) issue when event
      callbacks get converted to incompatible types:
      
      sound/core/seq/seq_midi.c:135:30: error: cast from 'int (*)(struct snd_rawmidi_substream *, const char *, int)' to 'snd_seq_dump_func_t' (aka 'int (*)(void *, void *, int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
        135 |                 snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)dump_midi, substream);
            |                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      sound/core/seq/seq_virmidi.c:83:31: error: cast from 'int (*)(struct snd_rawmidi_substream *, const unsigned char *, int)' to 'snd_seq_dump_func_t' (aka 'int (*)(void *, void *, int)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
         83 |                         snd_seq_dump_var_event(ev, (snd_seq_dump_func_t)snd_rawmidi_receive, vmidi->substream);
            |                                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      For addressing those errors, introduce wrapper functions that are used
      for callbacks and bridge to the actual function call with pointer
      cast.
      
      The code was originally added with the initial ALSA merge in linux-2.5.4.
      
      [ the patch description shamelessly copied from Arnd's original patch
        -- tiwai ]
      
      Fixes: 1da177e4 ("Linux-2.6.12-rc2")
      Reported-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20240213101020.459183-1-arnd@kernel.org
      Link: https://lore.kernel.org/r/20240213135343.16411-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      d7bf7380
    • Arnd Bergmann's avatar
      ALSA: aw2: avoid casting function pointers · 022a13a1
      Arnd Bergmann authored
      clang-16 started warning about incompatible function pointers here:
      
      sound/pci/aw2/aw2-alsa.c:363:11: error: cast from 'void (*)(struct snd_pcm_substream *)' to 'snd_aw2_saa7146_it_cb' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
        363 |                                                     (snd_aw2_saa7146_it_cb)
            |                                                     ^~~~~~~~~~~~~~~~~~~~~~~
        364 |                                                     snd_pcm_period_elapsed,
            |                                                     ~~~~~~~~~~~~~~~~~~~~~~
      sound/pci/aw2/aw2-alsa.c:392:10: error: cast from 'void (*)(struct snd_pcm_substream *)' to 'snd_aw2_saa7146_it_cb' (aka 'void (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
        392 |                                                    (snd_aw2_saa7146_it_cb)
            |                                                    ^~~~~~~~~~~~~~~~~~~~~~~
        393 |                                                    snd_pcm_period_elapsed,
            |                                                    ~~~~~~~~~~~~~~~~~~~~~~
      
      Add a forward declaration for struct snd_pcm_substrea to allow it to just
      use the correct prototype.
      
      Fixes: 98f2a97f ("[ALSA] Emagic Audiowerk 2 ALSA driver.")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20240213101327.460191-1-arnd@kernel.orgSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      022a13a1
    • Arnd Bergmann's avatar
      ALSA: ctxfi: avoid casting function pointers · aabdedf4
      Arnd Bergmann authored
      This driver creates an abstraction for different components by casting function
      pointers to slightly incompatible types for each one to get the correct
      argument even when the caller does not know those types. This is a
      bit unreliable and not allowed in combination with control flow integrity
      (KCFI):
      
      sound/pci/ctxfi/ctatc.c:115:25: error: cast from 'int (*)(struct hw *, struct src_mgr **)' to 'create_t' (aka 'int (*)(struct hw *, void **)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
        115 |         [SRC]           = { .create     = (create_t)src_mgr_create,
            |                                           ^~~~~~~~~~~~~~~~~~~~~~~~
      sound/pci/ctxfi/ctatc.c:116:20: error: cast from 'int (*)(struct src_mgr *)' to 'destroy_t' (aka 'int (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
        116 |                             .destroy    = (destroy_t)src_mgr_destroy    },
            |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~
      sound/pci/ctxfi/ctatc.c:117:27: error: cast from 'int (*)(struct hw *, struct srcimp_mgr **)' to 'create_t' (aka 'int (*)(struct hw *, void **)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
        117 |         [SRCIMP]        = { .create     = (create_t)srcimp_mgr_create,
            |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      sound/pci/ctxfi/ctatc.c:118:20: error: cast from 'int (*)(struct srcimp_mgr *)' to 'destroy_t' (aka 'int (*)(void *)') converts to incompatible function type [-Werror,-Wcast-function-type-strict]
        118 |                             .destroy    = (destroy_t)srcimp_mgr_destroy },
            |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Change these to always pass void pointers and move the abstraction one level
      down.
      
      Fixes: 8cc72361 ("ALSA: SB X-Fi driver merge")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20240213101303.460008-1-arnd@kernel.orgSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      aabdedf4
  3. 12 Feb, 2024 29 commits
  4. 09 Feb, 2024 3 commits
  5. 04 Feb, 2024 1 commit
  6. 02 Feb, 2024 1 commit
  7. 30 Jan, 2024 2 commits
    • Takashi Iwai's avatar
      Merge branch 'topic/format-kunit' into for-next · 8b87a786
      Takashi Iwai authored
      Pull ALSA core kunit test.
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      8b87a786
    • Ivan Orlov's avatar
      ALSA: core: Add sound core KUnit test · 3e39acf5
      Ivan Orlov authored
      At the moment, we have a decent amount of integration tests (selftests)
      covering different aspects of the sound subsystem. However, a lot of
      of sound-related in-kernel functions remains uncovered. This patch
      introduces the KUnit test for the core part of the sound subsystem.
      It includes 10 test cases:
      
      - Coverage of the format-related inline functions from 'pcm.h' header
      file: snd_pcm_format_physical_width, snd_pcm_format_width,
      snd_pcm_format_signed, test_format_endianness
      
      - Coverage of the available bytes counting functions from 'pcm.h'
      header: snd_pcm_capture_avail, snd_pcm_playback_avail
      
      - Coverage of functions from pcm_misc: snd_pcm_format_set_silence,
      snd_pcm_format_name
      
      - Coverage of card-related functions from init.c: snd_card_set_id,
      snd_component_add
      
      This patch depends on the previous patches in this patch series as they
      contain fix for the bug, which was found during the test development.
      Without them, the test doesn't pass.
      Signed-off-by: default avatarIvan Orlov <ivan.orlov0322@gmail.com>
      Link: https://lore.kernel.org/r/20240125223522.1122765-3-ivan.orlov0322@gmail.comSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      3e39acf5