Hello Vadim Bendebury,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/flashrom/+/38673
to review the following change.
Change subject: [WIP] Add .clang-format to help with patch formatting
......................................................................
[WIP] Add .clang-format to help with patch formatting
This is based on CB:38208 by Vadim, but with a few added changes.
Here is the original commit message.
This is a copy from the coreboot tree, could be tweaked to better
match the flashrom tree if there are any differences.
Once this file is in place a script could be deployed which would
format only new/changed lines in git patches.
Change-Id: I1fe22809c4a2d73fa02f4de55290d990a9750b86
Signed-off-by: Vadim Bendebury <vbendeb(a)chromium.org>
Signed-off-by: David Hendricks <david.hendricks(a)gmail.com>
---
A .clang-format
1 file changed, 21 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/73/38673/1
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..45c116b
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,21 @@
+BasedOnStyle: LLVM
+Language: Cpp
+IndentWidth: 8
+UseTab: Always
+BreakBeforeBraces: Linux
+AllowShortIfStatementsOnASingleLine: false
+IndentCaseLabels: false
+SortIncludes: false
+ContinuationIndentWidth: 8
+ColumnLimit: 112
+AlwaysBreakBeforeMultilineStrings: true
+AllowShortLoopsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: false
+AlignEscapedNewlinesLeft: false
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AlignAfterOpenBracket: true
+SpaceAfterCStyleCast: false
+MaxEmptyLinesToKeep: 2
+BreakBeforeBinaryOperators: NonAssignment
+BreakStringLiterals: false
--
To view, visit https://review.coreboot.org/c/flashrom/+/38673
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I1fe22809c4a2d73fa02f4de55290d990a9750b86
Gerrit-Change-Number: 38673
Gerrit-PatchSet: 1
Gerrit-Owner: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Vadim Bendebury <vbendeb(a)chromium.org>
Gerrit-MessageType: newchange
David Hendricks has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/37407 )
Change subject: print.c: Fix alignment in print_supported_boards_helper()
......................................................................
print.c: Fix alignment in print_supported_boards_helper()
Commit 61e16e5 eliminated some duplicate logic for printing test status,
but in doing so introduced a regression where some entries in `flashrom
-L` output became unaligned.
Up until then, it was assumed that the status field will always be
8-wide, including space for padding. This patch fixes alignment when
using test_state_to_text() by making the padding consistent with other
fields where a for-loop is used to pad the field up to a maximum width.
Change-Id: Ie0a0b45c6466d14447aca443c2697e2048c6ef14
Signed-off-by: David Hendricks <david.hendricks(a)gmail.com>
---
M flash.h
M print.c
2 files changed, 29 insertions(+), 14 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/07/37407/1
diff --git a/flash.h b/flash.h
index 1a9bd9f..e7b1c89 100644
--- a/flash.h
+++ b/flash.h
@@ -145,10 +145,11 @@
enum test_state {
OK = 0,
- NT = 1, /* Not tested */
- BAD, /* Known to not work */
- DEP, /* Support depends on configuration (e.g. Intel flash descriptor) */
- NA, /* Not applicable (e.g. write support on ROM chips) */
+ NT = 1, /* Not tested */
+ BAD, /* Known to not work */
+ DEP, /* Support depends on configuration (e.g. Intel flash descriptor) */
+ NA, /* Not applicable (e.g. write support on ROM chips) */
+ TEST_STATE_END, /* Not a test state, just an indicator of how many are defined. */
};
#define TEST_UNTESTED (struct tested){ .probe = NT, .read = NT, .erase = NT, .write = NT }
diff --git a/print.c b/print.c
index 6a7ff5d..e5be6b6 100644
--- a/print.c
+++ b/print.c
@@ -35,6 +35,20 @@
}
}
+static size_t max_test_state_len(void)
+{
+ int i;
+ size_t max_len;
+
+ for (i = max_len = 0; i < TEST_STATE_END; i++) {
+ size_t len = strlen(test_state_to_text(i));
+ if (len > max_len)
+ max_len = len;
+ }
+
+ return max_len;
+}
+
static int print_supported_chips(void)
{
const char *delim = "/";
@@ -388,8 +402,12 @@
for (i = strlen("Board"); i < maxboardlen; i++)
msg_ginfo(" ");
- msg_ginfo("Status Required value for\n");
- for (i = 0; i < maxvendorlen + maxboardlen + strlen("Status "); i++)
+ msg_ginfo("Status");
+ for (i = strlen("Status"); i < max_test_state_len(); i++)
+ msg_ginfo(" ");
+
+ msg_ginfo("Required value for\n");
+ for (i = 0; i < maxvendorlen + maxboardlen + max_test_state_len(); i++)
msg_ginfo(" ");
msg_ginfo("-p internal:mainboard=\n");
@@ -401,14 +419,10 @@
for (i = 0; i < maxboardlen - strlen(b->name); i++)
msg_ginfo(" ");
- switch (b->working) {
- case OK: msg_ginfo("OK "); break;
- case NT: msg_ginfo("NT "); break;
- case DEP: msg_ginfo("DEP "); break;
- case NA: msg_ginfo("N/A "); break;
- case BAD:
- default: msg_ginfo("BAD "); break;
- }
+ const char *test_state = test_state_to_text(b->working);
+ msg_ginfo("%s", test_state);
+ for (i = 0; i < max_test_state_len() - strlen(test_state); i++)
+ msg_ginfo(" ");
for (e = board_matches; e->vendor_name != NULL; e++) {
if (strcmp(e->vendor_name, b->vendor)
--
To view, visit https://review.coreboot.org/c/flashrom/+/37407
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Ie0a0b45c6466d14447aca443c2697e2048c6ef14
Gerrit-Change-Number: 37407
Gerrit-PatchSet: 1
Gerrit-Owner: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-MessageType: newchange