* [PATCH] ALSA: aloop: Constify ops structs
@ 2020-11-20 23:10 Rikard Falkeborn
2020-11-21 8:31 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Rikard Falkeborn @ 2020-11-20 23:10 UTC (permalink / raw)
To: Takashi Iwai, aroslav Kysela; +Cc: alsa-devel, linux-kernel, Rikard Falkeborn
The only usage of the ops field in the loopback_cable struct is to call
its members, the field it self is never changed. Make it a pointer to
const. This allows us to constify two static loopback_ops structs to
allow the compiler to put them in read-only memory.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
---
sound/drivers/aloop.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/drivers/aloop.c b/sound/drivers/aloop.c
index c91356326699..702f91b9c60f 100644
--- a/sound/drivers/aloop.c
+++ b/sound/drivers/aloop.c
@@ -105,7 +105,7 @@ struct loopback_cable {
unsigned int running;
unsigned int pause;
/* timer specific */
- struct loopback_ops *ops;
+ const struct loopback_ops *ops;
/* If sound timer is used */
struct {
int stream;
@@ -1021,7 +1021,7 @@ static int loopback_jiffies_timer_open(struct loopback_pcm *dpcm)
return 0;
}
-static struct loopback_ops loopback_jiffies_timer_ops = {
+static const struct loopback_ops loopback_jiffies_timer_ops = {
.open = loopback_jiffies_timer_open,
.start = loopback_jiffies_timer_start,
.stop = loopback_jiffies_timer_stop,
@@ -1172,7 +1172,7 @@ static int loopback_snd_timer_open(struct loopback_pcm *dpcm)
/* stop_sync() is not required for sound timer because it does not need to be
* restarted in loopback_prepare() on Xrun recovery
*/
-static struct loopback_ops loopback_snd_timer_ops = {
+static const struct loopback_ops loopback_snd_timer_ops = {
.open = loopback_snd_timer_open,
.start = loopback_snd_timer_start,
.stop = loopback_snd_timer_stop,
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: aloop: Constify ops structs
2020-11-20 23:10 [PATCH] ALSA: aloop: Constify ops structs Rikard Falkeborn
@ 2020-11-21 8:31 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2020-11-21 8:31 UTC (permalink / raw)
To: Rikard Falkeborn; +Cc: Takashi Iwai, aroslav Kysela, alsa-devel, linux-kernel
On Sat, 21 Nov 2020 00:10:46 +0100,
Rikard Falkeborn wrote:
>
> The only usage of the ops field in the loopback_cable struct is to call
> its members, the field it self is never changed. Make it a pointer to
> const. This allows us to constify two static loopback_ops structs to
> allow the compiler to put them in read-only memory.
>
> Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Thanks, applied.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-21 8:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 23:10 [PATCH] ALSA: aloop: Constify ops structs Rikard Falkeborn
2020-11-21 8:31 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).