Skip to contentSkip to conversation

e2fsck: map PROMPT_* values to prompt messages

PATCH Applied Andreas Dilger 3 participants 6 messages Dec 8, 2021 – May 3, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e2fsck: map PROMPT_* values to prompt messages

It isn't totally clear when searching the code for PROMPT_* constants from problem codes where these messages come from. Similarly, there isn't a direct mapping from the prompt string to the constant.

Add comments that make this mapping more clear.

---
 e2fsck/problem.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
e2fsck/problem.c +23 -23
index 757b5d56..2d02468c 100644
@@ -50,29 +50,29 @@
  * to fix a problem.
  */
 static const char *prompt[] = {
-	N_("(no prompt)"),	/* 0 */
-	N_("Fix"),		/* 1 */
-	N_("Clear"),		/* 2 */
-	N_("Relocate"),		/* 3 */
-	N_("Allocate"),		/* 4 */
-	N_("Expand"),		/* 5 */
-	N_("Connect to /lost+found"), /* 6 */
-	N_("Create"),		/* 7 */
-	N_("Salvage"),		/* 8 */
-	N_("Truncate"),		/* 9 */
-	N_("Clear inode"),	/* 10 */
-	N_("Abort"),		/* 11 */
-	N_("Split"),		/* 12 */
-	N_("Continue"),		/* 13 */
-	N_("Clone multiply-claimed blocks"), /* 14 */
-	N_("Delete file"),	/* 15 */
-	N_("Suppress messages"),/* 16 */
-	N_("Unlink"),		/* 17 */
-	N_("Clear HTree index"),/* 18 */
-	N_("Recreate"),		/* 19 */
-	N_("Optimize"),		/* 20 */
-	N_("Clear flag"),	/* 21 */
-	"",			/* 22 */
+	N_("(no prompt)"),			/* PROMPT_NONE		=  0 */
+	N_("Fix"),				/* PROMPT_FIX		=  1 */
+	N_("Clear"),				/* PROMPT_CLEAR		=  2 */
+	N_("Relocate"),				/* PROMPT_RELOCATE	=  3 */
+	N_("Allocate"),				/* PROMPT_CREATE	=  4 */
+	N_("Expand"),				/* PROMPT_EXPAND	=  5 */
+	N_("Connect to /lost+found"),		/* PROMPT_CONNECT	=  6 */
+	N_("Create"),				/* PROMPT_CREATE	=  7 */
+	N_("Salvage"),				/* PROMPT_SALVAGE	=  8 */
+	N_("Truncate"),				/* PROMPT_TRUNCATE	=  9 */
+	N_("Clear inode"),			/* PROMPT_CLEAR_INODE	= 10 */
+	N_("Abort"),				/* PROMPT_ABORT		= 11 */
+	N_("Split"),				/* PROMPT_SPLIT		= 12 */
+	N_("Continue"),				/* PROMPT_CONTINUE	= 13 */
+	N_("Clone multiply-claimed blocks"),	/* PROMPT_CLONE		= 14 */
+	N_("Delete file"),			/* PROMPT_DELETE	= 15 */
+	N_("Suppress messages"),		/* PROMPT_SUPPRESS	= 16 */
+	N_("Unlink"),				/* PROMPT_UNLINK	= 17 */
+	N_("Clear HTree index"),		/* PROMPT_CLEAR_HTREE	= 18 */
+	N_("Recreate"),				/* PROMPT_RECREATE	= 19 */
+	N_("Optimize"),				/* PROMPT_OPTIMIZE	= 20 */
+	N_("Clear flag"),			/* PROMPT_CLEAR_FLAG	= 21 */
+	"",					/* PROMPT_NULL		= 22 */
 };
 
 /*
Signature · 1 line
2.25.1
#1 lore raw
Quoted 34 lines · Andreas Dilger

It isn't totally clear when searching the code for PROMPT_* constants from problem codes where these messages come from. Similarly, there isn't a direct mapping from the prompt string to the constant.

Add comments that make this mapping more clear.

---
 e2fsck/problem.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
e2fsck/problem.c +0 -14
index 757b5d56..2d02468c 100644
@@ -50,29 +50,29 @@
  * to fix a problem.
  */
 static const char *prompt[] = {
-	N_("(no prompt)"),	/* 0 */
-	N_("Fix"),		/* 1 */
-	N_("Clear"),		/* 2 */
-	N_("Relocate"),		/* 3 */
-	N_("Allocate"),		/* 4 */
-	N_("Expand"),		/* 5 */
-	N_("Connect to /lost+found"), /* 6 */
-	N_("Create"),		/* 7 */
-	N_("Salvage"),		/* 8 */
-	N_("Truncate"),		/* 9 */
-	N_("Clear inode"),	/* 10 */
-	N_("Abort"),		/* 11 */
-	N_("Split"),		/* 12 */
-	N_("Continue"),		/* 13 */

e2fsck/problem.c line 53

Quoted 10 lines
e2fsck/problem.c +1 -9
-	N_("Clone multiply-claimed blocks"), /* 14 */
-	N_("Delete file"),	/* 15 */
-	N_("Suppress messages"),/* 16 */
-	N_("Unlink"),		/* 17 */
-	N_("Clear HTree index"),/* 18 */
-	N_("Recreate"),		/* 19 */
-	N_("Optimize"),		/* 20 */
-	N_("Clear flag"),	/* 21 */
-	"",			/* 22 */
+	N_("(no prompt)"),			/* PROMPT_NONE		=  0 */

Why not make it even clearer and mismerge proof:

static const char *prompt[] = {
	[0]		= N_("(no prompt")),	/* null value test */
	[PROMPT_FIX]	= N_("Fix"),		/* 1 */
	[PROMPT_CLEAR]	= N_("Clear"),		/* 2 */
	...
};

