pg_resetwal.c: duplicate '0' in hex character set for -l option validation - Mailing list pgsql-hackers

From jinbinge
Subject pg_resetwal.c: duplicate '0' in hex character set for -l option validation
Date
Msg-id 5d04a537.1970.19cac5292a7.Coremail.jinbinge@126.com
Whole thread Raw
Responses Re: pg_resetwal.c: duplicate '0' in hex character set for -l option validation
List pgsql-hackers
Hi,

In pg_resetwal.c, around line 310, there's a minor redundancy in the character set string for validating the -l option argument.

The current code is:


    case 'l':       if (strspn(optarg, "01234567890ABCDEFabcdef") != XLOG_FNAME_LEN)       {           pg_log_error("invalid argument for option %s", "-l");           pg_log_error_hint("Try \"%s --help\" for more information.", progname);           exit(1);       }

The string "01234567890ABCDEFabcdef" contains a duplicated '0' in the digit portion ("01234567890" instead of "0123456789").

While this redundancy doesn't affect functionality (the allowed character set remains unchanged and still properly validates

hexadecimal digits 0-9, A-F, a-f), it could cause confusion for code readers.


For improved clarity and to follow conventional hexadecimal representation, I suggest using the standard character set: 

"0123456789ABCDEFabcdef". This change would be purely cosmetic with no behavioral impact, but would eliminate the unnecessary duplication.


Thanks for considering this minor improvement.

Regards,
Jinbinge

Attachment

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: [Patch]Add tab completion for DELETE ... USING
Next
From: Michael Paquier
Date:
Subject: Re: Defects with invalid stats data for expressions in extended stats