From: Zhan Xusheng <zhanxusheng1024@gmail.com>
To: linux-staging@lists.linux.dev
Cc: Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: [PATCH 2/4] staging: greybus: audio: avoid macro with side effects
Date: Fri, 19 Dec 2025 14:34:13 +0800 [thread overview]
Message-ID: <20251219063415.46818-3-zhanxusheng@xiaomi.com> (raw)
In-Reply-To: <20251219063415.46818-1-zhanxusheng@xiaomi.com>
The gbaudio_dapm_for_each_direction() macro modifies its argument and
evaluates it multiple times, which can lead to subtle bugs if used with
expressions that have side effects.
Replace the macro with an explicit for-loop to improve readability and
avoid potential side effects.
No functional changes.
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
---
drivers/staging/greybus/audio_helper.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
index b4873c6d6bed..6264cafe9675 100644
--- a/drivers/staging/greybus/audio_helper.c
+++ b/drivers/staging/greybus/audio_helper.c
@@ -8,10 +8,6 @@
#include <sound/soc-dapm.h>
#include "audio_helper.h"
-#define gbaudio_dapm_for_each_direction(dir) \
- for ((dir) = SND_SOC_DAPM_DIR_IN; (dir) <= SND_SOC_DAPM_DIR_OUT; \
- (dir)++)
-
static void gbaudio_dapm_link_dai_widget(struct snd_soc_dapm_widget *dai_w,
struct snd_soc_card *card)
{
@@ -98,7 +94,7 @@ static void gbaudio_dapm_free_widget(struct snd_soc_dapm_widget *w)
* While removing the path, remove reference to it from both
* source and sink widgets so that path is removed only once.
*/
- gbaudio_dapm_for_each_direction(dir) {
+ for (dir = SND_SOC_DAPM_DIR_IN; dir <= SND_SOC_DAPM_DIR_OUT; dir++) {
snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p)
gbaudio_dapm_free_path(p);
}
--
2.43.0
next prev parent reply other threads:[~2025-12-19 6:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 6:34 [PATCH 0/4] greybus: staging fixes and cleanups Zhan Xusheng
2025-12-19 6:34 ` [PATCH 1/4] staging: greybus: spilib: fix function parameter indentation Zhan Xusheng
2025-12-22 8:45 ` Greg KH
2025-12-19 6:34 ` Zhan Xusheng [this message]
2025-12-22 8:46 ` [PATCH 2/4] staging: greybus: audio: avoid macro with side effects Greg KH
2025-12-19 6:34 ` [PATCH 3/4] staging: greybus: gb-camera: use BIT() macro and fix formatting Zhan Xusheng
2025-12-22 8:46 ` Greg KH
2025-12-19 6:34 ` [PATCH 4/4] staging: greybus: greybus_firmware: fix long macro lines Zhan Xusheng
2025-12-22 8:47 ` Greg KH
2025-12-22 15:40 ` [PATCH 1/4] staging: greybus: gb-camera: use BIT() macro and fix formatting Zhan Xusheng
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=20251219063415.46818-3-zhanxusheng@xiaomi.com \
--to=zhanxusheng1024@gmail.com \
--cc=linux-staging@lists.linux.dev \
--cc=zhanxusheng@xiaomi.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