Skip to contentSkip to conversation

ALSA: Remove redundant open helper return checks

PATCH Applied [email protected] 3 participants 10 messages Jul 2 – Jul 3 Sound

lore
Share & tools
lore
#0 lore raw

v2 cover ALSA: Remove redundant open helper return checks

From: bui duc phuc <[email protected]>

Hi all,

This series removes redundant error checks after calls to nonseekable_open() and stream_open() in the ALSA core.

nonseekable_open() always returns 0, so checking its return value is unnecessary.

Several users were later converted from nonseekable_open() to stream_open(), but the original error checks were retained. Since stream_open() also always returns 0, those checks are likewise unnecessary.

As a result, all patches simply remove dead error handling paths with no functional change.

Change in v2 :
- Drop the unnecessary assignment of the return value from nonseekable_open()/stream_open(), as suggested by Takashi.
- Merge the individual patches into a single patch series.

Best regards,
Phuc

bui duc phuc (7):
ALSA: control: Drop redundant stream_open() return check
ALSA: mixer: oss: Drop redundant nonseekable_open() return check
ALSA: pcm: oss: Drop redundant nonseekable_open() return check
ALSA: pcm: Drop redundant nonseekable_open() return check
ALSA: rawmidi: Drop redundant stream_open() return check
ALSA: seq: Drop redundant stream_open() return check
ALSA: timer: Drop redundant stream_open() return check

 sound/core/control.c           |  4 +---
 sound/core/oss/mixer_oss.c     |  4 +---
 sound/core/oss/pcm_oss.c       |  4 +---
 sound/core/pcm_native.c        | 14 ++++++++------
 sound/core/rawmidi.c           |  4 +---
 sound/core/seq/seq_clientmgr.c |  5 +----
 sound/core/timer.c             |  5 +----
 7 files changed, 14 insertions(+), 26 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/7 ALSA: control: Drop redundant stream_open() return check

From: bui duc phuc <[email protected]>

The previous conversion from nonseekable_open() to stream_open() retained the existing error check.
Since stream_open() always returns 0, remove the dead error handling path.

---
 sound/core/control.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/core/control.c +1 -3
index 7a8dc506221e..037e455bb11b 100644
@@ -55,9 +55,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
 	struct snd_ctl_file *ctl;
 	int i, err;
 
-	err = stream_open(inode, file);
-	if (err < 0)
-		return err;
+	stream_open(inode, file);
 
 	card = snd_lookup_minor_data(iminor(inode), SNDRV_DEVICE_TYPE_CONTROL);
 	if (!card) {
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/7 ALSA: mixer: oss: Drop redundant nonseekable_open() return check

In reply to [email protected]

From: bui duc phuc <[email protected]>

nonseekable_open() always returns 0, so the error check is unnecessary. Remove the dead error handling path.

---
 sound/core/oss/mixer_oss.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/core/oss/mixer_oss.c +1 -3
index 591cff800329..f5bcc7896542 100644
@@ -30,9 +30,7 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)
 	struct snd_mixer_oss_file *fmixer;
 	int err;
 
-	err = nonseekable_open(inode, file);
-	if (err < 0)
-		return err;
+	nonseekable_open(inode, file);
 
 	card = snd_lookup_oss_minor_data(iminor(inode),
 					 SNDRV_OSS_DEVICE_TYPE_MIXER);
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/7 ALSA: pcm: oss: Drop redundant nonseekable_open() return check

In reply to [email protected]

From: bui duc phuc <[email protected]>

nonseekable_open() always returns 0, so the error check is unnecessary. Remove the dead error handling path.

---
 sound/core/oss/pcm_oss.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/core/oss/pcm_oss.c +1 -3
index 9826d9a0be6d..0d7818eb3e14 100644
@@ -2495,9 +2495,7 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)
 	int nonblock;
 	wait_queue_entry_t wait;
 
-	err = nonseekable_open(inode, file);
-	if (err < 0)
-		return err;
+	nonseekable_open(inode, file);
 
 	pcm = snd_lookup_oss_minor_data(iminor(inode),
 					SNDRV_OSS_DEVICE_TYPE_PCM);
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 4/7 ALSA: pcm: Drop redundant nonseekable_open() return check

In reply to [email protected]

From: bui duc phuc <[email protected]>

nonseekable_open() always returns 0, so the error check is unnecessary. Remove the dead error handling path.

---
 sound/core/pcm_native.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
