зеркало из https://github.com/AvaloniaUI/angle.git
Converts from sprintf() to snprintf().
sprintf() is deprecated in Xcode 14, so update to safer equivalents in order to keep the compiler happy on iOS and macOS. Bug: chromium:1331345 Change-Id: Id5348088bf69cbd360d9251e6323596cb710666d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3690747 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Родитель
ce3c0fe901
Коммит
4b911686c6
|
@ -34,7 +34,7 @@ void LoadBinaryData(const char *fileName)
|
||||||
}
|
}
|
||||||
char pathBuffer[1000] = {};
|
char pathBuffer[1000] = {};
|
||||||
|
|
||||||
sprintf(pathBuffer, "%s/%s", gBinaryDataDir.c_str(), fileName);
|
snprintf(pathBuffer, sizeof(pathBuffer), "%s/%s", gBinaryDataDir.c_str(), fileName);
|
||||||
FILE *fp = fopen(pathBuffer, "rb");
|
FILE *fp = fopen(pathBuffer, "rb");
|
||||||
if (fp == 0)
|
if (fp == 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -33,11 +33,11 @@ class GLSLTest : public ANGLETest
|
||||||
|
|
||||||
if (vectorSize == 1)
|
if (vectorSize == 1)
|
||||||
{
|
{
|
||||||
sprintf(varyingType, "float");
|
snprintf(varyingType, sizeof(varyingType), "float");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(varyingType, "vec%d", vectorSize);
|
snprintf(varyingType, sizeof(varyingType), "vec%d", vectorSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string(varyingType);
|
return std::string(varyingType);
|
||||||
|
@ -49,12 +49,13 @@ class GLSLTest : public ANGLETest
|
||||||
|
|
||||||
if (arraySize == 1)
|
if (arraySize == 1)
|
||||||
{
|
{
|
||||||
sprintf(buff, "varying %s v%d;\n", GenerateVaryingType(vectorSize).c_str(), id);
|
snprintf(buff, sizeof(buff), "varying %s v%d;\n",
|
||||||
|
GenerateVaryingType(vectorSize).c_str(), id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(buff, "varying %s v%d[%d];\n", GenerateVaryingType(vectorSize).c_str(), id,
|
snprintf(buff, sizeof(buff), "varying %s v%d[%d];\n",
|
||||||
arraySize);
|
GenerateVaryingType(vectorSize).c_str(), id, arraySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::string(buff);
|
return std::string(buff);
|
||||||
|
@ -67,14 +68,15 @@ class GLSLTest : public ANGLETest
|
||||||
|
|
||||||
if (arraySize == 1)
|
if (arraySize == 1)
|
||||||
{
|
{
|
||||||
sprintf(buff, "\t v%d = %s(1.0);\n", id, GenerateVaryingType(vectorSize).c_str());
|
snprintf(buff, sizeof(buff), "\t v%d = %s(1.0);\n", id,
|
||||||
|
GenerateVaryingType(vectorSize).c_str());
|
||||||
returnString += buff;
|
returnString += buff;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < arraySize; i++)
|
for (int i = 0; i < arraySize; i++)
|
||||||
{
|
{
|
||||||
sprintf(buff, "\t v%d[%d] = %s(1.0);\n", id, i,
|
snprintf(buff, sizeof(buff), "\t v%d[%d] = %s(1.0);\n", id, i,
|
||||||
GenerateVaryingType(vectorSize).c_str());
|
GenerateVaryingType(vectorSize).c_str());
|
||||||
returnString += buff;
|
returnString += buff;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +90,7 @@ class GLSLTest : public ANGLETest
|
||||||
if (arraySize == 1)
|
if (arraySize == 1)
|
||||||
{
|
{
|
||||||
char buff[100];
|
char buff[100];
|
||||||
sprintf(buff, "v%d + ", id);
|
snprintf(buff, sizeof(buff), "v%d + ", id);
|
||||||
return std::string(buff);
|
return std::string(buff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -97,7 +99,7 @@ class GLSLTest : public ANGLETest
|
||||||
for (int i = 0; i < arraySize; i++)
|
for (int i = 0; i < arraySize; i++)
|
||||||
{
|
{
|
||||||
char buff[100];
|
char buff[100];
|
||||||
sprintf(buff, "v%d[%d] + ", id, i);
|
snprintf(buff, sizeof(buff), "v%d[%d] + ", id, i);
|
||||||
returnString += buff;
|
returnString += buff;
|
||||||
}
|
}
|
||||||
return returnString;
|
return returnString;
|
||||||
|
|
|
@ -349,7 +349,7 @@ void WriteResultsFile(bool interrupted,
|
||||||
jsResult.AddMember("times", times, allocator);
|
jsResult.AddMember("times", times, allocator);
|
||||||
|
|
||||||
char testName[500];
|
char testName[500];
|
||||||
id.sprintfName(testName);
|
id.snprintfName(testName, sizeof(testName));
|
||||||
js::Value jsName;
|
js::Value jsName;
|
||||||
jsName.SetString(testName, allocator);
|
jsName.SetString(testName, allocator);
|
||||||
|
|
||||||
|
@ -1008,9 +1008,9 @@ TestIdentifier::~TestIdentifier() = default;
|
||||||
|
|
||||||
TestIdentifier &TestIdentifier::operator=(const TestIdentifier &other) = default;
|
TestIdentifier &TestIdentifier::operator=(const TestIdentifier &other) = default;
|
||||||
|
|
||||||
void TestIdentifier::sprintfName(char *outBuffer) const
|
void TestIdentifier::snprintfName(char *outBuffer, size_t maxLen) const
|
||||||
{
|
{
|
||||||
sprintf(outBuffer, "%s.%s", testSuiteName.c_str(), testName.c_str());
|
snprintf(outBuffer, maxLen, "%s.%s", testSuiteName.c_str(), testName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct TestIdentifier
|
||||||
static bool ParseFromString(const std::string &str, TestIdentifier *idOut);
|
static bool ParseFromString(const std::string &str, TestIdentifier *idOut);
|
||||||
|
|
||||||
bool valid() const { return !testName.empty(); }
|
bool valid() const { return !testName.empty(); }
|
||||||
void sprintfName(char *outBuffer) const;
|
void snprintfName(char *outBuffer, size_t maxLen) const;
|
||||||
|
|
||||||
std::string testSuiteName;
|
std::string testSuiteName;
|
||||||
std::string testName;
|
std::string testName;
|
||||||
|
|
|
@ -98,8 +98,7 @@ ReadResult ReadFromFile(int fd, std::string *out)
|
||||||
void ReadEntireFile(int fd, std::string *out)
|
void ReadEntireFile(int fd, std::string *out)
|
||||||
{
|
{
|
||||||
while (ReadFromFile(fd, out) == ReadResult::GotData)
|
while (ReadFromFile(fd, out) == ReadResult::GotData)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class PosixProcess : public Process
|
class PosixProcess : public Process
|
||||||
|
@ -420,7 +419,7 @@ bool GetTempDir(char *tempDirOut, uint32_t maxDirNameLen)
|
||||||
bool CreateTemporaryFileInDir(const char *dir, char *tempFileNameOut, uint32_t maxFileNameLen)
|
bool CreateTemporaryFileInDir(const char *dir, char *tempFileNameOut, uint32_t maxFileNameLen)
|
||||||
{
|
{
|
||||||
std::string tempFile = TempFileName();
|
std::string tempFile = TempFileName();
|
||||||
sprintf(tempFileNameOut, "%s/%s", dir, tempFile.c_str());
|
snprintf(tempFileNameOut, maxFileNameLen, "%s/%s", dir, tempFile.c_str());
|
||||||
int fd = mkstemp(tempFileNameOut);
|
int fd = mkstemp(tempFileNameOut);
|
||||||
close(fd);
|
close(fd);
|
||||||
return fd != -1;
|
return fd != -1;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче