Explorar o código

Don't pad files that are already aligned

David Tang <dtang03@users.sf.net> noted:
  According to the DOCSIS MULPI spec, pad bytes should be used to word
  (32-bit) align a file. This means that there should only be at most
  3 pad bytes appended to the end of a file. We are noticing that some
  files are getting generated with 4 pad bytes, which does not
  accomplish anything for word alignment.

  From the spec:
    C.1.2.2 Pad Configuration Setting
    This has no length or value fields and is only used following the
    end of data marker to pad the file to an integral number of 32-bit
    words.

http://sf.net/tracker/?func=detail&aid=2858695&group_id=22615&atid=375631
Richard Laager %!s(int64=15) %!d(string=hai) anos
pai
achega
d040810fd2
Modificáronse 1 ficheiros con 1 adicións e 7 borrados
  1. 1 7
      src/docsis.c

+ 1 - 7
src/docsis.c

@@ -74,13 +74,7 @@ add_eod_and_pad (unsigned char *tlvbuf, unsigned int tlvbuflen)
 
   tlvbuf[tlvbuflen] = 255;
   tlvbuflen = tlvbuflen + 1;
-  nr_pads =
-    4 - (tlvbuflen - 4 * ((unsigned int) floor ((double) (tlvbuflen / 4))));
-  if (nr_pads < 0)
-    {
-      printf ("Illegal number of pads\n");
-      exit (-1);
-    }
+  nr_pads = (4 - (tlvbuflen % 4)) % 4;
   memset (&tlvbuf[tlvbuflen], 0, nr_pads);
   return (tlvbuflen + nr_pads);
 }