@@ -470,7 +470,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
470470 if (entry -> call )
471471 Print (L"internal call yes\n" );
472472
473- if (entry -> tries_left != ( UINTN ) - 1 )
473+ if (entry -> tries_left != UINTN_MAX )
474474 Print (L"counting boots yes\n"
475475 "tries done %u\n"
476476 "tries left %u\n"
@@ -1077,7 +1077,7 @@ static VOID config_entry_parse_tries(
10771077 CHAR16 * file ,
10781078 CHAR16 * suffix ) {
10791079
1080- UINTN left = ( UINTN ) - 1 , done = ( UINTN ) - 1 , factor = 1 , i , next_left , next_done ;
1080+ UINTN left = UINTN_MAX , done = UINTN_MAX , factor = 1 , i , next_left , next_done ;
10811081 _cleanup_freepool_ CHAR16 * prefix = NULL ;
10821082
10831083 /*
@@ -1114,46 +1114,46 @@ static VOID config_entry_parse_tries(
11141114 switch (file [i ]) {
11151115
11161116 case '+' :
1117- if (left == ( UINTN ) - 1 ) /* didn't read at least one digit for 'left'? */
1117+ if (left == UINTN_MAX ) /* didn't read at least one digit for 'left'? */
11181118 return ;
11191119
1120- if (done == ( UINTN ) - 1 ) /* no 'done' counter? If so, it's equivalent to 0 */
1120+ if (done == UINTN_MAX ) /* no 'done' counter? If so, it's equivalent to 0 */
11211121 done = 0 ;
11221122
11231123 goto good ;
11241124
11251125 case '-' :
1126- if (left == ( UINTN ) - 1 ) /* didn't parse any digit yet? */
1126+ if (left == UINTN_MAX ) /* didn't parse any digit yet? */
11271127 return ;
11281128
1129- if (done != ( UINTN ) - 1 ) /* already encountered a dash earlier? */
1129+ if (done != UINTN_MAX ) /* already encountered a dash earlier? */
11301130 return ;
11311131
11321132 /* So we encountered a dash. This means this counter is of the form +LEFT-DONE. Let's assign
11331133 * what we already parsed to 'done', and start fresh for the 'left' part. */
11341134
11351135 done = left ;
1136- left = ( UINTN ) - 1 ;
1136+ left = UINTN_MAX ;
11371137 factor = 1 ;
11381138 break ;
11391139
11401140 case '0' ...'9' : {
11411141 UINTN new_factor ;
11421142
1143- if (left == ( UINTN ) - 1 )
1143+ if (left == UINTN_MAX )
11441144 left = file [i ] - '0' ;
11451145 else {
11461146 UINTN new_left , digit ;
11471147
11481148 digit = file [i ] - '0' ;
1149- if (digit > ( UINTN ) -1 / factor ) /* overflow check */
1149+ if (digit > UINTN_MAX / factor ) /* overflow check */
11501150 return ;
11511151
11521152 new_left = left + digit * factor ;
11531153 if (new_left < left ) /* overflow check */
11541154 return ;
11551155
1156- if (new_left == ( UINTN ) - 1 ) /* don't allow us to be confused */
1156+ if (new_left == UINTN_MAX ) /* don't allow us to be confused */
11571157 return ;
11581158 }
11591159
@@ -1197,7 +1197,7 @@ static VOID config_entry_bump_counters(
11971197 UINTN file_info_size , a , b ;
11981198 EFI_STATUS r ;
11991199
1200- if (entry -> tries_left == ( UINTN ) - 1 )
1200+ if (entry -> tries_left == UINTN_MAX )
12011201 return ;
12021202
12031203 if (!entry -> path || !entry -> current_name || !entry -> next_name )
@@ -1275,8 +1275,8 @@ static VOID config_entry_add_from_file(
12751275 entry = AllocatePool (sizeof (ConfigEntry ));
12761276
12771277 * entry = (ConfigEntry ) {
1278- .tries_done = ( UINTN ) - 1 ,
1279- .tries_left = ( UINTN ) - 1 ,
1278+ .tries_done = UINTN_MAX ,
1279+ .tries_left = UINTN_MAX ,
12801280 };
12811281
12821282 while ((line = line_get_key_value (content , (CHAR8 * )" \t" , & pos , & key , & value ))) {
@@ -1482,8 +1482,8 @@ static INTN config_entry_compare(ConfigEntry *a, ConfigEntry *b) {
14821482 if (r != 0 )
14831483 return r ;
14841484
1485- if (a -> tries_left == ( UINTN ) - 1 ||
1486- b -> tries_left == ( UINTN ) - 1 )
1485+ if (a -> tries_left == UINTN_MAX ||
1486+ b -> tries_left == UINTN_MAX )
14871487 return 0 ;
14881488
14891489 /* If both items have boot counting, and otherwise are identical, put the entry with more tries left last */
@@ -1701,8 +1701,8 @@ static BOOLEAN config_entry_add_call(
17011701 .title = StrDuplicate (title ),
17021702 .call = call ,
17031703 .no_autoselect = TRUE,
1704- .tries_done = ( UINTN ) - 1 ,
1705- .tries_left = ( UINTN ) - 1 ,
1704+ .tries_done = UINTN_MAX ,
1705+ .tries_left = UINTN_MAX ,
17061706 };
17071707
17081708 config_add_entry (config , entry );
@@ -1730,8 +1730,8 @@ static ConfigEntry *config_entry_add_loader(
17301730 .loader = StrDuplicate (loader ),
17311731 .id = StrDuplicate (id ),
17321732 .key = key ,
1733- .tries_done = ( UINTN ) - 1 ,
1734- .tries_left = ( UINTN ) - 1 ,
1733+ .tries_done = UINTN_MAX ,
1734+ .tries_left = UINTN_MAX ,
17351735 };
17361736
17371737 StrLwr (entry -> id );
@@ -1971,9 +1971,9 @@ static VOID config_load_xbootldr(
19711971 EFI_HANDLE * device ) {
19721972
19731973 EFI_DEVICE_PATH * partition_path , * disk_path , * copy ;
1974- UINT32 found_partition_number = ( UINT32 ) - 1 ;
1975- UINT64 found_partition_start = ( UINT64 ) - 1 ;
1976- UINT64 found_partition_size = ( UINT64 ) - 1 ;
1974+ UINT32 found_partition_number = UINT32_MAX ;
1975+ UINT64 found_partition_start = UINT64_MAX ;
1976+ UINT64 found_partition_size = UINT64_MAX ;
19771977 UINT8 found_partition_signature [16 ] = {};
19781978 EFI_HANDLE new_device ;
19791979 EFI_FILE * root_dir ;
@@ -2053,7 +2053,7 @@ static VOID config_load_xbootldr(
20532053 continue ;
20542054
20552055 /* Calculate CRC check */
2056- c = ~crc32_exclude_offset (( UINT32 ) - 1 ,
2056+ c = ~crc32_exclude_offset (UINT32_MAX ,
20572057 (const UINT8 * ) & gpt_header_buffer ,
20582058 h -> Header .HeaderSize ,
20592059 OFFSETOF (EFI_PARTITION_TABLE_HEADER , Header .CRC32 ),
@@ -2087,7 +2087,7 @@ static VOID config_load_xbootldr(
20872087 continue ;
20882088
20892089 /* Calculate CRC of entries array, too */
2090- c = ~crc32 (( UINT32 ) - 1 , entries , sz );
2090+ c = ~crc32 (UINT32_MAX , entries , sz );
20912091 if (c != h -> PartitionEntryArrayCRC32 )
20922092 continue ;
20932093
0 commit comments