mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 21:29:41 +00:00
Replace strcpy with memcpy when we have the length around anyway.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94746 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2c47368a7d
commit
12ea66a727
@ -368,7 +368,7 @@ GenericValue lle_X_sprintf(const FunctionType *FT,
|
|||||||
|
|
||||||
switch (Last) {
|
switch (Last) {
|
||||||
case '%':
|
case '%':
|
||||||
strcpy(Buffer, "%"); break;
|
memcpy(Buffer, "%", 2); break;
|
||||||
case 'c':
|
case 'c':
|
||||||
sprintf(Buffer, FmtBuf, uint32_t(Args[ArgNo++].IntVal.getZExtValue()));
|
sprintf(Buffer, FmtBuf, uint32_t(Args[ArgNo++].IntVal.getZExtValue()));
|
||||||
break;
|
break;
|
||||||
@ -400,8 +400,9 @@ GenericValue lle_X_sprintf(const FunctionType *FT,
|
|||||||
errs() << "<unknown printf code '" << *FmtStr << "'!>";
|
errs() << "<unknown printf code '" << *FmtStr << "'!>";
|
||||||
ArgNo++; break;
|
ArgNo++; break;
|
||||||
}
|
}
|
||||||
strcpy(OutputBuffer, Buffer);
|
size_t Len = strlen(Buffer);
|
||||||
OutputBuffer += strlen(Buffer);
|
memcpy(OutputBuffer, Buffer, Len + 1);
|
||||||
|
OutputBuffer += Len;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -507,8 +507,9 @@ void cl::ParseCommandLineOptions(int argc, char **argv,
|
|||||||
|
|
||||||
// Copy the program name into ProgName, making sure not to overflow it.
|
// Copy the program name into ProgName, making sure not to overflow it.
|
||||||
std::string ProgName = sys::Path(argv[0]).getLast();
|
std::string ProgName = sys::Path(argv[0]).getLast();
|
||||||
if (ProgName.size() > 79) ProgName.resize(79);
|
size_t Len = std::min(ProgName.size(), size_t(79));
|
||||||
strcpy(ProgramName, ProgName.c_str());
|
memcpy(ProgramName, ProgName.data(), Len);
|
||||||
|
ProgramName[Len] = '\0';
|
||||||
|
|
||||||
ProgramOverview = Overview;
|
ProgramOverview = Overview;
|
||||||
bool ErrorParsing = false;
|
bool ErrorParsing = false;
|
||||||
|
@ -55,9 +55,10 @@ namespace PIC16CC {
|
|||||||
|
|
||||||
// External symbol names require memory to live till the program end.
|
// External symbol names require memory to live till the program end.
|
||||||
// So we have to allocate it and keep.
|
// So we have to allocate it and keep.
|
||||||
|
// FIXME: Don't leak the allocated strings.
|
||||||
inline static const char *createESName (const std::string &name) {
|
inline static const char *createESName (const std::string &name) {
|
||||||
char *tmpName = new char[name.size() + 1];
|
char *tmpName = new char[name.size() + 1];
|
||||||
strcpy (tmpName, name.c_str());
|
memcpy(tmpName, name.c_str(), name.size() + 1);
|
||||||
return tmpName;
|
return tmpName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -323,8 +323,6 @@ llvm::SplitFunctionsOutOfModule(Module *M,
|
|||||||
Module *BugDriver::ExtractMappedBlocksFromModule(const
|
Module *BugDriver::ExtractMappedBlocksFromModule(const
|
||||||
std::vector<BasicBlock*> &BBs,
|
std::vector<BasicBlock*> &BBs,
|
||||||
Module *M) {
|
Module *M) {
|
||||||
char *ExtraArg = NULL;
|
|
||||||
|
|
||||||
sys::Path uniqueFilename(OutputPrefix + "-extractblocks");
|
sys::Path uniqueFilename(OutputPrefix + "-extractblocks");
|
||||||
std::string ErrMsg;
|
std::string ErrMsg;
|
||||||
if (uniqueFilename.createTemporaryFileOnDisk(true, &ErrMsg)) {
|
if (uniqueFilename.createTemporaryFileOnDisk(true, &ErrMsg)) {
|
||||||
@ -359,9 +357,8 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
|
|||||||
}
|
}
|
||||||
BlocksToNotExtractFile.close();
|
BlocksToNotExtractFile.close();
|
||||||
|
|
||||||
const char *uniqueFN = uniqueFilename.c_str();
|
std::string uniqueFN = "--extract-blocks-file=" + uniqueFilename.str();
|
||||||
ExtraArg = (char*)malloc(23 + strlen(uniqueFN));
|
const char *ExtraArg = uniqueFN.c_str();
|
||||||
strcat(strcpy(ExtraArg, "--extract-blocks-file="), uniqueFN);
|
|
||||||
|
|
||||||
std::vector<const PassInfo*> PI;
|
std::vector<const PassInfo*> PI;
|
||||||
std::vector<BasicBlock *> EmptyBBs; // This parameter is ignored.
|
std::vector<BasicBlock *> EmptyBBs; // This parameter is ignored.
|
||||||
@ -370,7 +367,6 @@ Module *BugDriver::ExtractMappedBlocksFromModule(const
|
|||||||
|
|
||||||
if (uniqueFilename.exists())
|
if (uniqueFilename.exists())
|
||||||
uniqueFilename.eraseFromDisk(); // Free disk space
|
uniqueFilename.eraseFromDisk(); // Free disk space
|
||||||
free(ExtraArg);
|
|
||||||
|
|
||||||
if (Ret == 0) {
|
if (Ret == 0) {
|
||||||
outs() << "*** Basic Block extraction failed, please report a bug!\n";
|
outs() << "*** Basic Block extraction failed, please report a bug!\n";
|
||||||
|
@ -179,8 +179,9 @@ static char ** CopyEnv(char ** const envp) {
|
|||||||
// Make a copy of the list. Don't forget the NULL that ends the list.
|
// Make a copy of the list. Don't forget the NULL that ends the list.
|
||||||
entries = 0;
|
entries = 0;
|
||||||
while (envp[entries] != NULL) {
|
while (envp[entries] != NULL) {
|
||||||
newenv[entries] = new char[strlen (envp[entries]) + 1];
|
size_t len = strlen(envp[entries]) + 1;
|
||||||
strcpy (newenv[entries], envp[entries]);
|
newenv[entries] = new char[len];
|
||||||
|
memcpy(newenv[entries], envp[entries], len);
|
||||||
++entries;
|
++entries;
|
||||||
}
|
}
|
||||||
newenv[entries] = NULL;
|
newenv[entries] = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user