All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Dilger <adilger@dilger.ca>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>, linux-ext4 <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH] e2fsck: map PROMPT_* values to prompt messages
Date: Mon, 28 Feb 2022 16:58:19 -0700	[thread overview]
Message-ID: <49C6329B-BF16-4819-98F8-AE98F985676E@dilger.ca> (raw)
In-Reply-To: <20211211005111.GC69182@magnolia>

[-- Attachment #1: Type: text/plain, Size: 2855 bytes --]

On Dec 10, 2021, at 5:51 PM, Darrick J. Wong <djwong@kernel.org> wrote:
> On Thu, Dec 09, 2021 at 02:55:26PM -0700, Andreas Dilger wrote:
>> On Dec 8, 2021, at 9:42 AM, Darrick J. Wong <djwong@kernel.org> wrote:
>>> 
>>> On Wed, Dec 08, 2021 at 12:51:12AM -0700, Andreas Dilger wrote:
>>>> 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.
>>>> 
>>>> Signed-off-by: Andreas Dilger <adilger@dilger.ca>
>>>> ---
>>>> e2fsck/problem.c | 46 +++++++++++++++++++++++-----------------------
>>>> 1 file changed, 23 insertions(+), 23 deletions(-)
>>>> 
>>>> diff --git a/e2fsck/problem.c b/e2fsck/problem.c
>>>> index 757b5d56..2d02468c 100644
>>>> --- a/e2fsck/problem.c
>>>> +++ b/e2fsck/problem.c
>>>> @@ -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 */
>>> 
>>> 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 */
>>> 	...
>>> };
>> 
>> 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. :(

Ted, thoughts on this?

Cheers, Andreas






[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]

  reply	other threads:[~2022-02-28 23:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-08  7:51 [PATCH] e2fsck: map PROMPT_* values to prompt messages Andreas Dilger
2021-12-08 16:42 ` Darrick J. Wong
2021-12-09 21:55   ` Andreas Dilger
2021-12-11  0:51     ` Darrick J. Wong
2022-02-28 23:58       ` Andreas Dilger [this message]
2022-05-03  3:31 ` Theodore Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49C6329B-BF16-4819-98F8-AE98F985676E@dilger.ca \
    --to=adilger@dilger.ca \
    --cc=djwong@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.