[COMPBATT] Use BATTERY_TAG_INVALID instead 0 when applicable

This commit is contained in:
Hervé Poussineau 2024-11-20 19:08:02 +01:00
parent 05ae94092e
commit 2d3f3a1613
2 changed files with 6 additions and 6 deletions

View file

@ -111,7 +111,7 @@ CompBattRecalculateTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension)
} }
/* No tag for this device extension, clear it */ /* No tag for this device extension, clear it */
DeviceExtension->Tag = 0; DeviceExtension->Tag = BATTERY_TAG_INVALID;
NextEntry = NextEntry->Flink; NextEntry = NextEntry->Flink;
} }
@ -161,7 +161,7 @@ CompBattQueryTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension,
} }
/* Do we have a tag now? */ /* Do we have a tag now? */
if ((DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED) && (DeviceExtension->Tag)) if ((DeviceExtension->Flags & COMPBATT_TAG_ASSIGNED) && DeviceExtension->Tag != BATTERY_TAG_INVALID)
{ {
/* Return the tag */ /* Return the tag */
*Tag = DeviceExtension->Tag; *Tag = DeviceExtension->Tag;
@ -170,7 +170,7 @@ CompBattQueryTag(IN PCOMPBATT_DEVICE_EXTENSION DeviceExtension,
else else
{ {
/* No tag */ /* No tag */
*Tag = 0; *Tag = BATTERY_TAG_INVALID;
Status = STATUS_NO_SUCH_DEVICE; Status = STATUS_NO_SUCH_DEVICE;
} }
@ -261,7 +261,7 @@ CompBattGetBatteryInformation(OUT PBATTERY_INFORMATION BatteryInfo,
InputBuffer.AtRate = 0; InputBuffer.AtRate = 0;
/* Make sure the battery has a tag */ /* Make sure the battery has a tag */
if (BatteryData->Tag) if (BatteryData->Tag != BATTERY_TAG_INVALID)
{ {
/* Do we already have the data? */ /* Do we already have the data? */
if (!(BatteryData->Flags & COMPBATT_BATTERY_INFORMATION_PRESENT)) if (!(BatteryData->Flags & COMPBATT_BATTERY_INFORMATION_PRESENT))
@ -419,7 +419,7 @@ CompBattGetBatteryGranularity(OUT PBATTERY_REPORTING_SCALE ReportingScale,
InputBuffer.InformationLevel = BatteryGranularityInformation; InputBuffer.InformationLevel = BatteryGranularityInformation;
/* Make sure the battery has a tag */ /* Make sure the battery has a tag */
if (BatteryData->Tag) if (BatteryData->Tag != BATTERY_TAG_INVALID)
{ {
/* Send the IOCTL to query the information */ /* Send the IOCTL to query the information */
RtlZeroMemory(&BatteryData->BatteryInformation, RtlZeroMemory(&BatteryData->BatteryInformation,

View file

@ -134,7 +134,7 @@ CompBattAddNewBattery(IN PUNICODE_STRING BatteryName,
{ {
/* Initialize the data and write the battery name */ /* Initialize the data and write the battery name */
RtlZeroMemory(BatteryData, sizeof(COMPBATT_BATTERY_DATA)); RtlZeroMemory(BatteryData, sizeof(COMPBATT_BATTERY_DATA));
BatteryData->Tag = 0; BatteryData->Tag = BATTERY_TAG_INVALID;
BatteryData->BatteryName.MaximumLength = BatteryName->Length; BatteryData->BatteryName.MaximumLength = BatteryName->Length;
BatteryData->BatteryName.Buffer = (PWCHAR)(BatteryData + 1); BatteryData->BatteryName.Buffer = (PWCHAR)(BatteryData + 1);
RtlCopyUnicodeString(&BatteryData->BatteryName, BatteryName); RtlCopyUnicodeString(&BatteryData->BatteryName, BatteryName);