Skip to contentSkip to conversation

sound: oss: make the function argument and structure const

PATCH In review Bhumika Goyal 2 participants 4 messages Oct 13, 2017 – Oct 16, 2017 Sound

lore
Share & tools
lore
#0 lore raw

cover sound: oss: make the function argument and structure const

Make the function argument of function sound_install_audiodrv const. After this change, make the structures audio_driver const as they are only passed to the const argument (made const in Patch[1/2]) of the function sound_install_audiodrv .

Bhumika Goyal (2):
sound: oss: make the function argument as const
sound: oss: make audio_driver structure const

 sound/oss/dev_table.c  | 2 +-
 sound/oss/dev_table.h  | 2 +-
 sound/oss/pas2_pcm.c   | 2 +-
 sound/oss/waveartist.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/2 sound: oss: make the function argument as const

Make the function argument struct audio_driver *driver of the function sound_install_audiodrv as const as it's memory contents are only copied during a memcpy call. So, the fields of the structure to which driver points to never gets modified and therefore the argument can be made const.
Add const to the prototype too.

---
 sound/oss/dev_table.c | 2 +-
 sound/oss/dev_table.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
sound/oss/dev_table.c +1 -1
index 6dad515..dbb9a3b 100644
@@ -48,7 +48,7 @@ struct sound_timer_operations *sound_timer_devs[MAX_TIMER_DEV] = {
 
 static int sound_alloc_audiodev(void);
 
-int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
+int sound_install_audiodrv(int vers, char *name, const struct audio_driver *driver,
 			int driver_size, int flags, unsigned int format_mask,
 			void *devc, int dma1, int dma2)
 {
sound/oss/dev_table.h +1 -1
index 0199a31..b388ed0 100644
@@ -371,7 +371,7 @@ struct sound_timer_operations
 
 #define AUDIO_DRIVER_VERSION	2
 #define MIXER_DRIVER_VERSION	2
-int sound_install_audiodrv(int vers, char *name, struct audio_driver *driver,
+int sound_install_audiodrv(int vers, char *name, const struct audio_driver *driver,
 			int driver_size, int flags, unsigned int format_mask,
 			void *devc, int dma1, int dma2);
 int sound_install_mixer(int vers, char *name, struct mixer_operations *driver,
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/2 sound: oss: make audio_driver structure const

In reply to Bhumika Goyal

This is a followup patch for [PATCH 1/2].

Make these structures const as they are only passed to the const argument of the function sound_install_audiodrv.

---
 sound/oss/pas2_pcm.c   | 2 +-
 sound/oss/waveartist.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
sound/oss/pas2_pcm.c +1 -1
index 474803b..716c5c4 100644
@@ -356,7 +356,7 @@ static int pas_audio_prepare_for_output(int dev, int bsize, int bcount)
 	return 0;
 }
 
-static struct audio_driver pas_audio_driver =
+static const struct audio_driver pas_audio_driver =
 {
 	.owner			= THIS_MODULE,
 	.open			= pas_audio_open,
sound/oss/waveartist.c +1 -1
index 4f0c3a2..7509777 100644
@@ -826,7 +826,7 @@ static void vnc_configure_mixer(struct wavnc_info *devc,
 	return arg;
 }
 
-static struct audio_driver waveartist_audio_driver = {
+static const struct audio_driver waveartist_audio_driver = {
 	.owner			= THIS_MODULE,
 	.open			= waveartist_open,
 	.close			= waveartist_close,
Signature · 1 line
1.9.1
#3 lore raw
In reply to Bhumika Goyal
Quoted 9 lines · Bhumika Goyal

Make the function argument of function sound_install_audiodrv const. After this change, make the structures audio_driver const as they are only passed to the const argument (made const in Patch[1/2]) of the function sound_install_audiodrv .

Bhumika Goyal (2):
sound: oss: make the function argument as const
sound: oss: make audio_driver structure const

The OSS code is already disabled in Kconfig and will be dropped soon, so please don't touch it.

thanks,

Takashi

Quoted 11 lines
 sound/oss/dev_table.c  | 2 +-
 sound/oss/dev_table.h  | 2 +-
 sound/oss/pas2_pcm.c   | 2 +-
 sound/oss/waveartist.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
1.9.1