summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-emit-source-writer.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-04-24 15:51:43 -0700
committerGitHub <noreply@github.com>2024-04-24 15:51:43 -0700
commitfc4c242442510fb97c3cfbf04d7582ebbc3bb0ed (patch)
tree0c19f6974dad99cbe1faa24b1aba41d0780008da /source/slang/slang-emit-source-writer.cpp
parent211b2ffc20d7798cab0b8483ccc3ec2b7ade49ab (diff)
Fix macos CI and clang warnings. (#4019)
* Fix macos CI. * Fix. * Fix. * Fix. * Fix clang warnings. * Fix more warnings.
Diffstat (limited to 'source/slang/slang-emit-source-writer.cpp')
-rw-r--r--source/slang/slang-emit-source-writer.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/source/slang/slang-emit-source-writer.cpp b/source/slang/slang-emit-source-writer.cpp
index d8364d5c3..ddce0ab89 100644
--- a/source/slang/slang-emit-source-writer.cpp
+++ b/source/slang/slang-emit-source-writer.cpp
@@ -3,10 +3,6 @@
#include "../core/slang-char-encode.h"
-// Disable warnings about sprintf
-#ifdef _WIN32
-# pragma warning(disable:4996)
-#endif
// Note: using C++ stdio just to get a locale-independent
// way to format floating-point values.
@@ -199,28 +195,28 @@ void SourceWriter::emitInt64(int64_t value)
void SourceWriter::emit(Int32 value)
{
char buffer[16];
- sprintf(buffer, "%" PRId32, value);
+ snprintf(buffer, sizeof(buffer), "%" PRId32, value);
emit(buffer);
}
void SourceWriter::emit(Int64 value)
{
char buffer[32];
- sprintf(buffer, "%" PRId64, value);
+ snprintf(buffer, sizeof(buffer), "%" PRId64, value);
emit(buffer);
}
void SourceWriter::emit(UInt32 value)
{
char buffer[32];
- sprintf(buffer, "%" PRIu32, value);
+ snprintf(buffer, sizeof(buffer), "%" PRIu32, value);
emit(buffer);
}
void SourceWriter::emit(UInt64 value)
{
char buffer[32];
- sprintf(buffer, "%" PRIu64, value);
+ snprintf(buffer, sizeof(buffer), "%" PRIu64, value);
emit(buffer);
}
@@ -463,7 +459,7 @@ void SourceWriter::_emitLineDirective(const HumaneSourceLoc& sourceLocation)
emitRawText("\n#line ");
char buffer[16];
- sprintf(buffer, "%llu", (unsigned long long)sourceLocation.line);
+ snprintf(buffer, sizeof(buffer), "%llu", (unsigned long long)sourceLocation.line);
emitRawText(buffer);
// Only emit the path part of a `#line` directive if needed
@@ -497,7 +493,7 @@ void SourceWriter::_emitLineDirective(const HumaneSourceLoc& sourceLocation)
m_mapGLSLSourcePathToID.add(path, id);
}
- sprintf(buffer, "%d", id);
+ snprintf(buffer, sizeof(buffer), "%d", id);
emitRawText(buffer);
break;
}