Skip to content

Commit

Permalink
treewide: Replace deprecated logging macros
Browse files Browse the repository at this point in the history
Prefer the more readable avb_{debug,error,fatal}() macros to their
avb_*v() counterparts and remove the now unnecessary NULL sentinel.

Test: -
Change-Id: Ibaaff539cd9c112cb4c5cc65e53778568de82f0a
  • Loading branch information
ptosi authored and openvela-robot committed Nov 20, 2024
1 parent 592e186 commit 604a6d3
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 173 deletions.
2 changes: 1 addition & 1 deletion boot_control/boot_control_avb.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static unsigned int module_getCurrentSlot(boot_control_module_t* module) {
} else if (strcmp(propbuf, "_b") == 0) {
return 1;
} else {
avb_errorv("Unexpected slot suffix '", propbuf, "'.\n", NULL);
avb_error("Unexpected slot suffix '", propbuf, "'.\n");
return 0;
}
return 0;
Expand Down
7 changes: 3 additions & 4 deletions examples/uefi/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle,
}
boot_result =
uefi_avb_boot_kernel(ImageHandle, slot_data, additional_cmdline);
avb_fatalv("uefi_avb_boot_kernel() failed with error ",
uefi_avb_boot_kernel_result_to_string(boot_result),
"\n",
NULL);
avb_fatal("uefi_avb_boot_kernel() failed with error ",
uefi_avb_boot_kernel_result_to_string(boot_result),
"\n");
avb_slot_verify_data_free(slot_data);
avb_free(additional_cmdline);
break;
Expand Down
3 changes: 1 addition & 2 deletions examples/uefi/uefi_avb_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ UEFIAvbBootKernelResult uefi_avb_boot_kernel(EFI_HANDLE efi_image_handle,

boot = &slot_data->loaded_partitions[0];
if (avb_strcmp(boot->partition_name, "boot") != 0) {
avb_errorv(
"Unexpected partition name '", boot->partition_name, "'.\n", NULL);
avb_error("Unexpected partition name '", boot->partition_name, "'.\n");
ret = UEFI_AVB_BOOT_KERNEL_RESULT_ERROR_PARTITION_INVALID_FORMAT;
goto out;
}
Expand Down
186 changes: 79 additions & 107 deletions libavb/avb_slot_verify.c

Large diffs are not rendered by default.

26 changes: 11 additions & 15 deletions libavb_ab/avb_ab_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,12 @@ AvbABFlowResult avb_ab_flow(AvbABOps* ab_ops,
case AVB_SLOT_VERIFY_RESULT_ERROR_PUBLIC_KEY_REJECTED:
if (flags & AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR) {
/* Do nothing since we allow this. */
avb_debugv("Allowing slot ",
slot_suffixes[n],
" which verified "
"with result ",
avb_slot_verify_result_to_string(verify_result),
" because "
"AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR "
"is set.\n",
NULL);
avb_debug("Allowing slot ",
slot_suffixes[n],
" which verified with result ",
avb_slot_verify_result_to_string(verify_result),
" because AVB_SLOT_VERIFY_FLAGS_ALLOW_VERIFICATION_ERROR "
"is set.\n");
saw_and_allowed_verification_error = true;
} else {
set_slot_unbootable = true;
Expand All @@ -285,12 +282,11 @@ AvbABFlowResult avb_ab_flow(AvbABOps* ab_ops,
}

if (set_slot_unbootable) {
avb_errorv("Error verifying slot ",
slot_suffixes[n],
" with result ",
avb_slot_verify_result_to_string(verify_result),
" - setting unbootable.\n",
NULL);
avb_error("Error verifying slot ",
slot_suffixes[n],
" with result ",
avb_slot_verify_result_to_string(verify_result),
" - setting unbootable.\n");
slot_set_unbootable(&ab_data.slots[n]);
}
}
Expand Down
10 changes: 4 additions & 6 deletions libavb_user/avb_ops_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ static AvbIOResult read_from_partition(AvbOps* ops,
if (offset < 0) {
uint64_t partition_size;
if (ioctl(fd, BLKGETSIZE64, &partition_size) != 0) {
avb_errorv(
"Error getting size of \"", partition, "\" partition.\n", NULL);
avb_error("Error getting size of \"", partition, "\" partition.\n");
ret = AVB_IO_RESULT_ERROR_IO;
goto out;
}
Expand Down Expand Up @@ -194,7 +193,7 @@ static AvbIOResult write_to_partition(AvbOps* ops,

fd = open_partition(partition, O_WRONLY);
if (fd == -1) {
avb_errorv("Error opening \"", partition, "\" partition.\n", NULL);
avb_error("Error opening \"", partition, "\" partition.\n");
ret = AVB_IO_RESULT_ERROR_IO;
goto out;
}
Expand Down Expand Up @@ -273,15 +272,14 @@ static AvbIOResult get_size_of_partition(AvbOps* ops,

fd = open_partition(partition, O_WRONLY);
if (fd == -1) {
avb_errorv("Error opening \"", partition, "\" partition.\n", NULL);
avb_error("Error opening \"", partition, "\" partition.\n");
ret = AVB_IO_RESULT_ERROR_IO;
goto out;
}

if (out_size_in_bytes != NULL) {
if (ioctl(fd, BLKGETSIZE64, out_size_in_bytes) != 0) {
avb_errorv(
"Error getting size of \"", partition, "\" partition.\n", NULL);
avb_error("Error getting size of \"", partition, "\" partition.\n");
ret = AVB_IO_RESULT_ERROR_IO;
goto out;
}
Expand Down
32 changes: 13 additions & 19 deletions libavb_user/avb_user_verification.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,15 @@ static bool load_top_level_vbmeta_header(
&footer,
&num_read);
if (io_res != AVB_IO_RESULT_OK) {
avb_errorv("Error loading footer from partition '",
out_partition_name,
"'\n",
NULL);
avb_error(
"Error loading footer from partition '", out_partition_name, "'\n");
goto out;
}

if (avb_memcmp(footer.magic, AVB_FOOTER_MAGIC, AVB_FOOTER_MAGIC_LEN) != 0) {
avb_errorv("Data from '",
out_partition_name,
"' does not look like a vbmeta footer.\n",
NULL);
avb_error("Data from '",
out_partition_name,
"' does not look like a vbmeta footer.\n");
goto out;
}

Expand All @@ -111,8 +108,7 @@ static bool load_top_level_vbmeta_header(
}

if (io_res != AVB_IO_RESULT_OK) {
avb_errorv(
"Error loading from partition '", out_partition_name, "'\n", NULL);
avb_error("Error loading from partition '", out_partition_name, "'\n");
goto out;
}

Expand Down Expand Up @@ -141,10 +137,9 @@ bool avb_user_verification_get(AvbOps* ops,
}

if (avb_memcmp(vbmeta_image, AVB_MAGIC, AVB_MAGIC_LEN) != 0) {
avb_errorv("Data from '",
partition_name,
"' does not look like a vbmeta header.\n",
NULL);
avb_error("Data from '",
partition_name,
"' does not look like a vbmeta header.\n");
goto out;
}

Expand Down Expand Up @@ -180,10 +175,9 @@ bool avb_user_verification_set(AvbOps* ops,
}

if (avb_memcmp(vbmeta_image, AVB_MAGIC, AVB_MAGIC_LEN) != 0) {
avb_errorv("Data from '",
partition_name,
"' does not look like a vbmeta header.\n",
NULL);
avb_error("Data from '",
partition_name,
"' does not look like a vbmeta header.\n");
goto out;
}

Expand All @@ -203,7 +197,7 @@ bool avb_user_verification_set(AvbOps* ops,
AVB_VBMETA_IMAGE_HEADER_SIZE,
vbmeta_image);
if (io_res != AVB_IO_RESULT_OK) {
avb_errorv("Error writing to partition '", partition_name, "'\n", NULL);
avb_error("Error writing to partition '", partition_name, "'\n");
goto out;
}

Expand Down
32 changes: 13 additions & 19 deletions libavb_user/avb_user_verity.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,15 @@ static bool load_top_level_vbmeta_header(
&footer,
&num_read);
if (io_res != AVB_IO_RESULT_OK) {
avb_errorv("Error loading footer from partition '",
out_partition_name,
"'\n",
NULL);
avb_error(
"Error loading footer from partition '", out_partition_name, "'\n");
goto out;
}

if (avb_memcmp(footer.magic, AVB_FOOTER_MAGIC, AVB_FOOTER_MAGIC_LEN) != 0) {
avb_errorv("Data from '",
out_partition_name,
"' does not look like a vbmeta footer.\n",
NULL);
avb_error("Data from '",
out_partition_name,
"' does not look like a vbmeta footer.\n");
goto out;
}

Expand All @@ -111,8 +108,7 @@ static bool load_top_level_vbmeta_header(
}

if (io_res != AVB_IO_RESULT_OK) {
avb_errorv(
"Error loading from partition '", out_partition_name, "'\n", NULL);
avb_error("Error loading from partition '", out_partition_name, "'\n");
goto out;
}

Expand Down Expand Up @@ -141,10 +137,9 @@ bool avb_user_verity_get(AvbOps* ops,
}

if (avb_memcmp(vbmeta_image, AVB_MAGIC, AVB_MAGIC_LEN) != 0) {
avb_errorv("Data from '",
partition_name,
"' does not look like a vbmeta header.\n",
NULL);
avb_error("Data from '",
partition_name,
"' does not look like a vbmeta header.\n");
goto out;
}

Expand Down Expand Up @@ -179,10 +174,9 @@ bool avb_user_verity_set(AvbOps* ops,
}

if (avb_memcmp(vbmeta_image, AVB_MAGIC, AVB_MAGIC_LEN) != 0) {
avb_errorv("Data from '",
partition_name,
"' does not look like a vbmeta header.\n",
NULL);
avb_error("Data from '",
partition_name,
"' does not look like a vbmeta header.\n");
goto out;
}

Expand All @@ -202,7 +196,7 @@ bool avb_user_verity_set(AvbOps* ops,
AVB_VBMETA_IMAGE_HEADER_SIZE,
vbmeta_image);
if (io_res != AVB_IO_RESULT_OK) {
avb_errorv("Error writing to partition '", partition_name, "'\n", NULL);
avb_error("Error writing to partition '", partition_name, "'\n");
goto out;
}

Expand Down

0 comments on commit 604a6d3

Please sign in to comment.