MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / set_checksum

Method set_checksum

tools/comdb2ar/tar_header.cpp:84–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void TarHeader::set_checksum()
85// Calculate and store checksum. The method is:
86// Set the 8 checksum bytes to spaces
87// Sum the 512 bytes of the header, treating each byte as a uint.
88// Store the size in the format "000000\0 " where the 0's represent the
89// checksum as a zero padded six digit octal number.
90{
91 memset(m_head.h.checksum, ' ', sizeof(m_head.h.checksum));
92 unsigned int sum = 0;
93 for(int ii = 0; ii < sizeof(m_head.c); ii++) {
94 sum += m_head.c[ii];
95 }
96 snprintf(m_head.h.checksum, sizeof(m_head.h.checksum) - 1, "%06o", sum);
97}

Callers 4

serialise_stringFunction · 0.80
serialise_fileFunction · 0.80
serialise_databaseFunction · 0.80
write_incremental_fileFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected