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
This commit is contained in:
@@ -230,7 +230,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);
|
||||
}
|
||||
@@ -306,7 +306,7 @@ static void findPhysicalDevice(void)
|
||||
quit(2);
|
||||
}
|
||||
physicalDevices = (VkPhysicalDevice *) SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount);
|
||||
if (!physicalDevices) {
|
||||
if (physicalDevices == NULL) {
|
||||
SDL_OutOfMemory();
|
||||
quit(2);
|
||||
}
|
||||
@@ -328,7 +328,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);
|
||||
@@ -340,7 +340,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();
|
||||
@@ -386,8 +386,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);
|
||||
@@ -403,7 +402,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();
|
||||
@@ -421,7 +420,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;
|
||||
}
|
||||
@@ -638,7 +637,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;
|
||||
}
|
||||
@@ -684,7 +683,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",
|
||||
@@ -753,7 +752,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,
|
||||
@@ -778,8 +777,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);
|
||||
@@ -848,7 +847,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));
|
||||
@@ -906,7 +905,7 @@ static SDL_bool createNewSwapchainAndSwapchainSpecificStuff(void)
|
||||
destroySwapchainAndSwapchainSpecificStuff(SDL_FALSE);
|
||||
getSurfaceCaps();
|
||||
getSurfaceFormats();
|
||||
if(!createSwapchain()) {
|
||||
if (!createSwapchain()) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
createCommandPool();
|
||||
@@ -922,7 +921,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);
|
||||
}
|
||||
@@ -997,8 +996,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,
|
||||
@@ -1065,7 +1065,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;
|
||||
@@ -1084,7 +1084,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if(!state) {
|
||||
if (state == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user