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

Side by Side Diff: src/log-utils.cc

Issue 799008: Make the assumption on the minimum buffer size for GetLogLines explicit. (Closed)
Patch Set: Added assert, removed failing checks from test. Created 10 years, 9 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 unified diff | Download patch
« no previous file with comments | « src/log-utils.h ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 ASSERT(from_pos >= 0); 189 ASSERT(from_pos >= 0);
190 ASSERT(max_size >= 0); 190 ASSERT(max_size >= 0);
191 int actual_size = output_buffer_->Read(from_pos, dest_buf, max_size); 191 int actual_size = output_buffer_->Read(from_pos, dest_buf, max_size);
192 ASSERT(actual_size <= max_size); 192 ASSERT(actual_size <= max_size);
193 if (actual_size == 0) return 0; 193 if (actual_size == 0) return 0;
194 194
195 // Find previous log line boundary. 195 // Find previous log line boundary.
196 char* end_pos = dest_buf + actual_size - 1; 196 char* end_pos = dest_buf + actual_size - 1;
197 while (end_pos >= dest_buf && *end_pos != '\n') --end_pos; 197 while (end_pos >= dest_buf && *end_pos != '\n') --end_pos;
198 actual_size = static_cast<int>(end_pos - dest_buf + 1); 198 actual_size = static_cast<int>(end_pos - dest_buf + 1);
199 // If the assertion below is hit, it means that there was no line end
200 // found --- something wrong has happened.
201 ASSERT(actual_size > 0);
199 ASSERT(actual_size <= max_size); 202 ASSERT(actual_size <= max_size);
200 return actual_size; 203 return actual_size;
201 } 204 }
202 205
203 206
204 LogMessageBuilder::WriteFailureHandler 207 LogMessageBuilder::WriteFailureHandler
205 LogMessageBuilder::write_failure_handler = NULL; 208 LogMessageBuilder::write_failure_handler = NULL;
206 209
207 210
208 LogMessageBuilder::LogMessageBuilder(): sl(Log::mutex_), pos_(0) { 211 LogMessageBuilder::LogMessageBuilder(): sl(Log::mutex_), pos_(0) {
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 PrintBackwardReference(backref, best.distance, best.copy_from_pos); 488 PrintBackwardReference(backref, best.distance, best.copy_from_pos);
486 ASSERT(strlen(backref.start()) - best.backref_size == 0); 489 ASSERT(strlen(backref.start()) - best.backref_size == 0);
487 prev_record->Truncate(static_cast<int>(unchanged_len + best.backref_size)); 490 prev_record->Truncate(static_cast<int>(unchanged_len + best.backref_size));
488 } 491 }
489 return true; 492 return true;
490 } 493 }
491 494
492 #endif // ENABLE_LOGGING_AND_PROFILING 495 #endif // ENABLE_LOGGING_AND_PROFILING
493 496
494 } } // namespace v8::internal 497 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/log-utils.h ('k') | test/cctest/test-log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698