sound/core/pcm_native.c +8 -6
index 7dc0060617f1..7032f329e827 100644
@@ -2873,9 +2873,10 @@ static int snd_pcm_open_file(struct file *file,
 static int snd_pcm_playback_open(struct inode *inode, struct file *file)
 {
 	struct snd_pcm *pcm;
-	int err = nonseekable_open(inode, file);
-	if (err < 0)
-		return err;
+	int err;
+
+	nonseekable_open(inode, file);
+
 	pcm = snd_lookup_minor_data(iminor(inode),
 				    SNDRV_DEVICE_TYPE_PCM_PLAYBACK);
 	err = snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK);
@@ -2887,9 +2888,10 @@ static int snd_pcm_playback_open(struct inode *inode, struct file *file)
 static int snd_pcm_capture_open(struct inode *inode, struct file *file)
 {
 	struct snd_pcm *pcm;
-	int err = nonseekable_open(inode, file);
-	if (err < 0)
-		return err;
+	int err;
+
+	nonseekable_open(inode, file);
+
 	pcm = snd_lookup_minor_data(iminor(inode),
 				    SNDRV_DEVICE_TYPE_PCM_CAPTURE);
 	err = snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE);
Signature · 1 line
2.43.0
#5 lore raw

PATCH v2 5/7 ALSA: rawmidi: Drop redundant stream_open() return check

In reply to [email protected]

From: bui duc phuc <[email protected]>

The previous conversion from nonseekable_open() to stream_open() retained the existing error check.
Since stream_open() always returns 0, remove the dead error handling path.

---
 sound/core/rawmidi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/core/rawmidi.c +1 -3
index 4dfd9d53e6d3..789254a88e53 100644
@@ -441,9 +441,7 @@ static int snd_rawmidi_open(struct inode *inode, struct file *file)
 	if ((file->f_flags & O_APPEND) && !(file->f_flags & O_NONBLOCK))
 		return -EINVAL;		/* invalid combination */
 
-	err = stream_open(inode, file);
-	if (err < 0)
-		return err;
+	stream_open(inode, file);
 
 	if (maj == snd_major) {
 		rmidi = snd_lookup_minor_data(iminor(inode),
Signature · 1 line
2.43.0
#6 lore raw

PATCH v2 6/7 ALSA: seq: Drop redundant stream_open() return check

In reply to [email protected]

From: bui duc phuc <[email protected]>

The previous conversion from nonseekable_open() to stream_open() retained the existing error check.
Since stream_open() always returns 0, remove the dead error handling path.

---
 sound/core/seq/seq_clientmgr.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
sound/core/seq/seq_clientmgr.c +1 -4
index 28782e1776fa..8fe872367568 100644
@@ -296,11 +296,8 @@ static int snd_seq_open(struct inode *inode, struct file *file)
 	int c, mode;			/* client id */
 	struct snd_seq_client *client;
 	struct snd_seq_user_client *user;
-	int err;
 
-	err = stream_open(inode, file);
-	if (err < 0)
-		return err;
+	stream_open(inode, file);
 
 	scoped_guard(mutex, &register_mutex) {
 		client = seq_create_client1(-1, SNDRV_SEQ_DEFAULT_EVENTS);
Signature · 1 line
2.43.0
#7 lore raw

PATCH v2 7/7 ALSA: timer: Drop redundant stream_open() return check

In reply to [email protected]

From: bui duc phuc <[email protected]>

The previous conversion from nonseekable_open() to stream_open() retained the existing error check.
Since stream_open() always returns 0, remove the dead error handling path.

---
 sound/core/timer.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
sound/core/timer.c +1 -4
index 51c6ac4df9f4..937d7996f7ab 100644
@@ -1531,11 +1531,8 @@ static int realloc_user_queue(struct snd_timer_user *tu, int size)
 static int snd_timer_user_open(struct inode *inode, struct file *file)
 {
 	struct snd_timer_user *tu;
-	int err;
 
-	err = stream_open(inode, file);
-	if (err < 0)
-		return err;
+	stream_open(inode, file);
 
 	tu = kzalloc_obj(*tu);
 	if (tu == NULL)
Signature · 1 line
2.43.0
Reviewed-by on the v2 series
#8 lore raw
In reply to [email protected]
Quoted 15 lines · On 7/2/2026 10:44 AM, [email protected] wrote:

From: bui duc phuc <[email protected]>

Hi all,

This series removes redundant error checks after calls to nonseekable_open() and stream_open() in the ALSA core.

nonseekable_open() always returns 0, so checking its return value is unnecessary.

Several users were later converted from nonseekable_open() to stream_open(), but the original error checks were retained. Since stream_open() also always returns 0, those checks are likewise unnecessary.

Quoted 7 lines

As a result, all patches simply remove dead error handling paths with no functional change.

Change in v2 :
- Drop the unnecessary assignment of the return value from nonseekable_open()/stream_open(), as suggested by Takashi.
- Merge the individual patches into a single patch series.

Hi Phuc,

Now I released you've sent v2 within few hours of sending v1. The comments I've provided for v1 are already addressed in v2 so:

Kinds regards,
Czarek

Applied
#9 lore raw
In reply to [email protected]
Quoted 27 lines · On Thu, 02 Jul 2026 10:44:37 +0200, [email protected] wrote:

From: bui duc phuc <[email protected]>

Hi all,

This series removes redundant error checks after calls to nonseekable_open() and stream_open() in the ALSA core.

nonseekable_open() always returns 0, so checking its return value is unnecessary.

Several users were later converted from nonseekable_open() to stream_open(), but the original error checks were retained. Since stream_open() also always returns 0, those checks are likewise unnecessary.

As a result, all patches simply remove dead error handling paths with no functional change.

Change in v2 :
- Drop the unnecessary assignment of the return value from nonseekable_open()/stream_open(), as suggested by Takashi.
- Merge the individual patches into a single patch series.

Best regards,
Phuc

Quoted 8 lines

bui duc phuc (7):
ALSA: control: Drop redundant stream_open() return check
ALSA: mixer: oss: Drop redundant nonseekable_open() return check
ALSA: pcm: oss: Drop redundant nonseekable_open() return check
ALSA: pcm: Drop redundant nonseekable_open() return check
ALSA: rawmidi: Drop redundant stream_open() return check
ALSA: seq: Drop redundant stream_open() return check
ALSA: timer: Drop redundant stream_open() return check

Applied all patches to for-next branch now. Thanks.

Takashi