[PATCH 5.4 049/111] ALSA: hda: patch_realtek: fix empty macro usage in if block

From: Greg Kroah-Hartman
Date: Tue May 26 2020 - 15:24:20 EST


From: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>

[ Upstream commit 8a71821f12a010d7100f9cc1f7b218aff0313c4a ]

GCC reports the following warning with W=1

sound/pci/hda/patch_realtek.c: In function âalc269_suspendâ:
sound/pci/hda/patch_realtek.c:3616:29: warning: suggest braces around
empty body in an âifâ statement [-Wempty-body]
3616 | alc5505_dsp_suspend(codec);
| ^

sound/pci/hda/patch_realtek.c: In function âalc269_resumeâ:
sound/pci/hda/patch_realtek.c:3651:28: warning: suggest braces around empty body in an âifâ statement [-Wempty-body]
3651 | alc5505_dsp_resume(codec);
| ^

This is a classic macro problem and can indeed lead to bad program
flows.

Fix by using the usual "do { } while (0)" pattern

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@xxxxxxxxxxxxxxx>
Link: https://lore.kernel.org/r/20200111214736.3002-2-pierre-louis.bossart@xxxxxxxxxxxxxxx
Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
sound/pci/hda/patch_realtek.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 151099b8c394..a0e7d711cbb5 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -3719,8 +3719,8 @@ static void alc5505_dsp_init(struct hda_codec *codec)
}

#ifdef HALT_REALTEK_ALC5505
-#define alc5505_dsp_suspend(codec) /* NOP */
-#define alc5505_dsp_resume(codec) /* NOP */
+#define alc5505_dsp_suspend(codec) do { } while (0) /* NOP */
+#define alc5505_dsp_resume(codec) do { } while (0) /* NOP */
#else
#define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
#define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
--
2.25.1