ALSA: oss: Drop redundant nonseekable_open() return check
PATCH 1/1 ALSA: oss: Drop redundant nonseekable_open() return check
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 | 2 -- sound/core/oss/pcm_oss.c | 2 -- 2 files changed, 4 deletions(-)
sound/core/oss/mixer_oss.c +0 -2
@@ -31,8 +31,6 @@ static int snd_mixer_oss_open(struct inode *inode, struct file *file)int err; err =nonseekable_open (inode, file); -if (err <0 ) -return err; card =snd_lookup_oss_minor_data (iminor (inode),SNDRV_OSS_DEVICE_TYPE_MIXER );
sound/core/oss/pcm_oss.c +0 -2
@@ -2496,8 +2496,6 @@ static int snd_pcm_oss_open(struct inode *inode, struct file *file)wait_queue_entry_t wait; err =nonseekable_open (inode, file); -if (err <0 ) -return err; pcm =snd_lookup_oss_minor_data (iminor (inode),SNDRV_OSS_DEVICE_TYPE_PCM );
Signature · 1 line
2.43.0
Quoted 4 lines · On Thu, Jul 02, 2026 at 12:02:36PM +0700, [email protected] wrote:
From: bui duc phuc <[email protected]>
nonseekable_open()always returns 0, so the error check is unnecessary. Remove the dead error handling path.
The idea is that it might return errors in the future.
Also the patch is kind of sloppy...
regards,
dan carpenter
Quoted 8 lines · Dan Carpenter
Quoted 4 lines · On Thu, Jul 02, 2026 at 12:02:36PM +0700, [email protected] wrote:
From: bui duc phuc <[email protected]>
nonseekable_open()always returns 0, so the error check is unnecessary. Remove the dead error handling path.The idea is that it might return errors in the future.
Actually the comments on nonseekable_open() say there is no need to check. That would have been useful information to add in the commit message...
Quoted 1 line
Also the patch is kind of sloppy...
The sloppiness was fixed in v2. It's weird that there were no review comments on lore for this patch. Are people sending private reviews now?
regards,
dan carpenter
Hi Dan Carpenter,
Thank you for your feedback.
Quoted 3 lines
Quoted 3 lines
The idea is that it might return errors in the future.
I looked at the history of nonseekable_open(). It has existed since Linux 2.6 days, for over 20 years, and its behavior has remained unchanged. The comment still explicitly states:
"The function is not supposed to ever fail..."
It also explains that the function returns int only so that it can be plugged directly into file_operations, not because callers are expected to handle errors.
I also checked the current kernel tree. nonseekable_open() is referenced from 86 files,
and the overwhelming majority of callers ignore its return value entirely, following the
documented API contract. Only three callers checked the return value:
+ GPIO (already applied):
https://lore.kernel.org/all/[email protected]/
+ DRM:
https://lore.kernel.org/all/[email protected]/
+ASoC:
https://lore.kernel.org/all/[email protected]/
If nonseekable_open() were ever changed to return real errors, that would change its
long-established API contract and would affect a large number of existing callers.
Such a change would require updating those callers across the kernel, rather than
relying on a few isolated defensive checks.
Given its documented semantics, its unchanged behavior for over two decades, and how it is actually used throughout the kernel, I don't think keeping redundant
error handling here provides any practical benefit.
Quoted 6 lines
Quoted 2 lines
Also the patch is kind of sloppy...
The sloppiness was fixed in v2. It's weird that there were no review comments on lore for this patch. Are people sending private reviews now?
I was reading through the code and creating patches at the same time, so I submitted cleanups as I found them. That made the earlier patches somewhat inconsistent.
After Takashi-san reviewed one of the patches, I applied the same improvements to the rest of the series and sent them in v2.
There were no private reviews. The feedback was entirely public:
https://lore.kernel.org/all/[email protected]/
Best regards,
Phuc