|
|
Created:
4 years ago by Roman Sorokin (ftl) Modified:
3 years, 11 months ago CC:
chromium-reviews, alemate+watch_chromium.org, achuith+watch_chromium.org, hashimoto+watch_chromium.org, oshima+watch_chromium.org Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionChromad: Switch AuthPolicyClient to use cros_system_api enums.
BUG=659732
TEST=manual
Committed: https://crrev.com/c36703e9325eeb51a1582043e2c536eb2078ad6b
Cr-Commit-Position: refs/heads/master@{#441026}
Patch Set 1 #
Total comments: 4
Patch Set 2 : Check for enum range in the D-BUS code. #Patch Set 3 : Check for enum range in the D-BUS code. #Patch Set 4 : Switch to new universal enum type. #
Total comments: 4
Patch Set 5 : Modify switch. Create helper function for getting D-BUS error. #Patch Set 6 : add return into case statement. #
Total comments: 2
Patch Set 7 : s/NOTREACHED/LOG(WARNING) #Patch Set 8 : Rebase #
Total comments: 2
Patch Set 9 : Move default to the end of switch. #
Dependent Patchsets: Messages
Total messages: 43 (25 generated)
rsorokin@chromium.org changed reviewers: + alemate@chromium.org, hashimoto@chromium.org
Alex, PTAL chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.{h,cc} Hashimoto, PTAL chromeos/dbus/*
lgtm with nits. https://codereview.chromium.org/2587993002/diff/1/chrome/browser/ui/webui/chr... File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc (right): https://codereview.chromium.org/2587993002/diff/1/chrome/browser/ui/webui/chr... chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:588: authpolicy::ADJoinErrorType code) { nit: please document here that code may be outside of authpolicy::ADJoinErrorType domain because this value actually comes from DBUS integer value . (Probably this is the reason you are using default: clause here.) https://codereview.chromium.org/2587993002/diff/1/chromeos/dbus/auth_policy_c... File chromeos/dbus/auth_policy_client.h (right): https://codereview.chromium.org/2587993002/diff/1/chromeos/dbus/auth_policy_c... chromeos/dbus/auth_policy_client.h:21: public: nit: please document here that error-code may be outside of authpolicy::ADJoinErrorType domain because this value actually comes from DBUS integer value .
rsorokin@chromium.org changed reviewers: + stevenjb@chromium.org - hashimoto@chromium.org
Hi Steven, PTAL at chromeos/dbus/*
https://codereview.chromium.org/2587993002/diff/1/chrome/browser/ui/webui/chr... File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc (right): https://codereview.chromium.org/2587993002/diff/1/chrome/browser/ui/webui/chr... chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:588: authpolicy::ADJoinErrorType code) { On 2016/12/21 14:45:30, Alexander Alekseev wrote: > nit: please document here that code may be outside of > authpolicy::ADJoinErrorType domain because this value actually comes from DBUS > integer value . (Probably this is the reason you are using default: clause > here.) authpolicy::ADJoinErrorType is a DBus constant, so that shouldn't be possible. If we are concerned about that, we could test for that when we cast the integer in the dbus code. We shouldn't have to document that in the implementation code, that kind of defeats the purpose of using an enum.
The CQ bit was checked by rsorokin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Hey Steven, PTAL. Thanks! https://codereview.chromium.org/2587993002/diff/1/chrome/browser/ui/webui/chr... File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc (right): https://codereview.chromium.org/2587993002/diff/1/chrome/browser/ui/webui/chr... chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:588: authpolicy::ADJoinErrorType code) { On 2016/12/21 18:12:11, stevenjb wrote: > On 2016/12/21 14:45:30, Alexander Alekseev wrote: > > nit: please document here that code may be outside of > > authpolicy::ADJoinErrorType domain because this value actually comes from DBUS > > integer value . (Probably this is the reason you are using default: clause > > here.) > > authpolicy::ADJoinErrorType is a DBus constant, so that shouldn't be possible. > If we are concerned about that, we could test for that when we cast the integer > in the dbus code. We shouldn't have to document that in the implementation code, > that kind of defeats the purpose of using an enum. > I added _COUNT member to the enum and check if the number we got from D-BUS is within range.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by rsorokin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc (right): https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:572: default: We should list the unhandled cases explicitly and return here and not have a default, then the compiler will complain if a new unhandled case is added. We can also add NOTREACHED() after the switch. https://codereview.chromium.org/2587993002/diff/60001/chromeos/dbus/auth_poli... File chromeos/dbus/auth_policy_client.cc (right): https://codereview.chromium.org/2587993002/diff/60001/chromeos/dbus/auth_poli... chromeos/dbus/auth_policy_client.cc:131: error = static_cast<authpolicy::ErrorType>(res); Rather than duplicate this logic, add a helper function: authpolicy::ErrorType error = GetErrorFromReader(reader);
The CQ bit was checked by rsorokin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Hey Steven, PTAL. Thanks! https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc (right): https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:572: default: On 2016/12/27 17:52:26, stevenjb wrote: > We should list the unhandled cases explicitly and return here and not have a > default, then the compiler will complain if a new unhandled case is added. We > can also add NOTREACHED() after the switch. I think it's better to put NOTREACHED() after the default statement. That way rolling out new cases from chromeos repo won't break chrome build. WDYT? https://codereview.chromium.org/2587993002/diff/60001/chromeos/dbus/auth_poli... File chromeos/dbus/auth_policy_client.cc (right): https://codereview.chromium.org/2587993002/diff/60001/chromeos/dbus/auth_poli... chromeos/dbus/auth_policy_client.cc:131: error = static_cast<authpolicy::ErrorType>(res); On 2016/12/27 17:52:26, stevenjb wrote: > Rather than duplicate this logic, add a helper function: > authpolicy::ErrorType error = GetErrorFromReader(reader); Done.
On 2016/12/28 11:04:09, Roman Sorokin wrote: > Hey Steven, PTAL. Thanks! > > https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... > File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc > (right): > > https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... > chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:572: > default: > On 2016/12/27 17:52:26, stevenjb wrote: > > We should list the unhandled cases explicitly and return here and not have a > > default, then the compiler will complain if a new unhandled case is added. We > > can also add NOTREACHED() after the switch. > > I think it's better to put NOTREACHED() after the default statement. That way > rolling out new cases from chromeos repo won't break chrome build. WDYT? > We generally avoid default specifically so that when new enums are added the code must be updated. That said, it does make a deps roll more complicated since the enum would need to be fixed at the same time. I suppose using default is fine then, but I wouldn't use NOTREACHED in that case since it would break Debug builds, I would use LOG(WARNING) instead.
https://codereview.chromium.org/2587993002/diff/100001/chrome/browser/ui/webu... File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc (right): https://codereview.chromium.org/2587993002/diff/100001/chrome/browser/ui/webu... chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:594: NOTREACHED(); As mentioned, either make this LOG(WARNING) or remove 'default'. Also, if we we handle 'default' we should probably still call 'invalidateAd'.
On 2016/12/28 18:09:33, stevenjb wrote: > On 2016/12/28 11:04:09, Roman Sorokin wrote: > > Hey Steven, PTAL. Thanks! > > > > > https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... > > File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc > > (right): > > > > > https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... > > chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:572: > > default: > > On 2016/12/27 17:52:26, stevenjb wrote: > > > We should list the unhandled cases explicitly and return here and not have a > > > default, then the compiler will complain if a new unhandled case is added. > We > > > can also add NOTREACHED() after the switch. > > > > I think it's better to put NOTREACHED() after the default statement. That way > > rolling out new cases from chromeos repo won't break chrome build. WDYT? > > > We generally avoid default specifically so that when new enums are added the > code must be updated. That said, it does make a deps roll more complicated since > the enum would need to be fixed at the same time. I suppose using default is > fine then, but I wouldn't use NOTREACHED in that case since it would break Debug > builds, I would use LOG(WARNING) instead. NOTREACHED should not break Debug builds. It would fail during the runtime. Am I wrong?
On 2016/12/28 20:04:22, Roman Sorokin wrote: > On 2016/12/28 18:09:33, stevenjb wrote: > > On 2016/12/28 11:04:09, Roman Sorokin wrote: > > > Hey Steven, PTAL. Thanks! > > > > > > > > > https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... > > > File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc > > > (right): > > > > > > > > > https://codereview.chromium.org/2587993002/diff/60001/chrome/browser/ui/webui... > > > chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:572: > > > default: > > > On 2016/12/27 17:52:26, stevenjb wrote: > > > > We should list the unhandled cases explicitly and return here and not have > a > > > > default, then the compiler will complain if a new unhandled case is added. > > We > > > > can also add NOTREACHED() after the switch. > > > > > > I think it's better to put NOTREACHED() after the default statement. That > way > > > rolling out new cases from chromeos repo won't break chrome build. WDYT? > > > > > We generally avoid default specifically so that when new enums are added the > > code must be updated. That said, it does make a deps roll more complicated > since > > the enum would need to be fixed at the same time. I suppose using default is > > fine then, but I wouldn't use NOTREACHED in that case since it would break > Debug > > builds, I would use LOG(WARNING) instead. > > NOTREACHED should not break Debug builds. It would fail during the runtime. Am I > wrong? I'm not sure how "should not break Debug builds" != "fail during runtime". NOTREACHED would break any developer running a Debug build if the new error were encountered. This may be unlikely since it is an error code, but it is still better practice to use LOG(WARNING) in this situation. NOTREACHED should only be used for code that should be logically impossible, e.g. falling through a switch statement for an enum without a 'default' case.
The CQ bit was checked by rsorokin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Hey Steven, PTAL. Thanks! https://codereview.chromium.org/2587993002/diff/100001/chrome/browser/ui/webu... File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc (right): https://codereview.chromium.org/2587993002/diff/100001/chrome/browser/ui/webu... chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:594: NOTREACHED(); On 2016/12/28 18:12:43, stevenjb wrote: > As mentioned, either make this LOG(WARNING) or remove 'default'. Also, if we we > handle 'default' we should probably still call 'invalidateAd'. > Done.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-device on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device/builds...) ios-device-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-device-xcode-...) ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...) ios-simulator-xcode-clang on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator-xco...)
The CQ bit was checked by rsorokin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
lgtm w/ comment or default moved to end of switch. https://codereview.chromium.org/2587993002/diff/140001/chrome/browser/ui/webu... File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc (right): https://codereview.chromium.org/2587993002/diff/140001/chrome/browser/ui/webu... chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:573: LOG(WARNING) << "Unhandled error code: " << code; default should still be after any cases. We could add a comment here calling out that this is falling through to call invalidateAd, but I think duplicating that code is better, especially since the comment does not apply for 'default'.
The CQ bit was checked by rsorokin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from alemate@chromium.org, stevenjb@chromium.org Link to the patchset: https://codereview.chromium.org/2587993002/#ps160001 (title: "Move default to the end of switch.")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2587993002/diff/140001/chrome/browser/ui/webu... File chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc (right): https://codereview.chromium.org/2587993002/diff/140001/chrome/browser/ui/webu... chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc:573: LOG(WARNING) << "Unhandled error code: " << code; On 2016/12/29 21:09:54, stevenjb wrote: > default should still be after any cases. We could add a comment here calling out > that this is falling through to call invalidateAd, but I think duplicating that > code is better, especially since the comment does not apply for 'default'. Done.
CQ is committing da patch. Bot data: {"patchset_id": 160001, "attempt_start_ts": 1483097132273290, "parent_rev": "1558c162f9b0b6f002d261c2226e05359b51c30b", "commit_rev": "0442c4d30d9a49e975df10310ada75bb162009c9"}
Message was sent while issue was closed.
Description was changed from ========== Chromad: Switch AuthPolicyClient to use cros_system_api enums. BUG=659732 TEST=manual ========== to ========== Chromad: Switch AuthPolicyClient to use cros_system_api enums. BUG=659732 TEST=manual Review-Url: https://codereview.chromium.org/2587993002 ==========
Message was sent while issue was closed.
Committed patchset #9 (id:160001)
Message was sent while issue was closed.
Description was changed from ========== Chromad: Switch AuthPolicyClient to use cros_system_api enums. BUG=659732 TEST=manual Review-Url: https://codereview.chromium.org/2587993002 ========== to ========== Chromad: Switch AuthPolicyClient to use cros_system_api enums. BUG=659732 TEST=manual Committed: https://crrev.com/c36703e9325eeb51a1582043e2c536eb2078ad6b Cr-Commit-Position: refs/heads/master@{#441026} ==========
Message was sent while issue was closed.
Patchset 9 (id:??) landed as https://crrev.com/c36703e9325eeb51a1582043e2c536eb2078ad6b Cr-Commit-Position: refs/heads/master@{#441026} |