From 6ab32ec3d0e0ce2767e127b10784952e820834e6 Mon Sep 17 00:00:00 2001 From: Maciek Malik <142581992+0xMMBD@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:09:22 +0200 Subject: [PATCH] Formatting fixes (#12) --- libsol/common_byte_strings.h | 6 +++--- libsol/compute_budget_instruction.c | 14 ++++++++++---- libsol/compute_budget_instruction.h | 2 +- libsol/instruction_test.c | 14 +++++--------- libsol/system_instruction.c | 3 +-- libsol/transaction_printers.c | 9 +++++---- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/libsol/common_byte_strings.h b/libsol/common_byte_strings.h index b38c675b..6c0bf00c 100644 --- a/libsol/common_byte_strings.h +++ b/libsol/common_byte_strings.h @@ -77,9 +77,9 @@ 0x7c, 0x7c, 0x35, 0xb5, 0xdd, 0xbc, 0x92, 0xbb, 0x81, 0xe4, 0x1f, 0xa8, 0x40, 0x41, 0x05, \ 0x44, 0x8d -#define PROGRAM_ID_COMPUTE_BUDGET /* "ComputeBudget111111111111111111111111111111" */ \ - 0x03, 0x06, 0x46, 0x6f, 0xe5, 0x21, 0x17, 0x32, 0xff, 0xec, 0xad, 0xba, 0x72, 0xc3, \ - 0x9b, 0xe7, 0xbc, 0x8c, 0xe5, 0xbb, 0xc5, 0xf7, 0x12, 0x6b, 0x2c, 0x43, 0x9b, 0x3a, 0x40, 0x00, \ +#define PROGRAM_ID_COMPUTE_BUDGET /* "ComputeBudget111111111111111111111111111111" */ \ + 0x03, 0x06, 0x46, 0x6f, 0xe5, 0x21, 0x17, 0x32, 0xff, 0xec, 0xad, 0xba, 0x72, 0xc3, 0x9b, \ + 0xe7, 0xbc, 0x8c, 0xe5, 0xbb, 0xc5, 0xf7, 0x12, 0x6b, 0x2c, 0x43, 0x9b, 0x3a, 0x40, 0x00, \ 0x00, 0x00 // Sysvars diff --git a/libsol/compute_budget_instruction.c b/libsol/compute_budget_instruction.c index bb06dd4a..0d16ab04 100644 --- a/libsol/compute_budget_instruction.c +++ b/libsol/compute_budget_instruction.c @@ -38,13 +38,16 @@ static int parse_unit_price_instruction(Parser* parse, ComputeBudgetChangeUnitPr return 0; } -static int parse_loaded_accounts_data_size_limit(Parser* parse, ComputeBudgetSetLoadedAccountsDataSizeLimitInfo* info) { +static int parse_loaded_accounts_data_size_limit( + Parser* parse, + ComputeBudgetSetLoadedAccountsDataSizeLimitInfo* info) { BAIL_IF(parse_u32(parse, &info->units)); return 0; } -static int print_compute_budget_unit_price(ComputeBudgetChangeUnitPriceInfo* info, const PrintConfig* print_config) { +static int print_compute_budget_unit_price(ComputeBudgetChangeUnitPriceInfo* info, + const PrintConfig* print_config) { UNUSED(print_config); SummaryItem* item; @@ -55,7 +58,8 @@ static int print_compute_budget_unit_price(ComputeBudgetChangeUnitPriceInfo* inf return 0; } -static int print_compute_budget_unit_limit(ComputeBudgetChangeUnitLimitInfo* info, const PrintConfig* print_config) { +static int print_compute_budget_unit_limit(ComputeBudgetChangeUnitLimitInfo* info, + const PrintConfig* print_config) { UNUSED(print_config); SummaryItem* item; @@ -92,7 +96,9 @@ int parse_compute_budget_instructions(const Instruction* instruction, ComputeBud case ComputeBudgetChangeUnitPrice: return parse_unit_price_instruction(&parser, &info->change_unit_price); case ComputeBudgetSetLoadedAccountsDataSizeLimit: - return parse_loaded_accounts_data_size_limit(&parser, &info->set_loaded_accounts_data_size_limit); + return parse_loaded_accounts_data_size_limit( + &parser, + &info->set_loaded_accounts_data_size_limit); default: return 1; } diff --git a/libsol/compute_budget_instruction.h b/libsol/compute_budget_instruction.h index 3648da0c..7ac61b4f 100644 --- a/libsol/compute_budget_instruction.h +++ b/libsol/compute_budget_instruction.h @@ -26,7 +26,7 @@ typedef struct ComputeBudgetChangeUnitPriceInfo { uint64_t units; } ComputeBudgetChangeUnitPriceInfo; -typedef struct ComputeBudgetSetLoadedAccountsDataSizeLimitInfo{ +typedef struct ComputeBudgetSetLoadedAccountsDataSizeLimitInfo { uint32_t units; } ComputeBudgetSetLoadedAccountsDataSizeLimitInfo; diff --git a/libsol/instruction_test.c b/libsol/instruction_test.c index 63838f28..63f23df2 100644 --- a/libsol/instruction_test.c +++ b/libsol/instruction_test.c @@ -140,7 +140,7 @@ void test_static_brief_initializer_macros() { assert(memcmp(&stake_test, &stake_expect, sizeof(InstructionBrief)) == 0); } -void test_instruction_info_matches_brief_constants(){ +void test_instruction_info_matches_brief_constants() { { InstructionInfo info = {.kind = ProgramIdSerumAssertOwner}; InstructionBrief brief_pass = {.program_id = ProgramIdSerumAssertOwner}; @@ -160,14 +160,10 @@ void test_instruction_info_matches_brief_constants(){ } } -void test_instruction_compute_budget_matches_brief(){ - InstructionInfo info = { - .kind = ProgramIdComputeBudget, - .compute_budget = { - .kind = ComputeBudgetChangeUnitLimit, - .change_unit_price = {.units = 0xAABBCCDD} - } - }; +void test_instruction_compute_budget_matches_brief() { + InstructionInfo info = {.kind = ProgramIdComputeBudget, + .compute_budget = {.kind = ComputeBudgetChangeUnitLimit, + .change_unit_price = {.units = 0xAABBCCDD}}}; { InstructionBrief brief_pass = {.program_id = ProgramIdComputeBudget, diff --git a/libsol/system_instruction.c b/libsol/system_instruction.c index 599bf9c5..bf5ae87f 100644 --- a/libsol/system_instruction.c +++ b/libsol/system_instruction.c @@ -273,8 +273,7 @@ static int print_system_transfer_info(const SystemTransferInfo* info, return 0; } -int print_system_prefund_for_split(const SystemInfo* info, - const PrintConfig* print_config) { +int print_system_prefund_for_split(const SystemInfo* info, const PrintConfig* print_config) { if (print_config->expert_mode) { const SystemTransferInfo* transfer_info = &info->transfer; SummaryItem* item; diff --git a/libsol/transaction_printers.c b/libsol/transaction_printers.c index ea1f615c..d8d1ded4 100644 --- a/libsol/transaction_printers.c +++ b/libsol/transaction_printers.c @@ -652,12 +652,12 @@ static int print_transaction_nonce_processed(const PrintConfig* print_config, // System allocate/assign have no interesting info, print // stake split as if it were a single instruction return print_stake_info(&infos[2]->stake, print_config); - } else if(is_stake_split_with_seed_v1_3(infos, infos_length)) { + } else if (is_stake_split_with_seed_v1_3(infos, infos_length)) { return print_prefunded_split_with_seed(print_config, infos, infos_length); } break; case 4: - if(is_stake_split_v1_3(infos, infos_length)) { + if (is_stake_split_v1_3(infos, infos_length)) { return print_prefunded_split(print_config, infos, infos_length); } break; @@ -683,8 +683,9 @@ int print_transaction(const PrintConfig* print_config, if (infos_length > 1) { // Iterate over infos and print compute budget instructions and offset pointers - // Handle ComputeBudget instructions first due to tech limitations of the print_transaction_nonce_processed. - // We can get one or 4 ComputeBudget instructions in a single transaction, so we are not able to handle it in a static switch case. + // Handle ComputeBudget instructions first due to tech limitations of the + // print_transaction_nonce_processed. We can get one or 4 ComputeBudget instructions in a + // single transaction, so we are not able to handle it in a static switch case. size_t infos_length_initial = infos_length; for (size_t info_idx = 0; info_idx < infos_length_initial; ++info_idx) { InstructionInfo* instruction_info = infos[0];