Skip to content

Commit 38b39f8

Browse files
committed
PhInitFormat inline funcs and cleanup
1 parent 4cf3b77 commit 38b39f8

File tree

3 files changed

+292
-112
lines changed

3 files changed

+292
-112
lines changed

SystemInformer/devprv.c

Lines changed: 29 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,76 +3004,47 @@ PPH_STRING PhpDevSysPowerPowerDataString(
30043004
PPH_STRING capabilities;
30053005
PPH_STRING string;
30063006

3007-
PhInitFormatSR(&format[count], *PhpDevPowerStateString(PowerData->PD_MostRecentPowerState));
3008-
count++; // TODO(jxy-s) if PhInitFormat were inline instead of macros we could clean this up
3007+
PhInitFormatSR(&format[count++], *PhpDevPowerStateString(PowerData->PD_MostRecentPowerState));
30093008
if (PowerData->PD_D1Latency)
30103009
{
3011-
PhInitFormatS(&format[count], L", ");
3012-
count++;
3013-
PhInitFormatU(&format[count], PowerData->PD_D1Latency);
3014-
count++;
3015-
PhInitFormatS(&format[count], L" D1 latency");
3016-
count++;
3010+
PhInitFormatS(&format[count++], L", ");
3011+
PhInitFormatU(&format[count++], PowerData->PD_D1Latency);
3012+
PhInitFormatS(&format[count++], L" D1 latency");
30173013
}
30183014
if (PowerData->PD_D2Latency)
30193015
{
3020-
PhInitFormatS(&format[count], L", ");
3021-
count++;
3022-
PhInitFormatU(&format[count], PowerData->PD_D2Latency);
3023-
count++;
3024-
PhInitFormatS(&format[count], L" D2 latency");
3025-
count++;
3016+
PhInitFormatS(&format[count++], L", ");
3017+
PhInitFormatU(&format[count++], PowerData->PD_D2Latency);
3018+
PhInitFormatS(&format[count++], L" D2 latency");
30263019
}
30273020
if (PowerData->PD_D2Latency)
30283021
{
3029-
PhInitFormatS(&format[count], L", ");
3030-
count++;
3031-
PhInitFormatU(&format[count], PowerData->PD_D3Latency);
3032-
count++;
3033-
PhInitFormatS(&format[count], L" D3 latency");
3034-
count++;
3022+
PhInitFormatS(&format[count++], L", ");
3023+
PhInitFormatU(&format[count++], PowerData->PD_D3Latency);
3024+
PhInitFormatS(&format[count++], L" D3 latency");
30353025
}
3036-
PhInitFormatS(&format[count], L", S0->");
3037-
count++;
3038-
PhInitFormatSR(&format[count], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemWorking]));
3039-
count++;
3040-
PhInitFormatS(&format[count], L", S1->");
3041-
count++;
3042-
PhInitFormatSR(&format[count], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemSleeping1]));
3043-
count++;
3044-
PhInitFormatS(&format[count], L", S2->");
3045-
count++;
3046-
PhInitFormatSR(&format[count], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemSleeping2]));
3047-
count++;
3048-
PhInitFormatS(&format[count], L", S3->");
3049-
count++;
3050-
PhInitFormatSR(&format[count], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemSleeping3]));
3051-
count++;
3052-
PhInitFormatS(&format[count], L", S4->");
3053-
count++;
3054-
PhInitFormatSR(&format[count], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemHibernate]));
3055-
count++;
3056-
PhInitFormatS(&format[count], L", S5->");
3057-
count++;
3058-
PhInitFormatSR(&format[count], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemShutdown]));
3059-
count++;
3026+
PhInitFormatS(&format[count++], L", S0->");
3027+
PhInitFormatSR(&format[count++], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemWorking]));
3028+
PhInitFormatS(&format[count++], L", S1->");
3029+
PhInitFormatSR(&format[count++], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemSleeping1]));
3030+
PhInitFormatS(&format[count++], L", S2->");
3031+
PhInitFormatSR(&format[count++], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemSleeping2]));
3032+
PhInitFormatS(&format[count++], L", S3->");
3033+
PhInitFormatSR(&format[count++], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemSleeping3]));
3034+
PhInitFormatS(&format[count++], L", S4->");
3035+
PhInitFormatSR(&format[count++], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemHibernate]));
3036+
PhInitFormatS(&format[count++], L", S5->");
3037+
PhInitFormatSR(&format[count++], *PhpDevPowerStateString(PowerData->PD_PowerStateMapping[PowerSystemShutdown]));
30603038
capabilities = PhGetAccessString(PowerData->PD_Capabilities, (PVOID)pdCap, RTL_NUMBER_OF(pdCap));
3061-
PhInitFormatS(&format[count], L", (");
3062-
count++;
3063-
PhInitFormatSR(&format[count], capabilities->sr);
3064-
count++;
3065-
PhInitFormatS(&format[count], L" (0x");
3066-
count++;
3067-
PhInitFormatX(&format[count], PowerData->PD_Capabilities);
3068-
count++;
3069-
PhInitFormatS(&format[count], L"))");
3070-
count++;
3039+
PhInitFormatS(&format[count++], L", (");
3040+
PhInitFormatSR(&format[count++], capabilities->sr);
3041+
PhInitFormatS(&format[count++], L" (0x");
3042+
PhInitFormatX(&format[count++], PowerData->PD_Capabilities);
3043+
PhInitFormatS(&format[count++], L"))");
30713044
if (PowerData->PD_DeepestSystemWake != PowerSystemUnspecified)
30723045
{
3073-
PhInitFormatS(&format[count], L", Deepest wake ");
3074-
count++;
3075-
PhInitFormatSR(&format[count], *PhpDevSysPowerStateString(PowerData->PD_DeepestSystemWake));
3076-
count++;
3046+
PhInitFormatS(&format[count++], L", Deepest wake ");
3047+
PhInitFormatSR(&format[count++], *PhpDevSysPowerStateString(PowerData->PD_DeepestSystemWake));
30773048
}
30783049

30793050
string = PhFormat(format, count, 20);

phlib/hndlinfo.c

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,92 +1594,76 @@ NTSTATUS PhpGetBestObjectName(
15941594

15951595
if (commsInfo.ClientCommunicationPort.OwnerProcessId == processInfo.UniqueProcessId)
15961596
{
1597-
PhInitFormatS(&format[formatCount], L"Client: ");
1598-
formatCount++;
1597+
PhInitFormatS(&format[formatCount++], L"Client: ");
15991598
if (commsInfo.ServerCommunicationPort.OwnerProcessId)
16001599
{
1601-
PhInitFormatS(&format[formatCount], L"Connection to ");
1602-
formatCount++;
1600+
PhInitFormatS(&format[formatCount++], L"Connection to ");
16031601
clientId.UniqueProcess = commsInfo.ServerCommunicationPort.OwnerProcessId;
16041602
clientId.UniqueThread = 0;
16051603
name = PhStdGetClientIdName(&clientId);
16061604
}
16071605
else if (commsInfo.ClientCommunicationPort.ConnectionRefused)
16081606
{
1609-
PhInitFormatS(&format[formatCount], L"Refused ");
1610-
formatCount++;
1607+
PhInitFormatS(&format[formatCount++], L"Refused ");
16111608
}
16121609
else if (commsInfo.ClientCommunicationPort.Closed)
16131610
{
1614-
PhInitFormatS(&format[formatCount], L"Closed ");
1615-
formatCount++;
1611+
PhInitFormatS(&format[formatCount++], L"Closed ");
16161612
}
16171613
else if (commsInfo.ClientCommunicationPort.Disconnected)
16181614
{
1619-
PhInitFormatS(&format[formatCount], L"Disconnected ");
1620-
formatCount++;
1615+
PhInitFormatS(&format[formatCount++], L"Disconnected ");
16211616
}
16221617
else if (commsInfo.ClientCommunicationPort.ConnectionPending)
16231618
{
1624-
PhInitFormatS(&format[formatCount], L"Pending ");
1625-
formatCount++;
1619+
PhInitFormatS(&format[formatCount++], L"Pending ");
16261620
}
16271621
}
16281622
else if (commsInfo.ServerCommunicationPort.OwnerProcessId == processInfo.UniqueProcessId)
16291623
{
1630-
PhInitFormatS(&format[formatCount], L"Server: ");
1631-
formatCount++;
1624+
PhInitFormatS(&format[formatCount++], L"Server: ");
16321625
if (commsInfo.ClientCommunicationPort.OwnerProcessId)
16331626
{
1634-
PhInitFormatS(&format[formatCount], L" Connection from ");
1635-
formatCount++;
1627+
PhInitFormatS(&format[formatCount++], L" Connection from ");
16361628
clientId.UniqueProcess = commsInfo.ClientCommunicationPort.OwnerProcessId;
16371629
clientId.UniqueThread = 0;
16381630
name = PhStdGetClientIdName(&clientId);
16391631
}
16401632
else if (commsInfo.ClientCommunicationPort.ConnectionRefused)
16411633
{
1642-
PhInitFormatS(&format[formatCount], L"Refused ");
1643-
formatCount++;
1634+
PhInitFormatS(&format[formatCount++], L"Refused ");
16441635
}
16451636
else if (commsInfo.ServerCommunicationPort.Closed)
16461637
{
1647-
PhInitFormatS(&format[formatCount], L"Closed ");
1648-
formatCount++;
1638+
PhInitFormatS(&format[formatCount++], L"Closed ");
16491639
}
16501640
else if (commsInfo.ServerCommunicationPort.Disconnected)
16511641
{
1652-
PhInitFormatS(&format[formatCount], L"Disconnected ");
1653-
formatCount++;
1642+
PhInitFormatS(&format[formatCount++], L"Disconnected ");
16541643
}
16551644
else if (commsInfo.ServerCommunicationPort.ConnectionPending)
16561645
{
1657-
PhInitFormatS(&format[formatCount], L"Pending ");
1658-
formatCount++;
1646+
PhInitFormatS(&format[formatCount++], L"Pending ");
16591647
}
16601648
}
16611649
else if (commsInfo.ConnectionPort.OwnerProcessId == processInfo.UniqueProcessId)
16621650
{
1663-
PhInitFormatS(&format[formatCount], L"Connection: ");
1664-
formatCount++;
1651+
PhInitFormatS(&format[formatCount++], L"Connection: ");
16651652
}
16661653

16671654
if (name)
16681655
{
1669-
PhInitFormatSR(&format[formatCount], name->sr);
1670-
formatCount++;
1656+
PhInitFormatSR(&format[formatCount++], name->sr);
16711657

16721658
if (namesInfo && namesInfo->ConnectionPort.Length > 0)
16731659
{
1674-
PhInitFormatS(&format[formatCount], L" on ");
1675-
formatCount++;
1660+
PhInitFormatS(&format[formatCount++], L" on ");
16761661
}
16771662
}
16781663

16791664
if (namesInfo && namesInfo->ConnectionPort.Length > 0)
16801665
{
1681-
PhInitFormatUCS(&format[formatCount], &namesInfo->ConnectionPort);
1682-
formatCount++;
1666+
PhInitFormatUCS(&format[formatCount++], &namesInfo->ConnectionPort);
16831667
}
16841668

16851669
if (formatCount > 0)

0 commit comments

Comments
 (0)