From b5297de56fc20af1f5c6d0decb1da7f3ade369e6 Mon Sep 17 00:00:00 2001 From: Petar Popovic Date: Fri, 21 Feb 2025 23:55:14 +0100 Subject: [PATCH] Add 'const' to pointer parameters --- src/audio/SDL_audioresample.c | 2 +- src/audio/alsa/SDL_alsa_audio.c | 12 ++++++------ src/gpu/vulkan/SDL_gpu_vulkan.c | 4 ++-- src/joystick/SDL_gamepad.c | 2 +- src/video/wayland/SDL_waylanddatamanager.c | 2 +- test/testgpu_spinning_cube.c | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/audio/SDL_audioresample.c b/src/audio/SDL_audioresample.c index dd2451bfa5..400396aba1 100644 --- a/src/audio/SDL_audioresample.c +++ b/src/audio/SDL_audioresample.c @@ -444,7 +444,7 @@ static void SincTable(float *table, int len) } // Calculate Sinc(x/y), using a lookup table -static float Sinc(float *table, int x, int y) +static float Sinc(const float *table, int x, int y) { float s = table[x % y]; s = ((x / y) & 1) ? -s : s; diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 25e9d492d6..308eb23593 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -566,7 +566,7 @@ static enum snd_pcm_chmap_position sdl_channel_maps[SDL_AUDIO_ALSA__SDL_CHMAPS_N }; // Helper for the function right below. -static bool has_pos(unsigned int *chmap, unsigned int pos) +static bool has_pos(const unsigned int *chmap, unsigned int pos) { for (unsigned int chan_idx = 0; ; chan_idx++) { if (chan_idx == 6) { @@ -586,7 +586,7 @@ static bool has_pos(unsigned int *chmap, unsigned int pos) #define HAVE_REAR 1 #define HAVE_SIDE 2 #define HAVE_BOTH 3 -static void sdl_6chans_set_rear_or_side_channels_from_alsa_6chans(unsigned int *sdl_6chans, unsigned int *alsa_6chans) +static void sdl_6chans_set_rear_or_side_channels_from_alsa_6chans(unsigned int *sdl_6chans, const unsigned int *alsa_6chans) { // For alsa channel maps with 6 channels and with SND_CHMAP_FL,SND_CHMAP_FR,SND_CHMAP_FC, // SND_CHMAP_LFE, reduce our 6 channels maps to a uniq one. @@ -638,7 +638,7 @@ static void sdl_6chans_set_rear_or_side_channels_from_alsa_6chans(unsigned int * #undef HAVE_SIDE #undef HAVE_BOTH -static void swizzle_map_compute_alsa_subscan(struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map, unsigned int sdl_pos_idx) +static void swizzle_map_compute_alsa_subscan(const struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map, unsigned int sdl_pos_idx) { swizzle_map[sdl_pos_idx] = -1; for (unsigned int alsa_pos_idx = 0; ; alsa_pos_idx++) { @@ -652,7 +652,7 @@ static void swizzle_map_compute_alsa_subscan(struct ALSA_pcm_cfg_ctx *ctx, int * } // XXX: this must stay playback/recording symetric. -static void swizzle_map_compute(struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map, bool *needs_swizzle) +static void swizzle_map_compute(const struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map, bool *needs_swizzle) { *needs_swizzle = false; for (unsigned int sdl_pos_idx = 0; sdl_pos_idx != ctx->chans_n; sdl_pos_idx++) { @@ -668,7 +668,7 @@ static void swizzle_map_compute(struct ALSA_pcm_cfg_ctx *ctx, int *swizzle_map, #define CHMAP_NOT_FOUND 2 // Should always be a queried alsa channel map unless the queried alsa channel map was of type VAR, // namely we can program the channel positions directly from the SDL channel map. -static int alsa_chmap_install(struct ALSA_pcm_cfg_ctx *ctx, unsigned int *chmap) +static int alsa_chmap_install(struct ALSA_pcm_cfg_ctx *ctx, const unsigned int *chmap) { bool isstack; snd_pcm_chmap_t *chmap_to_install = (snd_pcm_chmap_t*)SDL_small_alloc(unsigned int, 1 + ctx->chans_n, &isstack); @@ -698,7 +698,7 @@ static int alsa_chmap_install(struct ALSA_pcm_cfg_ctx *ctx, unsigned int *chmap) // We restrict the alsa channel maps because in the unordered matches we do only simple accounting. // In the end, this will handle mostly alsa channel maps with more than one SND_CHMAP_NA position fillers. -static bool alsa_chmap_has_duplicate_position(struct ALSA_pcm_cfg_ctx *ctx, unsigned int *pos) +static bool alsa_chmap_has_duplicate_position(const struct ALSA_pcm_cfg_ctx *ctx, const unsigned int *pos) { if (ctx->chans_n < 2) {// we need at least 2 positions LOGDEBUG("channel map:no duplicate"); diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index b8c900ea4b..cf832ad2b4 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -1586,7 +1586,7 @@ static void VULKAN_INTERNAL_RemoveMemoryUsedRegion( static bool VULKAN_INTERNAL_CheckMemoryTypeArrayUnique( Uint32 memoryTypeIndex, - Uint32 *memoryTypeIndexArray, + const Uint32 *memoryTypeIndexArray, Uint32 count) { Uint32 i = 0; @@ -4448,7 +4448,7 @@ static bool VULKAN_INTERNAL_VerifySwapSurfaceFormat( static bool VULKAN_INTERNAL_VerifySwapPresentMode( VkPresentModeKHR presentMode, - VkPresentModeKHR *availablePresentModes, + const VkPresentModeKHR *availablePresentModes, Uint32 availablePresentModesLength) { Uint32 i; diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index ba434eea45..bd28c90e3d 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -428,7 +428,7 @@ static bool SDLCALL SDL_GamepadEventWatcher(void *userdata, SDL_Event *event) orientation, so when it's changed orientation to be used as a gamepad, change the sensor orientation to match. */ -static void AdjustSensorOrientation(SDL_Joystick *joystick, float *src, float *dst) +static void AdjustSensorOrientation(const SDL_Joystick *joystick, const float *src, float *dst) { unsigned int i, j; diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index 8a7bf659cd..6f5b32bbb3 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c @@ -272,7 +272,7 @@ void Wayland_primary_selection_source_set_callback(SDL_WaylandPrimarySelectionSo } } -static void *Wayland_clone_data_buffer(const void *buffer, size_t *len) +static void *Wayland_clone_data_buffer(const void *buffer, const size_t *len) { void *clone = NULL; if (*len > 0 && buffer) { diff --git a/test/testgpu_spinning_cube.c b/test/testgpu_spinning_cube.c index b2f7aefff1..0eeb034fbb 100644 --- a/test/testgpu_spinning_cube.c +++ b/test/testgpu_spinning_cube.c @@ -152,7 +152,7 @@ perspective_matrix(float fovy, float aspect, float znear, float zfar, float *r) * major. In-place multiplication is supported. */ static void -multiply_matrix(float *lhs, float *rhs, float *r) +multiply_matrix(const float *lhs, const float *rhs, float *r) { int i, j, k; float tmp[16];