Fix GN issues identified by MSVC static analysis. MSVC's /analyze identified two missing null checks because it noted that a pointer was null checked in one place but not another. After some study I determined that null checks are not necessary for these values so I removed them. Although isxdigit takes an int, the input must be an unsigned char or the behavior is undefined. I added the cast. I think this API is suboptimal. BUG=643842,427616 Review-Url: https://codereview.chromium.org/2384493003 Cr-Original-Commit-Position: refs/heads/master@{#421945} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: e23e7021f9a06d621088bc13856db9ba93c328c0
diff --git a/tools/gn/command_format.cc b/tools/gn/command_format.cc index dafba6e..282f567 100644 --- a/tools/gn/command_format.cc +++ b/tools/gn/command_format.cc
@@ -323,7 +323,7 @@ } void Printer::SortIfSourcesOrDeps(const BinaryOpNode* binop) { - if (binop && binop->comments() && !binop->comments()->before().empty() && + if (binop->comments() && !binop->comments()->before().empty() && binop->comments()->before()[0].value().as_string() == "# NOSORT") { // Allow disabling of sort for specific actions that might be // order-sensitive. @@ -746,7 +746,7 @@ const auto& list = func_call->args()->contents(); const ParseNode* end = func_call->args()->End(); - if (end && end->comments() && !end->comments()->before().empty()) + if (end->comments() && !end->comments()->before().empty()) force_multiline = true; // If there's before line comments, make sure we have a place to put them.