Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(470)

Unified Diff: base/files/file_posix.cc

Issue 1372113002: Remove memory corruption testing from base::File(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: narrowed Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/files/file.h ('k') | base/files/file_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_posix.cc
diff --git a/base/files/file_posix.cc b/base/files/file_posix.cc
index 7fb617c3f9daab5cc0494cb63e54ddc7a3eb1a65..a5aee01aa2935f3d2e1110c1822d44b6cabe8217 100644
--- a/base/files/file_posix.cc
+++ b/base/files/file_posix.cc
@@ -420,49 +420,6 @@ File::Error File::OSErrorToFileError(int saved_errno) {
}
}
-File::MemoryCheckingScopedFD::MemoryCheckingScopedFD() {
- UpdateChecksum();
-}
-
-File::MemoryCheckingScopedFD::MemoryCheckingScopedFD(int fd) : file_(fd) {
- UpdateChecksum();
-}
-
-File::MemoryCheckingScopedFD::~MemoryCheckingScopedFD() {}
-
-// static
-void File::MemoryCheckingScopedFD::ComputeMemoryChecksum(
- unsigned int* out_checksum) const {
- // Use a single iteration of a linear congruentional generator (lcg) to
- // provide a cheap checksum unlikely to be accidentally matched by a random
- // memory corruption.
-
- // By choosing constants that satisfy the Hull-Duebell Theorem on lcg cycle
- // length, we insure that each distinct fd value maps to a distinct checksum,
- // which maximises the utility of our checksum.
-
- // This code uses "unsigned int" throughout for its defined modular semantics,
- // which implicitly gives us a divisor that is a power of two.
-
- const unsigned int kMultiplier = 13035 * 4 + 1;
- COMPILE_ASSERT(((kMultiplier - 1) & 3) == 0, pred_must_be_multiple_of_four);
- const unsigned int kIncrement = 1595649551;
- COMPILE_ASSERT(kIncrement & 1, must_be_coprime_to_powers_of_two);
-
- *out_checksum =
- static_cast<unsigned int>(file_.get()) * kMultiplier + kIncrement;
-}
-
-void File::MemoryCheckingScopedFD::Check() const {
- unsigned int computed_checksum;
- ComputeMemoryChecksum(&computed_checksum);
- CHECK_EQ(file_memory_checksum_, computed_checksum) << "corrupted fd memory";
-}
-
-void File::MemoryCheckingScopedFD::UpdateChecksum() {
- ComputeMemoryChecksum(&file_memory_checksum_);
-}
-
// NaCl doesn't implement system calls to open files directly.
#if !defined(OS_NACL)
// TODO(erikkay): does it make sense to support FLAG_EXCLUSIVE_* here?
« no previous file with comments | « base/files/file.h ('k') | base/files/file_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698