Commit 944c28c5 authored by brucedawson's avatar brucedawson Committed by Commit bot

Rewriting patch logic without the comma operator.

When running /analyze on all of Chrome there were three warnings about
using the comma operator in a tested expression. One was a genuine bug
and the other two were in UncompressAndPatchChromeArchive. Rewriting
to use nested if statements resolves these warnings (getting the count
to zero) and makes the code clearer.

Resolving the warning is not crucial, but it makes it easier to make a
zero-tolerance policy for that warning and thus avoid future bugs.
Plus, it makes the setup code easier to read.

The warnings are:

src\chrome\installer\setup\setup_main.cc(174) : warning C6319: Use of the comma-operator in a tested expression causes the left argument to be ignored when it has no side-effects.
src\chrome\installer\setup\setup_main.cc(176) : warning C6319: Use of the comma-operator in a tested expression causes the left argument to be ignored when it has no side-effects.

The bug that was found through this warning, which could eventually
have been very serious, was fixed here:
https://codereview.chromium.org/678193003

BUG=427616

Review URL: https://codereview.chromium.org/893703004

Cr-Commit-Position: refs/heads/master@{#314389}
parent 959eaea4
......@@ -170,15 +170,15 @@ bool UncompressAndPatchChromeArchive(
archive_helper->set_patch_source(patch_source);
// Try courgette first. Failing that, try bspatch.
if ((installer_state.UpdateStage(installer::ENSEMBLE_PATCHING),
!archive_helper->EnsemblePatch()) &&
(installer_state.UpdateStage(installer::BINARY_PATCHING),
!archive_helper->BinaryPatch())) {
*install_status = installer::APPLY_DIFF_PATCH_FAILED;
installer_state.WriteInstallerResult(*install_status,
IDS_INSTALL_UNCOMPRESSION_FAILED_BASE,
NULL);
return false;
installer_state.UpdateStage(installer::ENSEMBLE_PATCHING);
if (!archive_helper->EnsemblePatch()) {
installer_state.UpdateStage(installer::BINARY_PATCHING);
if (!archive_helper->BinaryPatch()) {
*install_status = installer::APPLY_DIFF_PATCH_FAILED;
installer_state.WriteInstallerResult(
*install_status, IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL);
return false;
}
}
*archive_type = installer::INCREMENTAL_ARCHIVE_TYPE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment