Skip to content

Commit 76e5143

Browse files
committed
[IPCONFIG] Print proper error messages and more TCHAR fixes
1 parent e5b3533 commit 76e5143

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

base/applications/network/ipconfig/ipconfig.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ _Ret_opt_z_ PWSTR timeToStr(_In_ time_t TimeStamp)
174174
TotalCchSize = DateCchSize + TimeCchSize;
175175

176176
/* Allocate buffer and format datetime string */
177-
DateTimeString = (PTSTR)HeapAlloc(ProcessHeap, 0, TotalCchSize * sizeof(WCHAR));
177+
DateTimeString = (PWSTR)HeapAlloc(ProcessHeap, 0, TotalCchSize * sizeof(WCHAR));
178178
if (!DateTimeString)
179179
{
180180
return NULL;
@@ -201,7 +201,9 @@ _Ret_opt_z_ PWSTR timeToStr(_In_ time_t TimeStamp)
201201
}
202202

203203

204-
VOID DoFormatMessage(LONG ErrorCode)
204+
VOID
205+
DoFormatMessage(
206+
_In_ LONG ErrorCode)
205207
{
206208
LPVOID lpMsgBuf;
207209
//DWORD ErrorCode;
@@ -575,7 +577,7 @@ ShowInfo(
575577
{
576578
pszDomainName = HeapAlloc(ProcessHeap,
577579
0,
578-
dwDomainNameSize * sizeof(TCHAR));
580+
dwDomainNameSize * sizeof(CHAR));
579581
if (pszDomainName != NULL)
580582
GetComputerNameExA(ComputerNameDnsDomain,
581583
pszDomainName,
@@ -859,7 +861,7 @@ Release(
859861
pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
860862
if (pAdapterInfo == NULL)
861863
{
862-
printf("memory allocation error");
864+
DoFormatMessage(ERROR_NOT_ENOUGH_MEMORY);
863865
return;
864866
}
865867

@@ -965,7 +967,7 @@ Renew(
965967
pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
966968
if (pAdapterInfo == NULL)
967969
{
968-
printf("memory allocation error");
970+
DoFormatMessage(ERROR_NOT_ENOUGH_MEMORY);
969971
return;
970972
}
971973

@@ -1258,7 +1260,7 @@ SetClassId(
12581260
pAdapterInfo = (IP_ADAPTER_INFO *)HeapAlloc(ProcessHeap, 0, adaptOutBufLen);
12591261
if (pAdapterInfo == NULL)
12601262
{
1261-
printf("memory allocation error");
1263+
DoFormatMessage(ERROR_NOT_ENOUGH_MEMORY);
12621264
return;
12631265
}
12641266

0 commit comments

Comments
 (0)