public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ?
@ 2012-10-03 21:21 dcb314 at hotmail dot com
2012-10-03 21:22 ` [Bug other/54800] " dcb314 at hotmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: dcb314 at hotmail dot com @ 2012-10-03 21:21 UTC (permalink / raw)
To: gcc-bugs
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 ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug other/54800] libiberty/simple-object-mach-o.c:704: possible optimisation ?
2012-10-03 21:21 [Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ? dcb314 at hotmail dot com
@ 2012-10-03 21:22 ` dcb314 at hotmail dot com
2013-01-01 16:34 ` ian at airs dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: dcb314 at hotmail dot com @ 2012-10-03 21:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54800
--- Comment #1 from David Binderman <dcb314 at hotmail dot com> 2012-10-03 21:22:31 UTC ---
Or if you want something that compiles
memset (&namebuf[MACH_O_NAME_LEN], 0, MACH_O_NAME_LEN + 2);
might be closer ;->
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug other/54800] libiberty/simple-object-mach-o.c:704: possible optimisation ?
2012-10-03 21:21 [Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ? dcb314 at hotmail dot com
2012-10-03 21:22 ` [Bug other/54800] " dcb314 at hotmail dot com
@ 2013-01-01 16:34 ` ian at airs dot com
2013-01-04 18:36 ` iains at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: ian at airs dot com @ 2013-01-01 16:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54800
Ian Lance Taylor <ian at airs dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ian at airs dot com
--- Comment #2 from Ian Lance Taylor <ian at airs dot com> 2013-01-01 16:34:09 UTC ---
I think the correct patch is the following, but I have no way to test it.
Index: simple-object-mach-o.c
===================================================================
--- simple-object-mach-o.c (revision 194764)
+++ simple-object-mach-o.c (working copy)
@@ -701,12 +701,13 @@ simple_object_mach_o_segment (simple_obj
/* Otherwise, make a name like __segment,__section as per the
convention in mach-o asm. */
name = &namebuf[0];
- memset (namebuf, 0, MACH_O_NAME_LEN * 2 + 2);
memcpy (namebuf, (char *) sechdr + segname_offset, MACH_O_NAME_LEN);
+ namebuf[MACH_O_NAME_LEN] = '\0';
l = strlen (namebuf);
namebuf[l] = ',';
memcpy (namebuf + l + 1, (char *) sechdr + sectname_offset,
MACH_O_NAME_LEN);
+ namebuf[l + 1 + MACH_O_NAME_LEN] = '\0';
}
simple_object_mach_o_section_info (omr->is_big_endian, is_32, sechdr,
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug other/54800] libiberty/simple-object-mach-o.c:704: possible optimisation ?
2012-10-03 21:21 [Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ? dcb314 at hotmail dot com
2012-10-03 21:22 ` [Bug other/54800] " dcb314 at hotmail dot com
2013-01-01 16:34 ` ian at airs dot com
@ 2013-01-04 18:36 ` iains at gcc dot gnu.org
2013-01-04 19:00 ` ian at gcc dot gnu.org
2013-01-04 19:01 ` ian at airs dot com
4 siblings, 0 replies; 6+ messages in thread
From: iains at gcc dot gnu.org @ 2013-01-04 18:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54800
--- Comment #3 from Iain Sandoe <iains at gcc dot gnu.org> 2013-01-04 18:36:01 UTC ---
(In reply to comment #2)
> I think the correct patch is the following, but I have no way to test it.
this looks fine for all darwin,
I've tested it on i686-darwin9 / w lto-bootstrap and x86_64-darwin10 with lto
enabled.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug other/54800] libiberty/simple-object-mach-o.c:704: possible optimisation ?
2012-10-03 21:21 [Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ? dcb314 at hotmail dot com
` (2 preceding siblings ...)
2013-01-04 18:36 ` iains at gcc dot gnu.org
@ 2013-01-04 19:00 ` ian at gcc dot gnu.org
2013-01-04 19:01 ` ian at airs dot com
4 siblings, 0 replies; 6+ messages in thread
From: ian at gcc dot gnu.org @ 2013-01-04 19:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54800
--- Comment #4 from ian at gcc dot gnu.org <ian at gcc dot gnu.org> 2013-01-04 19:00:15 UTC ---
Author: ian
Date: Fri Jan 4 19:00:06 2013
New Revision: 194914
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194914
Log:
PR other/54800
* simple-object-mach-o.c (simple_object_mach_o_segment): Don't
bother to zero out a buffer we are about to set anyhow.
Modified:
trunk/libiberty/ChangeLog
trunk/libiberty/simple-object-mach-o.c
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug other/54800] libiberty/simple-object-mach-o.c:704: possible optimisation ?
2012-10-03 21:21 [Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ? dcb314 at hotmail dot com
` (3 preceding siblings ...)
2013-01-04 19:00 ` ian at gcc dot gnu.org
@ 2013-01-04 19:01 ` ian at airs dot com
4 siblings, 0 replies; 6+ messages in thread
From: ian at airs dot com @ 2013-01-04 19:01 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54800
Ian Lance Taylor <ian at airs dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
--- Comment #5 from Ian Lance Taylor <ian at airs dot com> 2013-01-04 19:00:49 UTC ---
Fixed.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-01-04 19:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-03 21:21 [Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ? dcb314 at hotmail dot com
2012-10-03 21:22 ` [Bug other/54800] " dcb314 at hotmail dot com
2013-01-01 16:34 ` ian at airs dot com
2013-01-04 18:36 ` iains at gcc dot gnu.org
2013-01-04 19:00 ` ian at gcc dot gnu.org
2013-01-04 19:01 ` ian at airs dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).