Attention is currently required from: Anastasia Klimchuk, Peter Marheine.
Hello Anastasia Klimchuk, Peter Marheine, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/86875?usp=email
to look at the new patch set (#10).
The following approvals got outdated and were removed:
Verified+1 by build bot (Jenkins)
Change subject: libflashrom: Update the API for Logger Callback
......................................................................
libflashrom: Update the API for Logger Callback
The initial implementation does not account for user_data, requiring
the calling application to use a global scope. This may lead to issues
related to object lifecycle management and other architectural
concerns.
This patch adds user_data to the user’s log callback. Moreover, it
performs message formatting, so the application only needs to pass
the formatted string to the selected output.
The change does not break the existing logging API but extends it.
A new API version is introduced with the v2 suffix.
Testing: Both unit tests and CLI tools serve as libflashrom clients.
All unit tests run successfully.
Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Signed-off-by: Dmitry Zhadinets <dzhadinets(a)gmail.com>
---
M include/flash.h
M include/libflashrom.h
M libflashrom.c
M libflashrom.map
M meson.build
M meson_options.txt
A tests/libflashrom.c
M tests/meson.build
M tests/tests.c
M tests/tests.h
10 files changed, 157 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/75/86875/10
--
To view, visit https://review.coreboot.org/c/flashrom/+/86875?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Gerrit-Change-Number: 86875
Gerrit-PatchSet: 10
Gerrit-Owner: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Attention is currently required from: Anastasia Klimchuk, Peter Marheine.
Dmitry Zhadinets has posted comments on this change by Dmitry Zhadinets. ( https://review.coreboot.org/c/flashrom/+/86875?usp=email )
Change subject: libflashrom: Update the API for Logger Callback
......................................................................
Patch Set 9:
(1 comment)
File libflashrom.c:
https://review.coreboot.org/c/flashrom/+/86875/comment/cd1fad7d_64ad61c1?us… :
PS4, Line 59: /* Dynamic messages and double formatting may not be ideal,
: as they are slow. It would be better to limit the message
: size to a fixed value (e.g., char message[1024] = {0};). */
> Returning an error seems like an okay start, but in practical terms that's nearly the same as silent […]
I did. I agree that truncation is better then nothing but ....
If the user will really want to handle long messages he will not be ably to do it.
Only recompilation or using the old approach. because the user does not control it.
--
To view, visit https://review.coreboot.org/c/flashrom/+/86875?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Gerrit-Change-Number: 86875
Gerrit-PatchSet: 9
Gerrit-Owner: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Comment-Date: Sun, 30 Mar 2025 23:43:38 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Comment-In-Reply-To: Peter Marheine <pmarheine(a)chromium.org>
Attention is currently required from: Anastasia Klimchuk, Dmitry Zhadinets.
Hello Anastasia Klimchuk, Peter Marheine, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/86875?usp=email
to look at the new patch set (#9).
The following approvals got outdated and were removed:
Code-Review+2 by Anastasia Klimchuk, Verified+1 by build bot (Jenkins)
Change subject: libflashrom: Update the API for Logger Callback
......................................................................
libflashrom: Update the API for Logger Callback
The initial implementation does not account for user_data, requiring
the calling application to use a global scope. This may lead to issues
related to object lifecycle management and other architectural
concerns.
This patch adds user_data to the user’s log callback. Moreover, it
performs message formatting, so the application only needs to pass
the formatted string to the selected output.
The change does not break the existing logging API but extends it.
A new API version is introduced with the v2 suffix.
Testing: Both unit tests and CLI tools serve as libflashrom clients.
All unit tests run successfully.
Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Signed-off-by: Dmitry Zhadinets <dzhadinets(a)gmail.com>
---
M include/flash.h
M include/libflashrom.h
M libflashrom.c
M libflashrom.map
M meson.build
M meson_options.txt
A tests/libflashrom.c
M tests/meson.build
M tests/tests.c
M tests/tests.h
10 files changed, 154 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/75/86875/9
--
To view, visit https://review.coreboot.org/c/flashrom/+/86875?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Gerrit-Change-Number: 86875
Gerrit-PatchSet: 9
Gerrit-Owner: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Attention is currently required from: Dmitry Zhadinets.
Peter Marheine has posted comments on this change by Dmitry Zhadinets. ( https://review.coreboot.org/c/flashrom/+/86875?usp=email )
Change subject: libflashrom: Update the API for Logger Callback
......................................................................
Patch Set 8:
(1 comment)
File libflashrom.c:
https://review.coreboot.org/c/flashrom/+/86875/comment/c9766ae2_273eecd4?us… :
PS4, Line 59: /* Dynamic messages and double formatting may not be ideal,
: as they are slow. It would be better to limit the message
: size to a fixed value (e.g., char message[1024] = {0};). */
> Peter, I wanted to check, do you agree with how this ended up looking like? No dynamic allocation, h […]
Returning an error seems like an okay start, but in practical terms that's nearly the same as silently dropping the message because most uses of logging don't bother to check the return value (and I think that's reasonable because checking it would lead to much messier code).
As a compromise, I'd suggest truncating the message and if it does get truncated then also log a note that the previous message was truncated. To give users a knob to twiddle in case they really want to be able to handle long messages, I would also make the buffer size a compile-time option.
```
char message[LOG_MESSAGE_LENGTH_LIMIT];
int actual_len = vsnprintf(message, sizeof(message), format, args);
global_log_callback_v2(level, message, global_log_user_data);
if (actual_len >= sizeof(message)) {
snprintf(message, sizeof(message), "%d characters were truncated from the previous log message", actual_len - sizeof(message) + 1);
global_log_callback_v2(FLASHROM_MSG_WARN, message, global_log_user_data);
}
```
--
To view, visit https://review.coreboot.org/c/flashrom/+/86875?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Gerrit-Change-Number: 86875
Gerrit-PatchSet: 8
Gerrit-Owner: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Comment-Date: Sun, 30 Mar 2025 22:49:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Comment-In-Reply-To: Peter Marheine <pmarheine(a)chromium.org>
Attention is currently required from: Dmitry Zhadinets, Peter Marheine.
Anastasia Klimchuk has posted comments on this change by Dmitry Zhadinets. ( https://review.coreboot.org/c/flashrom/+/86875?usp=email )
Change subject: libflashrom: Update the API for Logger Callback
......................................................................
Patch Set 8: Code-Review+2
(1 comment)
File libflashrom.c:
https://review.coreboot.org/c/flashrom/+/86875/comment/3668c62c_79a7c0a7?us… :
PS4, Line 59: /* Dynamic messages and double formatting may not be ideal,
: as they are slow. It would be better to limit the message
: size to a fixed value (e.g., char message[1024] = {0};). */
> Done
Peter, I wanted to check, do you agree with how this ended up looking like? No dynamic allocation, however no silent dropping either (an error is returned)
--
To view, visit https://review.coreboot.org/c/flashrom/+/86875?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Gerrit-Change-Number: 86875
Gerrit-PatchSet: 8
Gerrit-Owner: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Comment-Date: Sun, 30 Mar 2025 12:33:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Comment-In-Reply-To: Peter Marheine <pmarheine(a)chromium.org>
Attention is currently required from: Anastasia Klimchuk, Peter Marheine.
Dmitry Zhadinets has posted comments on this change by Dmitry Zhadinets. ( https://review.coreboot.org/c/flashrom/+/86875?usp=email )
Change subject: libflashrom: Update the API for Logger Callback
......................................................................
Patch Set 7:
(2 comments)
File libflashrom.c:
https://review.coreboot.org/c/flashrom/+/86875/comment/93e4c07f_b8ed4089?us… :
PS7, Line 75: (unsigned)size+1
> in here, you need spaces between +, […]
Done
https://review.coreboot.org/c/flashrom/+/86875/comment/c4b7e52a_8e48b5cc?us… :
PS7, Line 75: if (((unsigned)size+1) > sizeof(message))
: return -ERANGE;
> Thank you so much for writing in that much details, this is helpful! I read everything and did lots […]
Done
--
To view, visit https://review.coreboot.org/c/flashrom/+/86875?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Gerrit-Change-Number: 86875
Gerrit-PatchSet: 7
Gerrit-Owner: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Comment-Date: Sat, 29 Mar 2025 22:21:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Comment-In-Reply-To: Anastasia Klimchuk <aklm(a)chromium.org>
Attention is currently required from: Dmitry Zhadinets, Peter Marheine.
Hello Anastasia Klimchuk, Peter Marheine, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/flashrom/+/86875?usp=email
to look at the new patch set (#8).
The following approvals got outdated and were removed:
Verified+1 by build bot (Jenkins)
Change subject: libflashrom: Update the API for Logger Callback
......................................................................
libflashrom: Update the API for Logger Callback
The initial implementation does not account for user_data, requiring
the calling application to use a global scope. This may lead to issues
related to object lifecycle management and other architectural
concerns.
This patch adds user_data to the user’s log callback. Moreover, it
performs message formatting, so the application only needs to pass
the formatted string to the selected output.
The change does not break the existing logging API but extends it.
A new API version is introduced with the v2 suffix.
Testing: Both unit tests and CLI tools serve as libflashrom clients.
All unit tests run successfully.
Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Signed-off-by: Dmitry Zhadinets <dzhadinets(a)gmail.com>
---
M include/flash.h
M include/libflashrom.h
M libflashrom.c
M libflashrom.map
A tests/libflashrom.c
M tests/meson.build
M tests/tests.c
M tests/tests.h
8 files changed, 149 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/75/86875/8
--
To view, visit https://review.coreboot.org/c/flashrom/+/86875?usp=email
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: flashrom
Gerrit-Branch: main
Gerrit-Change-Id: Iea738bd371fa3d69b9cf222c89ee67490d30af39
Gerrit-Change-Number: 86875
Gerrit-PatchSet: 8
Gerrit-Owner: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org>
Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Attention: Dmitry Zhadinets <dzhadinets(a)gmail.com>
Gerrit-Attention: Peter Marheine <pmarheine(a)chromium.org>