This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ?
- From: "dcb314 at hotmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 03 Oct 2012 21:20:57 +0000
- Subject: [Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ?
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54800
Bug #: 54800
Summary: libiberty/simple-object-mach-o.c:704: possible
optimisation ?
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: other
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: dcb314@hotmail.com
I just tried the latest cppcheck over the source code
of trunk and it said
[trunk/libiberty/simple-object-mach-o.c:704] ->
[trunk/libiberty/simple-object-mach-o.c:705]: (performance) Buffer 'namebuf' is
being written before its old content has been used.
The source code is
memset (namebuf, 0, MACH_O_NAME_LEN * 2 + 2);
memcpy (namebuf, (char *) sechdr + segname_offset, MACH_O_NAME_LEN);
Maybe something like
memcpy (namebuf, (char *) sechdr + segname_offset, MACH_O_NAME_LEN);
memset (&namebuf[MACH_O_NAME_LEN], MACH_O_NAME_LEN + 2);
might be faster and simpler ?