Skip to content

Commit d2ae286

Browse files
committed
[DISKPART] Command function return EXIT_CODE instead of BOOL
This simplifies the implementation of the NOERR option.
1 parent e616f29 commit d2ae286

40 files changed

+520
-355
lines changed

base/system/diskpart/active.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <debug.h>
1313

1414

15-
BOOL
15+
EXIT_CODE
1616
active_main(
1717
_In_ INT argc,
1818
_In_ PWSTR *argv)
@@ -24,21 +24,21 @@ active_main(
2424
if (CurrentDisk == NULL)
2525
{
2626
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
27-
return TRUE;
27+
return EXIT_SUCCESS;
2828
}
2929

3030
if (CurrentPartition == NULL)
3131
{
3232
ConResPuts(StdOut, IDS_SELECT_NO_PARTITION);
33-
return TRUE;
33+
return EXIT_SUCCESS;
3434
}
3535

3636
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR)
3737
{
3838
if (CurrentPartition->Mbr.BootIndicator)
3939
{
4040
ConResPuts(StdOut, IDS_ACTIVE_ALREADY);
41-
return TRUE;
41+
return EXIT_SUCCESS;
4242
}
4343

4444
CurrentPartition->Mbr.BootIndicator = TRUE;
@@ -59,5 +59,5 @@ active_main(
5959
ConResPuts(StdOut, IDS_ACTIVE_NO_MBR);
6060
}
6161

62-
return TRUE;
62+
return EXIT_SUCCESS;
6363
}

base/system/diskpart/add.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
#include "diskpart.h"
1010

11-
BOOL add_main(INT argc, LPWSTR *argv)
11+
EXIT_CODE
12+
add_main(
13+
_In_ INT argc,
14+
_In_ PWSTR *argv)
1215
{
13-
return TRUE;
16+
return EXIT_SUCCESS;
1417
}

base/system/diskpart/assign.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define NDEBUG
1212
#include <debug.h>
1313

