shill: Fix misleading error log in Device::SetEnabled.

There is a conditional error line in Device::SetEnabled that shouldn't
send an error log if an enable is in progress. The code checks for
Error::kOperationInitiated but not for Error::kInProgress, while the
code path usually prefers the latter.

BUG=chromium:271505
TEST=shill shouldn't log "Enable failed, but no way to report the
failure.", if an enable operation is already in progress.

Change-Id: I9b75097e052438b4dd0e96f44bb5c867dfd3e9d0
Reviewed-on: https://gerrit.chromium.org/gerrit/65617
Reviewed-by: Ben Chan <benchan@chromium.org>
Tested-by: Arman Uguray <armansito@chromium.org>
Commit-Queue: Arman Uguray <armansito@chromium.org>
diff --git a/device.cc b/device.cc
index f3054ed..20f24b3 100644
--- a/device.cc
+++ b/device.cc
@@ -993,7 +993,16 @@
   SLOG(Device, 2) << __func__ << "(" << enable << ")";
   Error error;
   SetEnabledInternal(enable, false, &error, ResultCallback());
-  LOG_IF(ERROR, error.IsFailure() && !error.IsOngoing())
+
+  // SetEnabledInternal might fail here if there is an unfinished enable or
+  // disable operation. Don't log error in this case, as this method is only
+  // called when the underlying device is already in the target state and the
+  // pending operation should eventually bring the device to the expected
+  // state.
+  LOG_IF(ERROR,
+         error.IsFailure() &&
+         !error.IsOngoing() &&
+         error.type() != Error::kInProgress)
       << "Enabled failed, but no way to report the failure.";
 }