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

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).