This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/54800] New: libiberty/simple-object-mach-o.c:704: possible optimisation ?


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 ?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]