Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions include/dxc/Support/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,15 @@ extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(
inline void OutputDebugBytes(const void *ptr, size_t len) {
const char digits[] = "0123456789abcdef";
const unsigned char *pBytes = (const unsigned char *)ptr;
const int bytesPerLine = 16;
char buffer[bytesPerLine * 3 + 2 + 1];
buffer[_countof(buffer) - 3] = '\r';
buffer[_countof(buffer) - 2] = '\n';
buffer[_countof(buffer) - 1] = '\0';
constexpr size_t bytesPerLine = 16;
constexpr size_t bufferSize = bytesPerLine * 3 + 2 + 1;
char buffer[bufferSize];
buffer[bufferSize - 3] = '\r';
buffer[bufferSize - 2] = '\n';
buffer[bufferSize - 1] = '\0';

char *pWrite = buffer;
char *pEnd = buffer + _countof(buffer) - 3;
char *pEnd = buffer + bufferSize - 3;
while (len) {
*pWrite++ = digits[(*pBytes & 0xF0) >> 4];
*pWrite++ = digits[*pBytes & 0x0f];
Expand All @@ -264,11 +265,12 @@ inline void OutputDebugBytes(const void *ptr, size_t len) {
}

inline void OutputDebugFormatA(const char *pszFormat, ...) {
char buffer[1024];
constexpr size_t bufferSize = 1024;
char buffer[bufferSize];

va_list argList;
va_start(argList, pszFormat);
int count = vsnprintf_s(buffer, _countof(buffer), pszFormat, argList);
int count = vsnprintf_s(buffer, bufferSize, pszFormat, argList);
va_end(argList);

OutputDebugStringA(buffer);
Expand Down
1 change: 1 addition & 0 deletions lib/DXIL/DxilSemantic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "dxc/DXIL/DxilSignature.h"
#include "dxc/Support/Global.h"

#include <cstdlib>
#include <string>

using std::string;
Expand Down
4 changes: 2 additions & 2 deletions lib/DXIL/DxilShaderModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ const char *ShaderModel::GetKindName() const { return GetKindName(m_Kind); }

const char *ShaderModel::GetKindName(Kind kind) {
static_assert(static_cast<unsigned>(Kind::Invalid) ==
_countof(ShaderModelKindNames) - 1,
std::size(ShaderModelKindNames) - 1,
"Invalid kinds or names");
return ShaderModelKindNames[static_cast<unsigned int>(kind)];
}
Expand Down Expand Up @@ -648,7 +648,7 @@ static const char *NodeLaunchTypeNames[] = {"invalid", "broadcasting",

const char *ShaderModel::GetNodeLaunchTypeName(DXIL::NodeLaunchType launchTy) {
static_assert(static_cast<unsigned>(DXIL::NodeLaunchType::Thread) ==
_countof(NodeLaunchTypeNames) - 1,
std::size(NodeLaunchTypeNames) - 1,
"Invalid launch type or names");
return NodeLaunchTypeNames[static_cast<unsigned int>(launchTy)];
}
Expand Down
Loading