From: Jeff Johnson <jeff.johnson@oss.qualcomm.com>
To: Kalle Valo <kvalo@kernel.org>,
Roopni Devanathan <quic_rdevanat@quicinc.com>
Cc: ath12k@lists.infradead.org, linux-wireless@vger.kernel.org,
Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>
Subject: Re: [PATCH 2/2] wifi: ath12k: Support Transmit Buffer OFDMA Stats
Date: Tue, 7 Jan 2025 15:38:32 -0800 [thread overview]
Message-ID: <c776b5ee-0e25-4d21-be21-dd318ae33d1e@oss.qualcomm.com> (raw)
In-Reply-To: <87jzb6flwz.fsf@kernel.org>
On 1/7/2025 11:45 AM, Kalle Valo wrote:
> Roopni Devanathan <quic_rdevanat@quicinc.com> writes:
>> From: Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com>
>> + len--;
>> + *(buf + len) = '\0';
>
> Please avoid pointer arithmetic, this is simpler:
>
> buf[len] = '\0';
>
> Or should it be just 0 instead of '\0'? Don't know which one is
> preferred.
>
well my take on this is we have a lot of similar pointer arithmetic already in
this and other debugfs files, including all of the scnprintf(buf + len, ...)
calls which could be scnprintf(&buf[len], ...). And we have existing instances
of trailing comma suppression in:
print_array_to_buf_index()
ath12k_htt_print_txbf_ofdma_ax_ndpa_stats_tlv()
ath12k_htt_print_txbf_ofdma_ax_ndp_stats_tlv()
and others, all of which assign '\0'
so this code looks ok to me.
that said, while i've been reviewing the debugfs implementations I thought the
code would look much cleaner if we had a wrapper function (or macro).
Note that the input to the current debugfs functions includes a struct
debug_htt_stats_req *stats_req that maintains the buffer pointer and filled
length. what if we had a wrapper that took just that, the format string, and
the optional arguments, and all of the pointer arithmetic is encapsulated in
that function, rather than being open coded?
so instead of:
len += scnprintf(buf + len, buf_len - len, "some string"");
have simply:
ath12k_scnprintf(stats_req, "some string");
that function would extract the buffer pointer and current filled length from
stats_req, calculate where to write the next string, call scnprintf() or
vscnprintf() to write the string, and then update the current filled length in
the stats_req. That would eliminate all of this housekeeping from the callers:
buf + len
buf_len - len
len += scnprintf(..)
/jeff
next prev parent reply other threads:[~2025-01-07 23:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-28 11:09 [PATCH 0/2] wifi: ath12k: Support Rate and OFDMA Stats Roopni Devanathan
2024-11-28 11:09 ` [PATCH 1/2] wifi: ath12k: Support Transmit Rate Buffer Stats Roopni Devanathan
2024-12-03 0:04 ` Jeff Johnson
2025-01-07 19:41 ` Kalle Valo
2024-11-28 11:09 ` [PATCH 2/2] wifi: ath12k: Support Transmit Buffer OFDMA Stats Roopni Devanathan
2024-12-03 0:04 ` Jeff Johnson
2025-01-07 19:45 ` Kalle Valo
2025-01-07 23:38 ` Jeff Johnson [this message]
2025-01-09 5:38 ` Roopni Devanathan
2025-01-10 20:08 ` Jeff Johnson
2025-01-10 20:17 ` [PATCH 0/2] wifi: ath12k: Support Rate and " 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=c776b5ee-0e25-4d21-be21-dd318ae33d1e@oss.qualcomm.com \
--to=jeff.johnson@oss.qualcomm.com \
--cc=ath12k@lists.infradead.org \
--cc=kvalo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=quic_pradeepc@quicinc.com \
--cc=quic_rdevanat@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