Re: [PATCH v2] gpg-interface: add function for converting trust level to string

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jul 10, 2022 at 1:48 AM Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Eric Sunshine <sunshine@xxxxxxxxxxxxxx> writes:
> > Given the small, fixed number of trust levels, and if the list is
> > unlikely to change much in the future, I might suggest simply
> > initializing the fields at compile-time rather than on-demand at
> > run-time:
> >
> >     static struct {
> >         const char *key;
> >         const char *display_key;
> >         enum signature_trust_level value;
> >     } sigcheck_gpg_trust_level[] = {
> >         { "UNDEFINED", "undefined", TRUST_UNDEFINED },
> >         { "NEVER", "never", TRUST_NEVER },
> >         { "MARGINAL", "marginal", TRUST_MARGINAL },
> >         { "FULLY", "fully", TRUST_FULLY },
> >         { "ULTIMATE", "ultimate", TRUST_ULTIMATE },
> >     };
>
> Yup, that is even better.  I wonder if we can upcase in C
> preprocessor macro?  It would be wonderful if we can do so,
> but for just 5 entries, we can type each token three times
> just fine.

No standardized way to upcase via the C preprocessor, as far as I
know. At any rate, I suspect such a macro would be uglier and harder
to reason about than the code above, which is dead-simple to
understand.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux