summaryrefslogtreecommitdiffstats
path: root/base/debug
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2014-10-20 20:11:21 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-21 03:12:36 +0000
commit073d514d518521a5c409d5037b45e0a46602c997 (patch)
tree965229f7d28b56331688b30aed23cca366d942a8 /base/debug
parent22390646e70aba2bb8e90688f9a6351f9571bca3 (diff)
downloadchromium_src-073d514d518521a5c409d5037b45e0a46602c997.zip
chromium_src-073d514d518521a5c409d5037b45e0a46602c997.tar.gz
chromium_src-073d514d518521a5c409d5037b45e0a46602c997.tar.bz2
Cleanup: Better constify some strings in base.
Fix some lint errors along the way. Review URL: https://codereview.chromium.org/632103004 Cr-Commit-Position: refs/heads/master@{#300407}
Diffstat (limited to 'base/debug')
-rw-r--r--base/debug/crash_logging_unittest.cc12
-rw-r--r--base/debug/proc_maps_linux_unittest.cc4
-rw-r--r--base/debug/trace_event_android.cc2
-rw-r--r--base/debug/trace_event_impl.h7
-rw-r--r--base/debug/trace_event_impl_constants.cc2
-rw-r--r--base/debug/trace_event_unittest.cc47
6 files changed, 36 insertions, 38 deletions
diff --git a/base/debug/crash_logging_unittest.cc b/base/debug/crash_logging_unittest.cc
index 8c252f0..cb11f13 100644
--- a/base/debug/crash_logging_unittest.cc
+++ b/base/debug/crash_logging_unittest.cc
@@ -44,7 +44,7 @@ class CrashLoggingTest : public testing::Test {
};
TEST_F(CrashLoggingTest, SetClearSingle) {
- const char* kTestKey = "test-key";
+ const char kTestKey[] = "test-key";
base::debug::CrashKey keys[] = { { kTestKey, 255 } };
base::debug::InitCrashKeys(keys, arraysize(keys), 255);
@@ -56,10 +56,10 @@ TEST_F(CrashLoggingTest, SetClearSingle) {
}
TEST_F(CrashLoggingTest, SetChunked) {
- const char* kTestKey = "chunky";
- const char* kChunk1 = "chunky-1";
- const char* kChunk2 = "chunky-2";
- const char* kChunk3 = "chunky-3";
+ const char kTestKey[] = "chunky";
+ const char kChunk1[] = "chunky-1";
+ const char kChunk2[] = "chunky-2";
+ const char kChunk3[] = "chunky-3";
base::debug::CrashKey keys[] = { { kTestKey, 15 } };
base::debug::InitCrashKeys(keys, arraysize(keys), 5);
@@ -104,7 +104,7 @@ TEST_F(CrashLoggingTest, SetChunked) {
}
TEST_F(CrashLoggingTest, ScopedCrashKey) {
- const char* kTestKey = "test-key";
+ const char kTestKey[] = "test-key";
base::debug::CrashKey keys[] = { { kTestKey, 255 } };
base::debug::InitCrashKeys(keys, arraysize(keys), 255);
diff --git a/base/debug/proc_maps_linux_unittest.cc b/base/debug/proc_maps_linux_unittest.cc
index 4be5a0f..d5d1b83 100644
--- a/base/debug/proc_maps_linux_unittest.cc
+++ b/base/debug/proc_maps_linux_unittest.cc
@@ -239,7 +239,7 @@ TEST(ProcMapsTest, ReadProcMapsNonEmptyString) {
}
TEST(ProcMapsTest, MissingFields) {
- static const char* kTestCases[] = {
+ static const char* const kTestCases[] = {
"00400000\n", // Missing end + beyond.
"00400000-0040b000\n", // Missing perms + beyond.
"00400000-0040b000 r-xp\n", // Missing offset + beyond.
@@ -261,7 +261,7 @@ TEST(ProcMapsTest, MissingFields) {
}
TEST(ProcMapsTest, InvalidInput) {
- static const char* kTestCases[] = {
+ static const char* const kTestCases[] = {
"thisisal-0040b000 rwxp 00000000 fc:00 794418 /bin/cat\n",
"0040000d-linvalid rwxp 00000000 fc:00 794418 /bin/cat\n",
"00400000-0040b000 inpu 00000000 fc:00 794418 /bin/cat\n",
diff --git a/base/debug/trace_event_android.cc b/base/debug/trace_event_android.cc
index 1e78b45..f08fffc 100644
--- a/base/debug/trace_event_android.cc
+++ b/base/debug/trace_event_android.cc
@@ -15,7 +15,7 @@
namespace {
int g_atrace_fd = -1;
-const char* kATraceMarkerFile = "/sys/kernel/debug/tracing/trace_marker";
+const char kATraceMarkerFile[] = "/sys/kernel/debug/tracing/trace_marker";
void WriteEvent(
char phase,
diff --git a/base/debug/trace_event_impl.h b/base/debug/trace_event_impl.h
index bac74e3..79bdc97 100644
--- a/base/debug/trace_event_impl.h
+++ b/base/debug/trace_event_impl.h
@@ -179,7 +179,7 @@ class BASE_EXPORT TraceEvent {
// TraceBufferChunk is the basic unit of TraceBuffer.
class BASE_EXPORT TraceBufferChunk {
public:
- TraceBufferChunk(uint32 seq)
+ explicit TraceBufferChunk(uint32 seq)
: next_free_(0),
seq_(seq) {
}
@@ -281,7 +281,7 @@ class BASE_EXPORT CategoryFilter {
// The default category filter, used when none is provided.
// Allows all categories through, except if they end in the suffix 'Debug' or
// 'Test'.
- static const char* kDefaultCategoryFilterString;
+ static const char kDefaultCategoryFilterString[];
// |filter_string| is a comma-delimited list of category wildcards.
// A category can have an optional '-' prefix to make it an excluded category.
@@ -380,13 +380,12 @@ enum TraceRecordMode {
};
struct BASE_EXPORT TraceOptions {
-
TraceOptions()
: record_mode(RECORD_UNTIL_FULL),
enable_sampling(false),
enable_systrace(false) {}
- TraceOptions(TraceRecordMode record_mode)
+ explicit TraceOptions(TraceRecordMode record_mode)
: record_mode(record_mode),
enable_sampling(false),
enable_systrace(false) {}
diff --git a/base/debug/trace_event_impl_constants.cc b/base/debug/trace_event_impl_constants.cc
index 24d7af7..8e01411 100644
--- a/base/debug/trace_event_impl_constants.cc
+++ b/base/debug/trace_event_impl_constants.cc
@@ -8,7 +8,7 @@ namespace base {
namespace debug {
// Enable everything but debug and test categories by default.
-const char* CategoryFilter::kDefaultCategoryFilterString = "-*Debug,-*Test";
+const char CategoryFilter::kDefaultCategoryFilterString[] = "-*Debug,-*Test";
// Constant used by TraceLog's internal implementation of trace_option.
const TraceLog::InternalTraceOptions
diff --git a/base/debug/trace_event_unittest.cc b/base/debug/trace_event_unittest.cc
index 90be070..836a0bb 100644
--- a/base/debug/trace_event_unittest.cc
+++ b/base/debug/trace_event_unittest.cc
@@ -252,7 +252,6 @@ DictionaryValue* TraceEventTestFixture::FindMatchingTraceEntry(
}
void TraceEventTestFixture::DropTracedMetadataRecords() {
-
scoped_ptr<ListValue> old_trace_parsed(trace_parsed_.DeepCopy());
size_t old_trace_parsed_size = old_trace_parsed->GetSize();
trace_parsed_.Clear();
@@ -266,7 +265,7 @@ void TraceEventTestFixture::DropTracedMetadataRecords() {
}
DictionaryValue* dict = static_cast<DictionaryValue*>(value);
std::string tmp;
- if(dict->GetString("ph", &tmp) && tmp == "M")
+ if (dict->GetString("ph", &tmp) && tmp == "M")
continue;
trace_parsed_.Append(value->DeepCopy());
@@ -377,7 +376,7 @@ std::vector<const DictionaryValue*> FindTraceEntries(
return hits;
}
-const char* kControlCharacters = "\001\002\003\n\r";
+const char kControlCharacters[] = "\001\002\003\n\r";
void TraceWithAllMacroVariants(WaitableEvent* task_complete_event) {
{
@@ -478,7 +477,7 @@ void TraceWithAllMacroVariants(WaitableEvent* task_complete_event) {
TRACE_EVENT1(kControlCharacters, kControlCharacters,
kControlCharacters, kControlCharacters);
- } // Scope close causes TRACE_EVENT0 etc to send their END events.
+ } // Scope close causes TRACE_EVENT0 etc to send their END events.
if (task_complete_event)
task_complete_event->Signal();
@@ -1300,12 +1299,12 @@ TEST_F(TraceEventTestFixture, AsyncBeginEndEvents) {
BeginTrace();
unsigned long long id = 0xfeedbeeffeedbeefull;
- TRACE_EVENT_ASYNC_BEGIN0( "cat", "name1", id);
- TRACE_EVENT_ASYNC_STEP_INTO0( "cat", "name1", id, "step1");
+ TRACE_EVENT_ASYNC_BEGIN0("cat", "name1", id);
+ TRACE_EVENT_ASYNC_STEP_INTO0("cat", "name1", id, "step1");
TRACE_EVENT_ASYNC_END0("cat", "name1", id);
- TRACE_EVENT_BEGIN0( "cat", "name2");
- TRACE_EVENT_ASYNC_BEGIN0( "cat", "name3", 0);
- TRACE_EVENT_ASYNC_STEP_PAST0( "cat", "name3", 0, "step2");
+ TRACE_EVENT_BEGIN0("cat", "name2");
+ TRACE_EVENT_ASYNC_BEGIN0("cat", "name3", 0);
+ TRACE_EVENT_ASYNC_STEP_PAST0("cat", "name3", 0, "step2");
EndTraceAndFlush();
@@ -1332,13 +1331,13 @@ TEST_F(TraceEventTestFixture, AsyncBeginEndPointerMangling) {
TraceLog::GetInstance()->SetProcessID(100);
BeginTrace();
- TRACE_EVENT_ASYNC_BEGIN0( "cat", "name1", ptr);
- TRACE_EVENT_ASYNC_BEGIN0( "cat", "name2", ptr);
+ TRACE_EVENT_ASYNC_BEGIN0("cat", "name1", ptr);
+ TRACE_EVENT_ASYNC_BEGIN0("cat", "name2", ptr);
EndTraceAndFlush();
TraceLog::GetInstance()->SetProcessID(200);
BeginTrace();
- TRACE_EVENT_ASYNC_END0( "cat", "name1", ptr);
+ TRACE_EVENT_ASYNC_END0("cat", "name1", ptr);
EndTraceAndFlush();
DictionaryValue* async_begin = FindNamePhase("name1", "S");
@@ -1490,32 +1489,32 @@ TEST_F(TraceEventTestFixture, DataCapturedManyThreads) {
TEST_F(TraceEventTestFixture, ThreadNames) {
// Create threads before we enable tracing to make sure
// that tracelog still captures them.
- const int num_threads = 4;
- const int num_events = 10;
- Thread* threads[num_threads];
- PlatformThreadId thread_ids[num_threads];
- for (int i = 0; i < num_threads; i++)
+ const int kNumThreads = 4;
+ const int kNumEvents = 10;
+ Thread* threads[kNumThreads];
+ PlatformThreadId thread_ids[kNumThreads];
+ for (int i = 0; i < kNumThreads; i++)
threads[i] = new Thread(StringPrintf("Thread %d", i));
// Enable tracing.
BeginTrace();
// Now run some trace code on these threads.
- WaitableEvent* task_complete_events[num_threads];
- for (int i = 0; i < num_threads; i++) {
+ WaitableEvent* task_complete_events[kNumThreads];
+ for (int i = 0; i < kNumThreads; i++) {
task_complete_events[i] = new WaitableEvent(false, false);
threads[i]->Start();
thread_ids[i] = threads[i]->thread_id();
threads[i]->message_loop()->PostTask(
FROM_HERE, base::Bind(&TraceManyInstantEvents,
- i, num_events, task_complete_events[i]));
+ i, kNumEvents, task_complete_events[i]));
}
- for (int i = 0; i < num_threads; i++) {
+ for (int i = 0; i < kNumThreads; i++) {
task_complete_events[i]->Wait();
}
// Shut things down.
- for (int i = 0; i < num_threads; i++) {
+ for (int i = 0; i < kNumThreads; i++) {
threads[i]->Stop();
delete threads[i];
delete task_complete_events[i];
@@ -1538,7 +1537,7 @@ TEST_F(TraceEventTestFixture, ThreadNames) {
EXPECT_TRUE(item->GetInteger("tid", &tmp_int));
// See if this thread name is one of the threads we just created
- for (int j = 0; j < num_threads; j++) {
+ for (int j = 0; j < kNumThreads; j++) {
if(static_cast<int>(thread_ids[j]) != tmp_int)
continue;
@@ -2969,7 +2968,7 @@ TEST_F(TraceEventTestFixture, ConfigureSyntheticDelays) {
}
TEST_F(TraceEventTestFixture, BadSyntheticDelayConfigurations) {
- const char* configs[] = {
+ const char* const configs[] = {
"",
"DELAY(",
"DELAY(;",