[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] maint: use consistent widths for comparison of file system c
From: |
Jim Meyering |
Subject: |
Re: [PATCH] maint: use consistent widths for comparison of file system constants |
Date: |
Wed, 21 May 2014 19:28:16 -0700 |
On Wed, May 21, 2014 at 6:46 PM, Pádraig Brady <address@hidden> wrote:
> * src/stat.c (human_fstype): Adjust a couple of existing constants
> to be a consistent width so that the src/fs-magic-compare target
> works without reporting false positives.
> * cfg.mk (sc_fs-magic-compare): A new syntax check to enforce this.
> ---
> cfg.mk | 9 +++++++++
> src/stat.c | 4 ++--
> 2 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/cfg.mk b/cfg.mk
> index 66aa55d..f930dae 100644
> --- a/cfg.mk
> +++ b/cfg.mk
> @@ -577,6 +577,15 @@ sc_marked_devdiagnostics:
> halt='found marked developer diagnostic(s)' \
> $(_sc_search_regexp)
>
> +# Ensure we keep hex constants as 4 or 8 bytes for consistency
> +# and so that make src/fs-magic-compare works consistently
> +sc_fs-magic-compare:
> + @sed -n 's|.*/\* \(0x[0-9A-F]\{1,\}\) .*\*/|\1|p' \
> + $(srcdir)/src/stat.c \
> + | sed 's/^.\{6\}$$/4 &/; s/^.\{10\}$$/8 &/' | grep '^[^48]' \
> + && { echo '$(ME): Hex values in src/stat.c should be 4 or 8
> bytes' \
> + 1>&2; exit 1; } || :
> +
> # Override the default Cc: used in generating an announcement.
> announcement_Cc_ = $(translation_project_), \
> address@hidden, address@hidden
Nice. Thanks!
What do you think about using e.g.,
grep -vE '^0x(....|........)$'
instead of that latter sed invocation?
Then any offending hex string would be printed.