14-
BOOL
14+
EXIT_CODE
1515
assign_main(
1616
_In_ INT argc,
1717
_In_ LPWSTR *argv)
@@ -26,7 +26,7 @@ assign_main(
2626
if (CurrentVolume == NULL)
2727
{
2828
ConResPuts(StdOut, IDS_SELECT_NO_VOLUME);
29-
return TRUE;
29+
return EXIT_SUCCESS;
3030
}
3131

3232
for (i = 1; i < argc; i++)
@@ -54,7 +54,7 @@ assign_main(
5454
else
5555
{
5656
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
57-
return TRUE;
57+
return EXIT_SUCCESS;
5858
}
5959
}
6060
else if (HasPrefix(argv[i], L"mount=", &pszSuffix))
@@ -70,14 +70,14 @@ assign_main(
7070
else
7171
{
7272
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
73-
return TRUE;
73+
return EXIT_SUCCESS;
7474
}
7575
}
7676

7777
if (nExclusive > 1)
7878
{
7979
ConResPuts(StdErr, IDS_ERROR_INVALID_ARGS);
80-
return TRUE;
80+
return EXIT_SUCCESS;
8181
}
8282

8383
DPRINT1("VolumeName: %S\n", CurrentVolume->VolumeName);
@@ -91,13 +91,13 @@ assign_main(
9191
if ((DriveLetter < L'C') || (DriveLetter > L'Z'))
9292
{
9393
ConResPuts(StdOut, IDS_ASSIGN_INVALID_LETTER);
94-
return TRUE;
94+
return EXIT_SUCCESS;
9595
}
9696

9797
if (DriveLetter == CurrentVolume->DriveLetter)
9898
{
9999
ConResPuts(StdOut, IDS_ASSIGN_ALREADY_ASSIGNED);
100-
return TRUE;
100+
return EXIT_SUCCESS;
101101
}
102102
}
103103

@@ -108,7 +108,7 @@ assign_main(
108108
if (bResult == FALSE)
109109
{
110110
ConResPuts(StdOut, IDS_ASSIGN_FAIL);
111-
return TRUE;
111+
return EXIT_SUCCESS;
112112
}
113113

114114
CurrentVolume->DriveLetter = UNICODE_NULL;
@@ -122,7 +122,7 @@ assign_main(
122122
if (bResult == FALSE)
123123
{
124124
ConResPuts(StdOut, IDS_ASSIGN_FAIL);
125-
return TRUE;
125+
return EXIT_SUCCESS;
126126
}
127127

128128
CurrentVolume->DriveLetter = DriveLetter;
@@ -134,17 +134,17 @@ assign_main(
134134
if (bResult == FALSE)
135135
{
136136
ConResPuts(StdOut, IDS_ASSIGN_FAIL);
137-
return TRUE;
137+
return EXIT_SUCCESS;
138138
}
139139

140140
if (CurrentVolume->DriveLetter == UNICODE_NULL)
141141
{
142142
ConResPuts(StdOut, IDS_ASSIGN_NO_MORE_LETTER);
143-
return TRUE;
143+
return EXIT_SUCCESS;
144144
}
145145
}
146146

147147
ConResPuts(StdOut, IDS_REMOVE_SUCCESS);
148148

149-
return TRUE;
149+
return EXIT_SUCCESS;
150150
}

base/system/diskpart/attach.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
#include "diskpart.h"
1010

11-
BOOL attach_main(INT argc, LPWSTR *argv)
11+
EXIT_CODE
12+
attach_main(
13+
_In_ INT argc,
14+
_In_ PWSTR *argv)
1215
{
13-
return TRUE;
16+
return EXIT_SUCCESS;
1417
}

base/system/diskpart/attributes.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
#include "diskpart.h"
1010

11-
BOOL attributes_main(INT argc, LPWSTR *argv)
11+
EXIT_CODE
12+
attributes_main(
13+
_In_ INT argc,
14+
_In_ PWSTR *argv)
1215
{
13-
return TRUE;
16+
return EXIT_SUCCESS;
1417
}

base/system/diskpart/automount.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
#include <debug.h>
1313

1414

15-
BOOL
15+
EXIT_CODE
1616
automount_main(
17-
INT argc,
18-
LPWSTR *argv)
17+
_In_ INT argc,
18+
_In_ PWSTR *argv)
1919
{
2020
BOOL bDisable = FALSE, bEnable = FALSE, bScrub = FALSE;
2121
#if 0
@@ -134,5 +134,5 @@ automount_main(
134134
ConPuts(StdOut, L"\n");
135135
}
136136

137-
return TRUE;
137+
return EXIT_SUCCESS;
138138
}

base/system/diskpart/break.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
#include "diskpart.h"
1010

11-
BOOL break_main(INT argc, LPWSTR *argv)
11+
EXIT_CODE
12+
break_main(
13+
_In_ INT argc,
14+
_In_ PWSTR *argv)
1215
{
1316
ConPuts(StdOut, L"\nTODO: Add code later since Win 7 Home Premium doesn't have this feature.\n");
14-
return TRUE;
17+
return EXIT_SUCCESS;
1518
}

base/system/diskpart/clean.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <debug.h>
1313

1414

15-
BOOL
15+
EXIT_CODE
1616
clean_main(
1717
_In_ INT argc,
1818
_In_ PWSTR *argv)
@@ -37,15 +37,15 @@ clean_main(
3737
if (CurrentDisk == NULL)
3838
{
3939
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
40-
return TRUE;
40+
return EXIT_SUCCESS;
4141
}
4242

4343
/* Do not allow to clean the boot disk */
4444
if ((CurrentDisk->BiosFound == TRUE) &&
4545
(CurrentDisk->BiosDiskNumber == 0))
4646
{
4747
ConResPuts(StdOut, IDS_CLEAN_SYSTEM);
48-
return TRUE;
48+
return EXIT_SUCCESS;
4949
}
5050

5151
for (i = 1; i < argc; i++)
@@ -112,7 +112,7 @@ clean_main(
112112
if (CurrentDisk->LayoutBuffer == NULL)
113113
{
114114
DPRINT1("Failed to allocate the disk layout buffer!\n");
115-
return TRUE;
115+
return EXIT_SUCCESS;
116116
}
117117

118118
CurrentDisk->LayoutBuffer->PartitionStyle = PARTITION_STYLE_RAW;
@@ -246,5 +246,5 @@ clean_main(
246246
if (SectorsBuffer != NULL)
247247
RtlFreeHeap(RtlGetProcessHeap(), 0, SectorsBuffer);
248248

249-
return TRUE;
249+
return EXIT_SUCCESS;
250250
}

base/system/diskpart/compact.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88

99
#include "diskpart.h"
1010

11-
BOOL compact_main(INT argc, LPWSTR *argv)
11+
EXIT_CODE
12+
compact_main(
13+
_In_ INT argc,
14+
_In_ PWSTR *argv)
1215
{
13-
return 0;
16+
return EXIT_SUCCESS;
1417
}

base/system/diskpart/convert.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ CreateDisk(
8484
}
8585

8686

87-
BOOL
87+
EXIT_CODE
8888
ConvertGPT(
8989
_In_ INT argc,
9090
_In_ PWSTR *argv)
@@ -97,27 +97,27 @@ ConvertGPT(
9797
if (CurrentDisk == NULL)
9898
{
9999
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
100-
return TRUE;
100+
return EXIT_SUCCESS;
101101
}
102102

103103
if (CurrentDisk->PartitionStyle == PARTITION_STYLE_GPT)
104104
{
105105
ConResPuts(StdOut, IDS_CONVERT_GPT_ALREADY);
106-
return TRUE;
106+
return EXIT_SUCCESS;
107107
}
108108

109109
if (GetPrimaryPartitionCount(CurrentDisk) != 0)
110110
{
111111
ConResPuts(StdOut, IDS_CONVERT_GPT_NOT_EMPTY);
112-
return TRUE;
112+
return EXIT_SUCCESS;
113113
}
114114

115115
#if 0
116116
/* Fail if disk size is less than 128MB */
117117
if (CurrentDisk->SectorCount.QuadPart * CurrentDisk->BytesPerSector < 128ULL * 1024ULL * 1024ULL)
118118
{
119119
ConResPuts(StdOut, IDS_CONVERT_GPT_TOO_SMALL);
120-
return TRUE;
120+
return EXIT_SUCCESS;
121121
}
122122
#endif
123123

@@ -129,7 +129,7 @@ ConvertGPT(
129129
if (!NT_SUCCESS(Status))
130130
{
131131
DPRINT1("CreateDisk() failed!\n");
132-
return TRUE;
132+
return EXIT_SUCCESS;
133133
}
134134

135135
CurrentDisk->StartSector.QuadPart = AlignDown(CurrentDisk->LayoutBuffer->Gpt.StartingUsableOffset.QuadPart / CurrentDisk->BytesPerSector,
@@ -140,11 +140,11 @@ ConvertGPT(
140140
ScanForUnpartitionedGptDiskSpace(CurrentDisk);
141141
ConResPuts(StdOut, IDS_CONVERT_GPT_SUCCESS);
142142

143-
return TRUE;
143+
return EXIT_SUCCESS;
144144
}
145145

146146

147-
BOOL
147+
EXIT_CODE
148148
ConvertMBR(
149149
_In_ INT argc,
150150
_In_ PWSTR *argv)
@@ -157,20 +157,20 @@ ConvertMBR(
157157
if (CurrentDisk == NULL)
158158
{
159159
ConResPuts(StdOut, IDS_SELECT_NO_DISK);
160-
return TRUE;
160+
return EXIT_SUCCESS;
161161
}
162162

163163
if ((CurrentDisk->PartitionStyle == PARTITION_STYLE_MBR) ||
164164
(CurrentDisk->PartitionStyle == PARTITION_STYLE_RAW))
165165
{
166166
ConResPuts(StdOut, IDS_CONVERT_MBR_ALREADY);
167-
return TRUE;
167+
return EXIT_SUCCESS;
168168
}
169169

170170
if (GetPrimaryPartitionCount(CurrentDisk) != 0)
171171
{
172172
ConResPuts(StdOut, IDS_CONVERT_MBR_NOT_EMPTY);
173-
return TRUE;
173+
return EXIT_SUCCESS;
174174
}
175175

176176
DiskInfo.PartitionStyle = PARTITION_STYLE_MBR;
@@ -180,7 +180,7 @@ ConvertMBR(
180180
if (!NT_SUCCESS(Status))
181181
{
182182
DPRINT1("CreateDisk() failed!\n");
183-
return TRUE;
183+
return EXIT_SUCCESS;
184184
}
185185

186186
CurrentDisk->StartSector.QuadPart = (ULONGLONG)CurrentDisk->SectorAlignment;
@@ -189,5 +189,5 @@ ConvertMBR(
189189
ScanForUnpartitionedMbrDiskSpace(CurrentDisk);
190190
ConResPuts(StdOut, IDS_CONVERT_MBR_SUCCESS);
191191

192-
return TRUE;
192+
return EXIT_SUCCESS;
193193
}

0 commit comments

Comments
 (0)