On Mon, Jan 2, 2023 at 6:01 AM NSENGIYUMVA WILBERFORCE <nsengiyumvawilberforce@xxxxxxxxx> wrote: > > Handing the !arg case first will make the if/else if/... cascade > > easier to follow, no? Also the body of the function may want to > > become a separate function that returns one of these S_FOO constants. > > > > static enum signatore_option signature_atom_parser(...) > > { > > enum signature_option opt = parse_signature_option(arg); > > if (opt < 0) > > return strbuf_addf_ret(err, opt, _("unknown ..."), arg); > > return opt; > > } > > > > where parse_signature_option() would look like > > > > static enum signature_option parse_signature_option(const char *arg) > > { > > if (!arg) > > return S_BARE; > > else if (!strcmp(arg, "signer")) > > return S_SIGNER; > > ... > > else > > return -1; > > } > > > > or something like that? [...] > > > + if (strcmp(name, "signature") && > > > + strcmp(name, "signature:signer") && > > > + strcmp(name, "signature:grade") && > > > + strcmp(name, "signature:key") && > > > + strcmp(name, "signature:fingerprint") && > > > + strcmp(name, "signature:primarykeyfingerprint") && > > > + strcmp(name, "signature:trustlevel")) > > > + continue; > > > > And with the helper above, we can avoid the repetition here that can > > go out of sync with the parser function. > > I am not sure I have understood this, which helper? I think Junio is talking about the following function: static enum signature_option parse_signature_option(const char *arg) he suggested above. With this function the above code could be just something like: if (parse_signature_option(name) < 0) continue;