[Patch for libcxxabi] Don't use bzero() and prevent unneeded copying
Ed Schouten
ed at 80386.nl
Thu Feb 12 08:42:02 PST 2015
Hi there,
While building libcxxabi on a new platform (more news on that later :-), I
noticed libcxxabi uses bzero() in a single place, causing the build to fail
in my environment. We could just use memset() instead.
At the same time, I received a compiler warning for strcpy(), as it is
advised to use str[nl]cpy() instead. In this specific case we could argue
we don't need to copy the string in the first place. The patch changes the
code to just assign a constant string to a pointer.
Best regards,
--
Ed Schouten <ed at 80386.nl>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150212/36b6b65a/attachment.html>
-------------- next part --------------
Index: src/Unwind/DwarfParser.hpp
===================================================================
--- src/Unwind/DwarfParser.hpp (revision 228935)
+++ src/Unwind/DwarfParser.hpp (working copy)
@@ -347,7 +347,7 @@
const CIE_Info &cieInfo, pint_t upToPC,
PrologInfo *results) {
// clear results
- bzero(results, sizeof(PrologInfo));
+ memset(results, '\0', sizeof(PrologInfo));
PrologInfoStackEntry *rememberStack = NULL;
// parse CIE then FDE instructions
Index: src/Unwind/Unwind-EHABI.cpp
===================================================================
--- src/Unwind/Unwind-EHABI.cpp (revision 228935)
+++ src/Unwind/Unwind-EHABI.cpp (working copy)
@@ -470,11 +470,12 @@
// When tracing, print state information.
if (_LIBUNWIND_TRACING_UNWINDING) {
- char functionName[512];
+ char functionBuf[512];
+ const char *functionName = functionBuf;
unw_word_t offset;
- if ((unw_get_proc_name(&cursor1, functionName, 512, &offset) !=
+ if ((unw_get_proc_name(&cursor1, functionBuf, 512, &offset) !=
UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
- strcpy(functionName, ".anonymous.");
+ functionName = ".anonymous.";
unw_word_t pc;
unw_get_reg(&cursor1, UNW_REG_IP, &pc);
_LIBUNWIND_TRACE_UNWINDING(
@@ -600,11 +601,12 @@
// When tracing, print state information.
if (_LIBUNWIND_TRACING_UNWINDING) {
- char functionName[512];
+ char functionBuf[512];
+ const char *functionName = functionBuf;
unw_word_t offset;
- if ((unw_get_proc_name(&cursor2, functionName, 512, &offset) !=
+ if ((unw_get_proc_name(&cursor2, functionBuf, 512, &offset) !=
UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
- strcpy(functionName, ".anonymous.");
+ functionName = ".anonymous.";
_LIBUNWIND_TRACE_UNWINDING(
"unwind_phase2(ex_ojb=%p): start_ip=0x%llX, func=%s, sp=0x%llX, "
"lsda=0x%llX, personality=0x%llX\n",
Index: src/Unwind/UnwindLevel1.c
===================================================================
--- src/Unwind/UnwindLevel1.c (revision 228935)
+++ src/Unwind/UnwindLevel1.c (working copy)
@@ -60,11 +60,12 @@
// When tracing, print state information.
if (_LIBUNWIND_TRACING_UNWINDING) {
- char functionName[512];
+ char functionBuf[512];
+ const char *functionName = functionBuf;
unw_word_t offset;
- if ((unw_get_proc_name(&cursor1, functionName, 512, &offset) !=
+ if ((unw_get_proc_name(&cursor1, functionBuf, 512, &offset) !=
UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
- strcpy(functionName, ".anonymous.");
+ functionName = ".anonymous.";
unw_word_t pc;
unw_get_reg(&cursor1, UNW_REG_IP, &pc);
_LIBUNWIND_TRACE_UNWINDING(
@@ -156,11 +157,12 @@
// When tracing, print state information.
if (_LIBUNWIND_TRACING_UNWINDING) {
- char functionName[512];
+ char functionBuf[512];
+ const char *functionName = functionBuf;
unw_word_t offset;
- if ((unw_get_proc_name(&cursor2, functionName, 512, &offset) !=
+ if ((unw_get_proc_name(&cursor2, functionBuf, 512, &offset) !=
UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
- strcpy(functionName, ".anonymous.");
+ functionName = ".anonymous.";
_LIBUNWIND_TRACE_UNWINDING("unwind_phase2(ex_ojb=%p): start_ip=0x%" PRIx64
", func=%s, sp=0x%" PRIx64 ", lsda=0x%" PRIx64
", personality=0x%" PRIx64 "\n",
@@ -246,11 +248,12 @@
// When tracing, print state information.
if (_LIBUNWIND_TRACING_UNWINDING) {
- char functionName[512];
+ char functionBuf[512];
+ const char *functionName = functionBuf;
unw_word_t offset;
- if ((unw_get_proc_name(&cursor2, functionName, 512, &offset) !=
+ if ((unw_get_proc_name(&cursor2, functionBuf, 512, &offset) !=
UNW_ESUCCESS) || (frameInfo.start_ip + offset > frameInfo.end_ip))
- strcpy(functionName, ".anonymous.");
+ functionName = ".anonymous.";
_LIBUNWIND_TRACE_UNWINDING(
"unwind_phase2_forced(ex_ojb=%p): start_ip=0x%" PRIx64
", func=%s, lsda=0x%" PRIx64 ", personality=0x%" PRIx64 "\n",
More information about the cfe-commits
mailing list