From: Kalle Valo <kvalo@kernel.org>
To: Jeff Johnson <quic_jjohnson@quicinc.com>
Cc: Karthikeyan Periyasamy <quic_periyasa@quicinc.com>,
<ath12k@lists.infradead.org>, <linux-wireless@vger.kernel.org>
Subject: Re: [PATCH v2 4/4] wifi: ath12k: Refactor data path cmem init
Date: Mon, 22 Apr 2024 15:04:47 +0300 [thread overview]
Message-ID: <87y195vc0w.fsf@kernel.org> (raw)
In-Reply-To: <823fe8a6-1e6c-49e9-a225-2012e77093ac@quicinc.com> (Jeff Johnson's message of "Thu, 11 Apr 2024 08:20:38 -0700")
Jeff Johnson <quic_jjohnson@quicinc.com> writes:
>>>> + default:
>>>> + ath12k_err(ab, "invalid descriptor type %d in cmem init\n", type);
>>>> + return;
>>>> + }
>>>> +
>>>> + /* Write to PPT in CMEM */
>>>> + for (i = start; i < end; i++)
>>>> + ath12k_hif_write32(ab, cmem_base + ATH12K_PPT_ADDR_OFFSET(i),
>>>> + dp->spt_info[i].paddr >> ATH12K_SPT_4K_ALIGN_OFFSET);
>>>> +}
>>>
>>> Here's a good example why I don't like functions returning void. How do
>>> we handle the errors in this case?
>>>
>>
>> sure, will handle the error case in the caller.
>>
>
> this is a static function with one caller. the only error is the default case
> which will never be hit. adding logic to return an error and then check it in
> the caller seems like overkill. why not just WARN() in the default case since
> this would be a logic error with newly added code?
I think the software will be more robust then all errors are properly
handled in a uniform way. For example, will everyone notice the warning
message? What if the function is extended later and then the person
doesn't add any error handling "because it didn't have that even
earlier"? It's also a lot easier to review if error handling follows the
same style throughout the driver.
I didn't do any measurements but the overhead from this shouldn't be
that large, maybe few bytes in the binary and few new lines in the
source code. I think that's a reasonable price to pay from having more
robust software.
This is why I want to avoid void functions as much as possible. Of
course there also are good cases when to use void functions, like here:
https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/ath.git/commit/?h=ath-next&id=6ef5b4c9598c928b3e2c4c4b543c81331941f136
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
next prev parent reply other threads:[~2024-04-22 12:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 15:14 [PATCH v2 0/4] wifi: ath12k: Refactor hardware cookie conversion Karthikeyan Periyasamy
2024-04-09 15:14 ` [PATCH v2 1/4] wifi: ath12k: avoid redundant code in Rx cookie conversion init Karthikeyan Periyasamy
2024-04-09 15:14 ` [PATCH v2 2/4] wifi: ath12k: Refactor the hardware " Karthikeyan Periyasamy
2024-04-09 15:14 ` [PATCH v2 3/4] wifi: ath12k: displace the Tx and Rx descriptor in cookie conversion table Karthikeyan Periyasamy
2024-04-09 15:14 ` [PATCH v2 4/4] wifi: ath12k: Refactor data path cmem init Karthikeyan Periyasamy
2024-04-11 9:45 ` Kalle Valo
2024-04-11 10:07 ` Karthikeyan Periyasamy
2024-04-11 15:20 ` Jeff Johnson
2024-04-22 12:04 ` Kalle Valo [this message]
2024-04-22 16:09 ` Jeff Johnson
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=87y195vc0w.fsf@kernel.org \
--to=kvalo@kernel.org \
--cc=ath12k@lists.infradead.org \
--cc=linux-wireless@vger.kernel.org \
--cc=quic_jjohnson@quicinc.com \
--cc=quic_periyasa@quicinc.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