Re: [PATCH 1/1] builtin/blame.c: constants into bit shift format
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 17, 2019, 07:38 UTC
- Message-ID
- <xmqqr23b7ref.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <3b4b8e0353d705ea649c9fb608c021b35e6d8f5b.1571250635.git.gitgitgadget@gmail.com>
"Hariom Verma via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 13 quoted lines
> -#define OUTPUT_SHOW_AGE_WITH_COLOR 04000 > +#define OUTPUT_ANNOTATE_COMPAT (1<<0) > +#define OUTPUT_LONG_OBJECT_NAME (1<<1) > +#define OUTPUT_RAW_TIMESTAMP (1<<2) > +#define OUTPUT_PORCELAIN (1<<3) > +#define OUTPUT_SHOW_NAME (1<<4) > +#define OUTPUT_SHOW_NUMBER (1<<5) > +#define OUTPUT_SHOW_SCORE (1<<6) > +#define OUTPUT_NO_AUTHOR (1<<7) > +#define OUTPUT_SHOW_EMAIL (1<<8) > +#define OUTPUT_LINE_PORCELAIN (1<<9) > +#define OUTPUT_COLOR_LINE (1<<10) > +#define OUTPUT_SHOW_AGE_WITH_COLOR (1<<11)
For these small shift counts it probably would not matter, but it may be a good discipline to make sure they are treated as constants of an unsigned type (i.e. write them as (1U<<0) etc.). It probably starts to matter when you reach 1<<31 if these are bits stuffed into "unsigned int" on 32-bit arch.
One advantage of octal and hexadecimal notations have is that 0x80000000 is automatically unsigned, IIRC, on such an archtecture.