Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Ingyu Jang <ingyujang25@korea.ac.kr>
Cc: linux-sound@vger.kernel.org, perex@perex.cz, tiwai@suse.com
Subject: Re: [Question] Dead code in ALSA drivers - functions always returning 0?
Date: Mon, 02 Feb 2026 17:43:41 +0100	[thread overview]
Message-ID: <87jywvyu2q.wl-tiwai@suse.de> (raw)
In-Reply-To: <20260131081431.2920839-1-ingyujang25@korea.ac.kr>

On Sat, 31 Jan 2026 09:14:31 +0100,
Ingyu Jang wrote:
> 
> Hi,
> 
> I noticed several ALSA driver functions that always return 0, but their
> return values are still checked by callers. I wanted to ask whether
> these are intentional defensive coding or could be cleaned up.
> 
> 1. sound/isa/cs423x/cs4236.c - snd_cs423x_pnp_init_mpu()
>    This function handles pnp_activate_dev() failure internally by
>    setting mpu_port[dev] = SNDRV_AUTO_PORT, then always returns 0.
>    The caller checks "< 0" which can never be true.
> 
> 2. sound/pci/ice1712/ice1712.c - snd_ice1712_chip_init()
>    Always returns 0. Callers check "< 0" in snd_ice1712_create()
>    and the PM resume path.
> 
> 3. sound/pci/ice1712/ice1724.c - snd_vt1724_chip_init()
>    Always returns 0. Similar pattern to ice1712.
> 
> 4. sound/pci/vx222/vx222_ops.c - put_xilinx_data()
>    Always returns 0. Caller vx2_load_xilinx_binary() checks "< 0".
> 
> Are these intentional for potential future error handling, or could
> the return value checks be removed?

Those are for potential error handling that may be added in future.
But, given that those are all pretty old code, the chance of
extensions should be very low.  OTOH, all those are static local
functions and the compiler should reduce things appropriately.

So, if any, we may clean them up, but the gain would be very small,
likely negligible.


thanks,

Takashi

      reply	other threads:[~2026-02-02 16:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-31  8:14 [Question] Dead code in ALSA drivers - functions always returning 0? Ingyu Jang
2026-02-02 16:43 ` Takashi Iwai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87jywvyu2q.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=ingyujang25@korea.ac.kr \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox