public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Ethan Carter Edwards <ethan@ethancedwards.com>
Cc: "wychay@ctl.creative.com" <wychay@ctl.creative.com>,
	"ryan_richards@creativelabs.com" <ryan_richards@creativelabs.com>,
	"tiwai@suse.de" <tiwai@suse.de>,
	"linux-sound@vger.kernel.org" <linux-sound@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: sound/pci/ctxfi/ctdaio.c: duplicate function removal question
Date: Sun, 29 Dec 2024 09:02:28 +0000	[thread overview]
Message-ID: <20241229090228.75f8a3ba@dsl-u17-10> (raw)
In-Reply-To: <NyKCr2VHK_xCQDwNxFKKx2LVd2d_AC2f2j4eAvnD9uRPtb50i2AruCLOp6mHxsGiyYJ0Tgd3Z50Oy1JTi5gPhjd2WQM2skrv7asp3fLl8HU=@ethancedwards.com>

On Tue, 24 Dec 2024 23:16:17 +0000
Ethan Carter Edwards <ethan@ethancedwards.com> wrote:

> Hello all,
> 
> First of all, happy holidays. 
> 
> I was browsing the ctdaio.c code and I noticed a lot of 
> duplicate code and functions, specifically:
> 
> dao_set_{right,left}_input and
> dao_clear_{right,left}_input functions.
> 
> The functions are pretty much identical. They only 
> differ in the side (left, right). What was the original
> idea in doing this? Wouldn't it make more since to just
> have an ENUM (left, right) as an argument that would 
> determine the side and just reduce the function to 
> dao_set_input and dao_clear_input.

Hmmm... you'd have a lot of conditionals inside the function.

They also look like a memory leak just waiting to happen.
I guess that an earlier implementation used a separate kmalloc()
for each imappers[].

Why is imappers[] an array of pointers not an array of the items?
Each is just 8 bytes plus a 'list_head' (2 pointers?).

	David

> 
> I would be more than happy to send in a patch doing
> these changes, but before I did I wanted to ask if
> there was a reason the code was written in this way.
> I am pretty new to kernel development.
> 
> Thanks,
> Ethan
> --
> Ethan Carter Edwards
> CompTIA A+, Security+, and ISC2 (CC)
> Ham Radio: AE4CE
> Website: https://ethancedwards.com
> 
> 


  parent reply	other threads:[~2024-12-29  9:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-24 23:16 sound/pci/ctxfi/ctdaio.c: duplicate function removal question Ethan Carter Edwards
2024-12-29  8:32 ` Takashi Iwai
2024-12-29  9:02 ` David Laight [this message]
2024-12-29  9:10   ` Takashi Iwai
2024-12-29 10:57     ` David Laight
2024-12-29 12:03       ` Takashi Iwai
2024-12-29 13:34         ` David Laight
2024-12-30 15:53           ` Ethan Carter Edwards

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=20241229090228.75f8a3ba@dsl-u17-10 \
    --to=david.laight.linux@gmail.com \
    --cc=ethan@ethancedwards.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=ryan_richards@creativelabs.com \
    --cc=tiwai@suse.de \
    --cc=wychay@ctl.creative.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