--D

Quoted 28 lines
e2fsck/problem.c +22 -0
+	N_("Fix"),				/* PROMPT_FIX		=  1 */
+	N_("Clear"),				/* PROMPT_CLEAR		=  2 */
+	N_("Relocate"),				/* PROMPT_RELOCATE	=  3 */
+	N_("Allocate"),				/* PROMPT_CREATE	=  4 */
+	N_("Expand"),				/* PROMPT_EXPAND	=  5 */
+	N_("Connect to /lost+found"),		/* PROMPT_CONNECT	=  6 */
+	N_("Create"),				/* PROMPT_CREATE	=  7 */
+	N_("Salvage"),				/* PROMPT_SALVAGE	=  8 */
+	N_("Truncate"),				/* PROMPT_TRUNCATE	=  9 */
+	N_("Clear inode"),			/* PROMPT_CLEAR_INODE	= 10 */
+	N_("Abort"),				/* PROMPT_ABORT		= 11 */
+	N_("Split"),				/* PROMPT_SPLIT		= 12 */
+	N_("Continue"),				/* PROMPT_CONTINUE	= 13 */
+	N_("Clone multiply-claimed blocks"),	/* PROMPT_CLONE		= 14 */
+	N_("Delete file"),			/* PROMPT_DELETE	= 15 */
+	N_("Suppress messages"),		/* PROMPT_SUPPRESS	= 16 */
+	N_("Unlink"),				/* PROMPT_UNLINK	= 17 */
+	N_("Clear HTree index"),		/* PROMPT_CLEAR_HTREE	= 18 */
+	N_("Recreate"),				/* PROMPT_RECREATE	= 19 */
+	N_("Optimize"),				/* PROMPT_OPTIMIZE	= 20 */
+	N_("Clear flag"),			/* PROMPT_CLEAR_FLAG	= 21 */
+	"",					/* PROMPT_NULL		= 22 */
 };
 
 /*
Signature · 1 line
2.25.1
#2 lore raw
Quoted 49 lines · Darrick J. Wong
Quoted 34 lines · Andreas Dilger

It isn't totally clear when searching the code for PROMPT_* constants from problem codes where these messages come from. Similarly, there isn't a direct mapping from the prompt string to the constant.

Add comments that make this mapping more clear.

---
e2fsck/problem.c | 46 +++++++++++++++++++++++-----------------------

1 file changed, 23 insertions(+), 23 deletions(-)
e2fsck/problem.c +0 -14
index 757b5d56..2d02468c 100644
@@ -50,29 +50,29 @@
 * to fix a problem.
 */
 static const char *prompt[] = {
-	N_("(no prompt)"),	/* 0 */
-	N_("Fix"),		/* 1 */
-	N_("Clear"),		/* 2 */
-	N_("Relocate"),		/* 3 */
-	N_("Allocate"),		/* 4 */
-	N_("Expand"),		/* 5 */
-	N_("Connect to /lost+found"), /* 6 */
-	N_("Create"),		/* 7 */
-	N_("Salvage"),		/* 8 */
-	N_("Truncate"),		/* 9 */
-	N_("Clear inode"),	/* 10 */
-	N_("Abort"),		/* 11 */
-	N_("Split"),		/* 12 */
-	N_("Continue"),		/* 13 */

e2fsck/problem.c line 53

Quoted 10 lines
e2fsck/problem.c +1 -9
-	N_("Clone multiply-claimed blocks"), /* 14 */
-	N_("Delete file"),	/* 15 */
-	N_("Suppress messages"),/* 16 */
-	N_("Unlink"),		/* 17 */
-	N_("Clear HTree index"),/* 18 */
-	N_("Recreate"),		/* 19 */
-	N_("Optimize"),		/* 20 */
-	N_("Clear flag"),	/* 21 */
-	"",			/* 22 */
+	N_("(no prompt)"),			/* PROMPT_NONE		=  0 */

Why not make it even clearer and mismerge proof:

Quoted 6 lines
static const char *prompt[] = {
	[0]		= N_("(no prompt")),	/* null value test */
	[PROMPT_FIX]	= N_("Fix"),		/* 1 */
	[PROMPT_CLEAR]	= N_("Clear"),		/* 2 */
	...
};

