Remove unnecessary calls to memset
authorPhilipp Kloke <philipp.kloke@web.de>
Sun, 31 Mar 2013 09:59:22 +0000 (11:59 +0200)
committerCyrill Gorcunov <gorcunov@gmail.com>
Sun, 31 Mar 2013 22:11:01 +0000 (02:11 +0400)
The C standard guarantees that strncpy pads
the string with zeros if source string is smaller
than destination buffer.

Signed-off-by: Philipp Kloke <philipp.kloke@web.de>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
output/outcoff.c

index 6c72806..258363f 100644 (file)
@@ -945,7 +945,6 @@ static void coff_section_header(char *name, int32_t vsize,
 
     (void)vsize;
 
-    memset(padname, 0, 8);
     strncpy(padname, name, 8);
     fwrite(padname, 8, 1, ofile);
 
@@ -998,7 +997,6 @@ static void coff_symbol(char *name, int32_t strpos, int32_t value,
     char padname[8];
 
     if (name) {
-        memset(padname, 0, 8);
         strncpy(padname, name, 8);
         fwrite(padname, 8, 1, ofile);
     } else {
@@ -1023,7 +1021,6 @@ static void coff_write_symbols(void)
      * The `.file' record, and the file name auxiliary record.
      */
     coff_symbol(".file", 0L, 0L, -2, 0, 0x67, 1);
-    memset(filename, 0, 18);
     strncpy(filename, coff_infile, 18);
     fwrite(filename, 18, 1, ofile);