Cleanup add brace (#6545)

* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line

(cherry picked from commit 6a2200823c to reduce conflicts merging between SDL2 and SDL3)
This commit is contained in:
Sylvain Becker authored and Sam Lantinga committed 2022-11-28 12:33:03 -08:00
1 parent 0739d237ad
commit fb0ce375f0
386 files changed
+6103 -4637

No files matched your search

+20 -20
View File
@@ -233,7 +233,7 @@ static void createInstance(void)
quit(2);
}
extensions = (const char **) SDL_malloc(sizeof(const char *) * extensionCount);
if (!extensions) {
if (extensions == NULL) {
SDL_OutOfMemory();
quit(2);
}
@@ -309,7 +309,7 @@ static void findPhysicalDevice(void)
quit(2);
}
physicalDevices = (VkPhysicalDevice *) SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
if (!physicalDevices) {
if (physicalDevices == NULL) {
SDL_OutOfMemory();
quit(2);
}
@@ -331,7 +331,7 @@ static void findPhysicalDevice(void)
VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex];
vkGetPhysicalDeviceProperties(physicalDevice, &vulkanContext->physicalDeviceProperties);
if(VK_VERSION_MAJOR(vulkanContext->physicalDeviceProperties.apiVersion) < 1) {
if (VK_VERSION_MAJOR(vulkanContext->physicalDeviceProperties.apiVersion) < 1) {
continue;
}
vkGetPhysicalDeviceFeatures(physicalDevice, &vulkanContext->physicalDeviceFeatures);
@@ -343,7 +343,7 @@ static void findPhysicalDevice(void)
SDL_free(queueFamiliesProperties);
queueFamiliesPropertiesAllocatedSize = queueFamiliesCount;
queueFamiliesProperties = (VkQueueFamilyProperties *) SDL_malloc(sizeof(VkQueueFamilyProperties) * queueFamiliesPropertiesAllocatedSize);
if (!queueFamiliesProperties) {
if (queueFamiliesProperties == NULL) {
SDL_free(physicalDevices);
SDL_free(deviceExtensions);
SDL_OutOfMemory();
@@ -389,8 +389,7 @@ static void findPhysicalDevice(void)
continue;
}
result = vkEnumerateDeviceExtensionProperties(physicalDevice, NULL, &deviceExtensionCount, NULL);
if (result != VK_SUCCESS)
{
if (result != VK_SUCCESS) {
SDL_free(physicalDevices);
SDL_free(queueFamiliesProperties);
SDL_free(deviceExtensions);
@@ -406,7 +405,7 @@ static void findPhysicalDevice(void)
SDL_free(deviceExtensions);
deviceExtensionsAllocatedSize = deviceExtensionCount;
deviceExtensions = SDL_malloc(sizeof(VkExtensionProperties) * deviceExtensionsAllocatedSize);
if (!deviceExtensions) {
if (deviceExtensions == NULL) {
SDL_free(physicalDevices);
SDL_free(queueFamiliesProperties);
SDL_OutOfMemory();
@@ -424,7 +423,7 @@ static void findPhysicalDevice(void)
quit(2);
}
for (i = 0; i < deviceExtensionCount; i++) {
if(SDL_strcmp(deviceExtensions[i].extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) {
if (SDL_strcmp(deviceExtensions[i].extensionName, VK_KHR_SWAPCHAIN_EXTENSION_NAME) == 0) {
hasSwapchainExtension = SDL_TRUE;
break;
}
@@ -641,7 +640,7 @@ static SDL_bool createSwapchain(void)
} else {
vulkanContext->surfaceFormat = vulkanContext->surfaceFormats[0];
for (i = 0; i < vulkanContext->surfaceFormatsCount; i++) {
if(vulkanContext->surfaceFormats[i].format == VK_FORMAT_R8G8B8A8_UNORM) {
if (vulkanContext->surfaceFormats[i].format == VK_FORMAT_R8G8B8A8_UNORM) {
vulkanContext->surfaceFormat = vulkanContext->surfaceFormats[i];
break;
}
@@ -687,7 +686,7 @@ static SDL_bool createSwapchain(void)
vkDestroySwapchainKHR(vulkanContext->device, createInfo.oldSwapchain, NULL);
}
if(result != VK_SUCCESS) {
if (result != VK_SUCCESS) {
vulkanContext->swapchain = VK_NULL_HANDLE;
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"vkCreateSwapchainKHR(): %s\n",
@@ -756,7 +755,7 @@ static void createCommandBuffers(void)
allocateInfo.commandBufferCount = vulkanContext->swapchainImageCount;
vulkanContext->commandBuffers = (VkCommandBuffer *) SDL_malloc(sizeof(VkCommandBuffer) * vulkanContext->swapchainImageCount);
result = vkAllocateCommandBuffers(vulkanContext->device, &allocateInfo, vulkanContext->commandBuffers);
if(result != VK_SUCCESS) {
if (result != VK_SUCCESS) {
SDL_free(vulkanContext->commandBuffers);
vulkanContext->commandBuffers = NULL;
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
@@ -781,8 +780,8 @@ static void createFences(void)
createInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
createInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
result = vkCreateFence(vulkanContext->device, &createInfo, NULL, &vulkanContext->fences[i]);
if(result != VK_SUCCESS) {
for(; i > 0; i--) {
if (result != VK_SUCCESS) {
for (; i > 0; i--) {
vkDestroyFence(vulkanContext->device, vulkanContext->fences[i - 1], NULL);
}
SDL_free(vulkanContext->fences);
@@ -851,7 +850,7 @@ static void rerecordCommandBuffer(uint32_t frameIndex, const VkClearColorValue *
VkImageSubresourceRange clearRange = {0};
VkResult result = vkResetCommandBuffer(commandBuffer, 0);
if(result != VK_SUCCESS) {
if (result != VK_SUCCESS) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"vkResetCommandBuffer(): %s\n",
getVulkanResultString(result));
@@ -909,7 +908,7 @@ static SDL_bool createNewSwapchainAndSwapchainSpecificStuff(void)
destroySwapchainAndSwapchainSpecificStuff(SDL_FALSE);
getSurfaceCaps();
getSurfaceFormats();
if(!createSwapchain()) {
if (!createSwapchain()) {
return SDL_FALSE;
}
createCommandPool();
@@ -925,7 +924,7 @@ static void initVulkan(void)
SDL_Vulkan_LoadLibrary(NULL);
vulkanContexts = (VulkanContext *) SDL_calloc(state->num_windows, sizeof (VulkanContext));
if (!vulkanContexts) {
if (vulkanContexts == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!");
quit(2);
}
@@ -1000,8 +999,9 @@ static SDL_bool render(void)
if (!vulkanContext->swapchain) {
SDL_bool retval = createNewSwapchainAndSwapchainSpecificStuff();
if(!retval)
if (!retval) {
SDL_Delay(100);
}
return retval;
}
result = vkAcquireNextImageKHR(vulkanContext->device,
@@ -1068,7 +1068,7 @@ static SDL_bool render(void)
quit(2);
}
SDL_Vulkan_GetDrawableSize(vulkanContext->window, &w, &h);
if(w != (int)vulkanContext->swapchainSize.width || h != (int)vulkanContext->swapchainSize.height) {
if (w != (int)vulkanContext->swapchainSize.width || h != (int)vulkanContext->swapchainSize.height) {
return createNewSwapchainAndSwapchainSpecificStuff();
}
return SDL_TRUE;
@@ -1087,7 +1087,7 @@ int main(int argc, char **argv)
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
if(!state) {
if (state == NULL) {
return 1;
}
@@ -1117,7 +1117,7 @@ int main(int argc, char **argv)
while (!done) {
/* Check for events */
frames++;
while(SDL_PollEvent(&event)) {
while (SDL_PollEvent(&event)) {
/* Need to destroy the swapchain before the window created
* by SDL.
*/