I thought about that too, but then I thought the "[index] = foo" designated initializer is GNU or at least C99-specific, and I wondered if that was going to cause portability problems for some ancient system that e2fsprogs is building on... I figured adding comments is relatively safe, and these values change so rarely that more complexity in the patch was not a win.

Cheers, Andreas

#3 lore raw
Quoted 57 lines · Andreas Dilger
Quoted 49 lines · Darrick J. Wong
Quoted 34 lines · Andreas Dilger

It isn't totally clear when searching the code for PROMPT_* constants from problem codes where these messages come from. Similarly, there isn't a direct mapping from the prompt string to the constant.

Add comments that make this mapping more clear.

---
e2fsck/problem.c | 46 +++++++++++++++++++++++-----------------------

1 file changed, 23 insertions(+), 23 deletions(-)
e2fsck/problem.c +0 -14
index 757b5d56..2d02468c 100644
@@ -50,29 +50,29 @@
 * to fix a problem.
 */
 static const char *prompt[] = {
-	N_("(no prompt)"),	/* 0 */
-	N_("Fix"),		/* 1 */
-	N_("Clear"),		/* 2 */
-	N_("Relocate"),		/* 3 */
-	N_("Allocate"),		/* 4 */
-	N_("Expand"),		/* 5 */
-	N_("Connect to /lost+found"), /* 6 */
-	N_("Create"),		/* 7 */
-	N_("Salvage"),		/* 8 */
-	N_("Truncate"),		/* 9 */
-	N_("Clear inode"),	/* 10 */
-	N_("Abort"),		/* 11 */
-	N_("Split"),		/* 12 */
-	N_("Continue"),		/* 13 */

e2fsck/problem.c line 53

Quoted 10 lines
e2fsck/problem.c +1 -9
-	N_("Clone multiply-claimed blocks"), /* 14 */
-	N_("Delete file"),	/* 15 */
-	N_("Suppress messages"),/* 16 */
-	N_("Unlink"),		/* 17 */
-	N_("Clear HTree index"),/* 18 */
-	N_("Recreate"),		/* 19 */
-	N_("Optimize"),		/* 20 */
-	N_("Clear flag"),	/* 21 */
-	"",			/* 22 */
+	N_("(no prompt)"),			/* PROMPT_NONE		=  0 */

Why not make it even clearer and mismerge proof:

Quoted 6 lines
static const char *prompt[] = {
	[0]		= N_("(no prompt")),	/* null value test */
	[PROMPT_FIX]	= N_("Fix"),		/* 1 */
	[PROMPT_CLEAR]	= N_("Clear"),		/* 2 */
	...
};
Quoted 5 lines

