Re: [PATCH v4 2/3] format-patch: use enum variables
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 12, 2019, 02:16 UTC
- Message-ID
- <xmqqk19aemi2.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <19ee1f71493fa584991f530e952d9198880208eb.1570821015.git.liu.denton@gmail.com>
Denton Liu <liu.denton@gmail.com> writes:
Show 9 quoted lines
> -#define THREAD_SHALLOW 1
> -#define THREAD_DEEP 2
> -static int thread;
> +enum thread_level {
> + THREAD_UNSET,
> + THREAD_SHALLOW,
> + THREAD_DEEP
> +};
> +static enum thread_level thread;As the assignment of values do not change, this is a safe conversion even if an existing code did things like
if (!thread)
... do this ...;Hopefully nobody did arithmetic on it; thread_level may now become unsigned depending on the compiler.
> -static int config_cover_letter; > +static enum cover_setting config_cover_letter;
Likewise about the signedness.