Skip to content

Commit a64b06e

Browse files
mkustermanncommit-bot@chromium.org
authored andcommitted
[gardening] Migrate most files to be implicit-bool-conversion free
Issue https://dart-review.googlesource.com/c/sdk/+/115701 Change-Id: Ib579f0bbc8d694aec74afd837217316a10baf910 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115707 Commit-Queue: Martin Kustermann <[email protected]> Reviewed-by: Ryan Macnak <[email protected]> Reviewed-by: Daco Harkes <[email protected]>
1 parent 698d120 commit a64b06e

File tree

90 files changed

+337
-175
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+337
-175
lines changed

runtime/bin/dartutils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ Dart_Handle DartUtils::EnvironmentCallback(Dart_Handle name) {
798798
// objects. As these will be used by different threads the use of
799799
// these depends on the fact that the marking internally in the
800800
// Dart_CObject structure is not marking simple value objects.
801-
Dart_CObject CObject::api_null_ = {Dart_CObject_kNull, {0}};
801+
Dart_CObject CObject::api_null_ = {Dart_CObject_kNull, {false}};
802802
Dart_CObject CObject::api_true_ = {Dart_CObject_kBool, {true}};
803803
Dart_CObject CObject::api_false_ = {Dart_CObject_kBool, {false}};
804804
CObject CObject::null_(&api_null_);

runtime/bin/dfe.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class WindowsPathSanitizer {
233233
if (len > 2 && path[1] == ':') {
234234
*s++ = '/';
235235
}
236-
for (const char *p = path; *p; ++p, ++s) {
236+
for (const char* p = path; *p != '\0'; ++p, ++s) {
237237
*s = *p == '\\' ? '/' : *p;
238238
}
239239
*s = '\0';

runtime/bin/ffi_test/ffi_test_functions.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ typedef Coord* (*CoordUnOp)(Coord* coord);
312312
// Coordinate.
313313
// Used for testing function pointers with structs.
314314
DART_EXPORT Coord* CoordinateUnOpTrice(CoordUnOp unop, Coord* coord) {
315-
std::cout << "CoordinateUnOpTrice(" << unop << ", " << coord << ")\n";
315+
std::cout << "CoordinateUnOpTrice(" << &unop << ", " << coord << ")\n";
316316
Coord* retval = unop(unop(unop(coord)));
317317
std::cout << "returning " << retval << "\n";
318318
return retval;
@@ -327,7 +327,7 @@ typedef intptr_t (*IntptrBinOp)(intptr_t a, intptr_t b);
327327
DART_EXPORT IntptrBinOp IntptrAdditionClosure() {
328328
std::cout << "IntptrAdditionClosure()\n";
329329
IntptrBinOp retval = [](intptr_t a, intptr_t b) { return a + b; };
330-
std::cout << "returning " << retval << "\n";
330+
std::cout << "returning " << &retval << "\n";
331331
return retval;
332332
}
333333

@@ -346,7 +346,7 @@ DART_EXPORT intptr_t ApplyTo42And74(IntptrBinOp binop) {
346346
DART_EXPORT int64_t* NullableInt64ElemAt1(int64_t* a) {
347347
std::cout << "NullableInt64ElemAt1(" << a << ")\n";
348348
int64_t* retval;
349-
if (a) {
349+
if (a != nullptr) {
350350
std::cout << "not null pointer, address: " << a << "\n";
351351
retval = a + 1;
352352
} else {
@@ -439,7 +439,7 @@ DART_EXPORT int64_t SumVeryLargeStruct(VeryLargeStruct* vls) {
439439
retval += vls->k;
440440
retval += vls->smallLastField;
441441
std::cout << retval << "\n";
442-
if (vls->parent) {
442+
if (vls->parent != nullptr) {
443443
std::cout << "has parent\n";
444444
retval += vls->parent->a;
445445
}

runtime/bin/file.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@ CObject* File::LockRequest(const CObjectArray& request) {
15071507
// Inspired by sdk/lib/core/uri.dart
15081508
UriDecoder::UriDecoder(const char* uri) : uri_(uri) {
15091509
const char* ch = uri;
1510-
while ((*ch != 0) && (*ch != '%')) {
1510+
while ((*ch != '\0') && (*ch != '%')) {
15111511
ch++;
15121512
}
15131513
if (*ch == 0) {
@@ -1524,7 +1524,7 @@ UriDecoder::UriDecoder(const char* uri) : uri_(uri) {
15241524
strncpy(dest, uri, i);
15251525
decoded_ = dest;
15261526
dest += i;
1527-
while (*ch) {
1527+
while (*ch != '\0') {
15281528
if (*ch != '%') {
15291529
*(dest++) = *(ch++);
15301530
continue;

runtime/bin/file_system_watcher_linux.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
132132
} else {
133133
Dart_ListSetAt(event, 2, Dart_Null());
134134
}
135-
Dart_ListSetAt(event, 3, Dart_NewBoolean(e->mask & IN_MOVED_TO));
135+
Dart_ListSetAt(event, 3, Dart_NewBoolean((e->mask & IN_MOVED_TO) != 0u));
136136
Dart_ListSetAt(event, 4, Dart_NewInteger(e->wd));
137137
Dart_ListSetAt(events, i, event);
138138
i++;

runtime/bin/file_test.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ TEST_CASE(OpenUri_RelativeFilename) {
4141
strlen(kFilename) * 3 + 1));
4242
char* t = encoded;
4343
// percent-encode all characters 'c'
44-
for (const char* p = kFilename; *p; p++) {
44+
for (const char* p = kFilename; *p != '\0'; p++) {
4545
if (*p == 'c') {
4646
*t++ = '%';
4747
*t++ = '6';
@@ -70,7 +70,7 @@ TEST_CASE(OpenUri_AbsoluteFilename) {
7070
strlen(kFilename) * 3 + 1));
7171
char* t = encoded;
7272
// percent-encode all characters 'c'
73-
for (const char* p = kFilename; *p; p++) {
73+
for (const char* p = kFilename; *p != '\0'; p++) {
7474
if (*p == 'c') {
7575
*t++ = '%';
7676
*t++ = '6';
@@ -110,7 +110,7 @@ TEST_CASE(OpenUri_ValidUri) {
110110
strlen(kFilename) * 3 + 1));
111111
char* t = encoded;
112112
// percent-encode all characters 'c'
113-
for (const char* p = kFilename; *p; p++) {
113+
for (const char* p = kFilename; *p != '\0'; p++) {
114114
if (*p == 'c') {
115115
*t++ = '%';
116116
*t++ = '6';
@@ -151,7 +151,7 @@ TEST_CASE(OpenUri_UriWithSpaces) {
151151
strlen(kFilename) * 3 + 1));
152152
char* t = encoded;
153153
// percent-encode all spaces
154-
for (const char* p = kFilename; *p; p++) {
154+
for (const char* p = kFilename; *p != '\0'; p++) {
155155
if (*p == ' ') {
156156
*t++ = '%';
157157
*t++ = '2';
@@ -180,7 +180,7 @@ TEST_CASE(OpenUri_InvalidUriPercentEncoding) {
180180
strlen(kFilename) * 3 + 1));
181181
char* t = encoded;
182182
// percent-encode all characters 'c'
183-
for (const char* p = kFilename; *p; p++) {
183+
for (const char* p = kFilename; *p != '\0'; p++) {
184184
if (*p == 'c') {
185185
*t++ = '%';
186186
*t++ = 'f';
@@ -200,7 +200,7 @@ TEST_CASE(OpenUri_TruncatedUriPercentEncoding) {
200200
strlen(kFilename) * 3 + 1));
201201
char* t = encoded;
202202
// percent-encode all characters 'c'
203-
for (const char* p = kFilename; *p; p++) {
203+
for (const char* p = kFilename; *p != '\0'; p++) {
204204
if (*p == 'c') {
205205
*t++ = '%';
206206
*t++ = 'f';

runtime/bin/gen_snapshot.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ int main(int argc, char** argv) {
909909
MapFile(load_vm_snapshot_instructions_filename, File::kReadExecute,
910910
&init_params.vm_snapshot_instructions);
911911
}
912-
if (load_isolate_snapshot_data_filename) {
912+
if (load_isolate_snapshot_data_filename != nullptr) {
913913
mapped_isolate_snapshot_data =
914914
MapFile(load_isolate_snapshot_data_filename, File::kReadOnly,
915915
&isolate_snapshot_data);

runtime/bin/loader.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ Dart_Handle Loader::LibraryTagHandler(Dart_LibraryTag tag,
619619
return result;
620620
}
621621
if (tag == Dart_kImportExtensionTag) {
622-
if (strncmp(url_string, "dart-ext:", 9)) {
622+
if (strncmp(url_string, "dart-ext:", 9) != 0) {
623623
return DartUtils::NewError(
624624
"Native extensions must use the dart-ext: scheme.");
625625
}

runtime/bin/main.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ static bool OnIsolateInitialize(void** child_callback_data, char** error) {
275275
}
276276
} else {
277277
result = DartUtils::ResolveScript(Dart_NewStringFromCString(script_uri));
278-
if (Dart_IsError(result)) return result;
278+
if (Dart_IsError(result)) return result != nullptr;
279279

280280
if (isolate_group_data->kernel_buffer().get() != nullptr) {
281281
// Various core-library parts will send requests to the Loader to resolve
@@ -284,7 +284,7 @@ static bool OnIsolateInitialize(void** child_callback_data, char** error) {
284284
// bypasses normal source code loading paths that initialize it.
285285
const char* resolved_script_uri = NULL;
286286
result = Dart_StringToCString(result, &resolved_script_uri);
287-
if (Dart_IsError(result)) return result;
287+
if (Dart_IsError(result)) return result != nullptr;
288288
Loader::InitForSnapshot(resolved_script_uri, isolate_data);
289289
}
290290
}
@@ -661,7 +661,7 @@ static Dart_Isolate CreateIsolateGroupAndSetupHelper(
661661
}
662662
}
663663

664-
if (flags->copy_parent_code && callback_data) {
664+
if (flags->copy_parent_code && callback_data != nullptr) {
665665
auto parent_isolate_group_data =
666666
reinterpret_cast<IsolateData*>(callback_data)->isolate_group_data();
667667
parent_kernel_buffer = parent_isolate_group_data->kernel_buffer();

runtime/bin/main_options.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ bool Options::ProcessAbiVersionOption(const char* arg,
340340
return false;
341341
}
342342
int ver = 0;
343-
for (int i = 0; value[i]; ++i) {
343+
for (int i = 0; value[i] != '\0'; ++i) {
344344
if (value[i] >= '0' && value[i] <= '9') {
345345
ver = (ver * 10) + value[i] - '0';
346346
} else {

0 commit comments

Comments
 (0)