I thought about that too, but then I thought the "[index] = foo" designated initializer is GNU or at least C99-specific, and I wondered if that was going to cause portability problems for some ancient system that e2fsprogs is building on... I figured adding comments is relatively safe, and these values change so rarely that more complexity in the patch was not a win.

<shrug> Yeah, I thought it was safe enough to use -std=gnu90 features, but I guess it's really up to Ted to decide if he'd prefer a structural fix or not. Evidently this syntax is /still/ being argued in the C++ committees, which ... yay. :(

--D

Quoted 6 lines

Cheers, Andreas

#4 lore raw
Quoted 64 lines · Darrick J. Wong
Quoted 57 lines · Andreas Dilger
Quoted 49 lines · Darrick J. Wong
Quoted 34 lines · Andreas Dilger

It isn't totally clear when searching the code for PROMPT_* constants from problem codes where these messages come from. Similarly, there isn't a direct mapping from the prompt string to the constant.

Add comments that make this mapping more clear.

---
e2fsck/problem.c | 46 +++++++++++++++++++++++-----------------------

1 file changed, 23 insertions(+), 23 deletions(-)
e2fsck/problem.c +0 -14
index 757b5d56..2d02468c 100644
@@ -50,29 +50,29 @@
 * to fix a problem.
 */
 static const char *prompt[] = {
-	N_("(no prompt)"),	/* 0 */
-	N_("Fix"),		/* 1 */
-	N_("Clear"),		/* 2 */
-	N_("Relocate"),		/* 3 */
-	N_("Allocate"),		/* 4 */
-	N_("Expand"),		/* 5 */
-	N_("Connect to /lost+found"), /* 6 */
-	N_("Create"),		/* 7 */
-	N_("Salvage"),		/* 8 */
-	N_("Truncate"),		/* 9 */
-	N_("Clear inode"),	/* 10 */
-	N_("Abort"),		/* 11 */
-	N_("Split"),		/* 12 */
-	N_("Continue"),		/* 13 */

e2fsck/problem.c line 53

Quoted 10 lines
e2fsck/problem.c +1 -9
-	N_("Clone multiply-claimed blocks"), /* 14 */
-	N_("Delete file"),	/* 15 */
-	N_("Suppress messages"),/* 16 */
-	N_("Unlink"),		/* 17 */
-	N_("Clear HTree index"),/* 18 */
-	N_("Recreate"),		/* 19 */
-	N_("Optimize"),		/* 20 */
-	N_("Clear flag"),	/* 21 */
-	"",			/* 22 */
+	N_("(no prompt)"),			/* PROMPT_NONE		=  0 */

Why not make it even clearer and mismerge proof:

Quoted 6 lines
static const char *prompt[] = {
	[0]		= N_("(no prompt")),	/* null value test */
	[PROMPT_FIX]	= N_("Fix"),		/* 1 */
	[PROMPT_CLEAR]	= N_("Clear"),		/* 2 */
	...
};
Quoted 5 lines

I thought about that too, but then I thought the "[index] = foo" designated initializer is GNU or at least C99-specific, and I wondered if that was going to cause portability problems for some ancient system that e2fsprogs is building on... I figured adding comments is relatively safe, and these values change so rarely that more complexity in the patch was not a win.

Quoted 4 lines

<shrug> Yeah, I thought it was safe enough to use -std=gnu90 features, but I guess it's really up to Ted to decide if he'd prefer a structural fix or not. Evidently this syntax is /still/ being argued in the C++ committees, which ... yay. :(

Ted, thoughts on this?

Cheers, Andreas

#5 lore raw
In reply to Andreas Dilger
Quoted 8 lines · Andreas Dilger

It isn't totally clear when searching the code for PROMPT_* constants from problem codes where these messages come from. Similarly, there isn't a direct mapping from the prompt string to the constant.

Add comments that make this mapping more clear.

[...]

Applied, thanks!

[1/1] e2fsck: map PROMPT_* values to prompt messages

      commit: c1bd25333e8986b081b82a8eb8c9173a0c7480af

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>