Re: [PATCH 3/4] soc: qcom: aoss: Format string in qmp_send()
From: Konrad Dybcio <hidden>
Date: 2023-07-31 08:22:00
Also in:
linux-arm-msm, linux-remoteproc, lkml
From: Konrad Dybcio <hidden>
Date: 2023-07-31 08:22:00
Also in:
linux-arm-msm, linux-remoteproc, lkml
On 31.07.2023 06:10, Bjorn Andersson wrote:
The majority of callers to qmp_send() composes the message dynamically using some form of sprintf(), resulting in unnecessary complication and stack usage. By changing the interface of qmp_send() to take a format string and arguments, the duplicated composition of the commands can be moved to a single location. Signed-off-by: Bjorn Andersson <redacted> ---
[...]
+int qmp_send(struct qmp *qmp, const char *fmt, ...)
{
long time_left;
+ va_list args;
char buf[QMP_MSG_LEN];
+ int len;
int ret;
- if (WARN_ON(IS_ERR_OR_NULL(qmp) || !data))
+ if (WARN_ON(IS_ERR_OR_NULL(qmp) || !fmt))
return -EINVAL;
- if (WARN_ON(strlen(data) >= sizeof(buf)))
- return -EINVAL;
+ memset(buf, 0, sizeof(buf));Wouldn't initializing the array with = { 0 } be faster?
Otherwise, this looks very cool
Reviewed-by: Konrad Dybcio <redacted>
Konrad