[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [XENBUS PATCH 2/2] Be more tolerant of RealTimeIsUniversal values
status = SystemGetTimeInformation(); if (!NT_SUCCESS(status)) Error("Cannot read RealTimeIsUniversal, clock may be incorrect!\n");
doesnt log the error code, and still returns STATUS_SUCCESS from this function (SystemInitialize).
Owen
On Wed, Aug 13, 2025 at 5:12 PM Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx> wrote:
On 13/08/2025 18:09, Owen Smith wrote:
>
>
> On Wed, Aug 13, 2025 at 2:32 PM Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx> wrote:
>
>
> - status = RegistryQueryDwordValue(Key, "RealTimeIsUniversal",
> - &RealTimeIsUniversal);
> - if (!NT_SUCCESS(status)) {
> - if (status != STATUS_OBJECT_NAME_NOT_FOUND)
> - goto fail2;
> + status = RegistryQueryDwordValue(Key, "RealTimeIsUniversal",
> &ValueDword);
> + if (status == STATUS_OBJECT_NAME_NOT_FOUND) {
> + Context->RealTimeIsUniversal = FALSE;
> + goto done;
> + } else if (NT_SUCCESS(status)) {
> + Context->RealTimeIsUniversal = !!ValueDword;
> + goto done;
> + }
>
> - RealTimeIsUniversal = 0;
> + status = RegistryQueryQwordValue(Key, "RealTimeIsUniversal",
> &ValueQword);
> + if (NT_SUCCESS(status)) {
> + Context->RealTimeIsUniversal = !!ValueQword;
> + goto done;
> }
>
> - Context->RealTimeIsUniversal = RealTimeIsUniversal ? TRUE : FALSE;
> + status = STATUS_UNSUCCESSFUL;
> + Context->RealTimeIsUniversal = FALSE;
>
> +done:
> Info("%s\n", Context->RealTimeIsUniversal ? "TRUE" : "FALSE");
>
> The logic here seems more complicated than required. Would something like
>
> status = RegistryQueryDwordValue(Key, "RealTimeIsUniversal",
> &ValueDword);
> if (NT_SUCCESS(status)) {
> Context->RealTimeIsUniversal = !!ValueDword;
> goto done;
> }
>
> status = RegistryQueryQwordValue(Key, "RealTimeIsUniversal",
> &ValueQword);
> if (NT_SUCCESS(status)) {
> Context->RealTimeIsUniversal = !!ValueQword;
> goto done;
> }
>
> Context->RealTimeIsUniversal = FALSE;
>
> done:
> Info("%s\n", Context->RealTimeIsUniversal ? "TRUE" : "FALSE");
>
> be cleaner?
>
> Owen
>
I didn't want SystemGetTimeInformation to error out when the
RealTimeIsUniversal value is absent since its status code is used later
on for error reporting. But I can also ignore the status code of
SystemGetTimeInformation instead. What do you prefer?
Ngoc Tu Dinh | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|