diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2023-10-26 03:22:01 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-25 12:22:01 -0700 |
| commit | 1a8216b7cd6f272253e7381bc520c65b7dd38b24 (patch) | |
| tree | 9865d2dcf28d7a56a13c665563f8adc0fa96de04 /tools | |
| parent | e04abb54bc69d90a503852d60a89e8bac7b60ec8 (diff) | |
Fix warnings for gcc 12.3 (#3286)
* Silence a few gcc out of bounds warnings
* Search upwards from executable for prelude directory instead of assuming depth
* comment wording
* Check return values of read and write
* Correct path to vulkan headers in gfx
* Correct diagnostic on missing file in slang-embed
* Do not use absolute path to libraries in test-context.cpp
---------
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/gfx/vulkan/vk-module.h | 2 | ||||
| -rw-r--r-- | tools/render-test/slang-support.cpp | 6 | ||||
| -rw-r--r-- | tools/slang-embed/slang-embed.cpp | 2 | ||||
| -rw-r--r-- | tools/slang-generate/main.cpp | 6 | ||||
| -rw-r--r-- | tools/slang-test/test-context.cpp | 5 |
5 files changed, 14 insertions, 7 deletions
diff --git a/tools/gfx/vulkan/vk-module.h b/tools/gfx/vulkan/vk-module.h index 5e67a0a7f..97a0c8aba 100644 --- a/tools/gfx/vulkan/vk-module.h +++ b/tools/gfx/vulkan/vk-module.h @@ -13,7 +13,7 @@ #define VK_NO_PROTOTYPES -#include <vulkan/include/vulkan/vulkan.h> +#include <vulkan/vulkan.h> // Undef xlib macros #ifdef Always diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp index d9d8ddb45..82d292cee 100644 --- a/tools/render-test/slang-support.cpp +++ b/tools/render-test/slang-support.cpp @@ -348,7 +348,11 @@ void ShaderCompilerUtil::Output::reset() fseek(sourceFile, 0, SEEK_SET); outSourceText.setCount(sourceSize + 1); - fread(outSourceText.getBuffer(), sourceSize, 1, sourceFile); + if(fread(outSourceText.getBuffer(), sourceSize, 1, sourceFile) != 1) + { + fprintf(stderr, "error: failed to read from '%s'\n", inSourcePath.getBuffer()); + return SLANG_FAIL; + } fclose(sourceFile); outSourceText[sourceSize] = 0; diff --git a/tools/slang-embed/slang-embed.cpp b/tools/slang-embed/slang-embed.cpp index 80ee6c237..0edc13683 100644 --- a/tools/slang-embed/slang-embed.cpp +++ b/tools/slang-embed/slang-embed.cpp @@ -213,7 +213,7 @@ struct App FILE* outputFile = fopen(outputPath, "w"); ScopedFile outputFileCleanup(outputFile); - if( !outputPath ) + if( !outputFile ) { fprintf(stderr, "%s: error: failed to open '%s' for reading\n", appName, outputPath); exit(1); diff --git a/tools/slang-generate/main.cpp b/tools/slang-generate/main.cpp index 7d07cd613..af81385dd 100644 --- a/tools/slang-generate/main.cpp +++ b/tools/slang-generate/main.cpp @@ -809,7 +809,11 @@ SourceFile* parseSourceFile(const String& path) fseek(inputStream, 0, SEEK_SET); char* input = (char*)malloc(inputSize + 1); - fread(input, inputSize, 1, inputStream); + if(fread(input, inputSize, 1, inputStream) != 1) + { + fprintf(stderr, "unable to read input file: %s\n", path.getBuffer()); + return nullptr; + } input[inputSize] = 0; char const* inputEnd = input + inputSize; diff --git a/tools/slang-test/test-context.cpp b/tools/slang-test/test-context.cpp index 39f5c92ed..b1be005cb 100644 --- a/tools/slang-test/test-context.cpp +++ b/tools/slang-test/test-context.cpp @@ -122,9 +122,8 @@ TestContext::InnerMainFunc TestContext::getInnerMainFunc(const String& dirPath, sharedLibToolBuilder.append(name); sharedLibToolBuilder.append("-tool"); - StringBuilder builder; - SharedLibrary::appendPlatformFileName(sharedLibToolBuilder.getUnownedSlice(), builder); - String path = Path::combine(dirPath, builder); + StringBuilder path; + SharedLibrary::appendPlatformFileName(sharedLibToolBuilder.getUnownedSlice(), path); DefaultSharedLibraryLoader* loader = DefaultSharedLibraryLoader::getSingleton(); |
