From: Felix Fietkau Date: Sat, 15 Mar 2025 15:02:55 +0000 (+0100) Subject: cli: reduce code duplication, cleanup X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=5f97919896c492b96ae698e726143f468323f372;p=project%2Funetd.git cli: reduce code duplication, cleanup Signed-off-by: Felix Fietkau --- diff --git a/cli.c b/cli.c index fcf9755..5029a60 100644 --- a/cli.c +++ b/cli.c @@ -655,9 +655,8 @@ int main(int argc, char **argv) if (has_peerkey) return usage(progname); - if (!parse_key(peerkey, optarg)) { + if (!parse_key(peerkey, optarg)) return 1; - } has_peerkey = true; break; @@ -669,16 +668,13 @@ int main(int argc, char **argv) return 1; has_key = true; - edsign_sec_to_pub(pubkey, seckey); - has_pubkey = true; break; case 'k': if (has_pubkey) return usage(progname); - if (!parse_key(pubkey, optarg)) { + if (!parse_key(pubkey, optarg)) return 1; - } has_pubkey = true; break; @@ -686,14 +682,10 @@ int main(int argc, char **argv) if (has_pubkey) return usage(progname); - if (!parse_key(seckey, optarg)) { + if (!parse_key(seckey, optarg)) return 1; - } has_key = true; - - edsign_sec_to_pub(pubkey, seckey); - has_pubkey = true; break; case 'p': password_prompt++; @@ -735,6 +727,11 @@ int main(int argc, char **argv) } } + if (has_key) { + edsign_sec_to_pub(pubkey, seckey); + has_pubkey = true; + } + if (!has_peerkey && cmd_needs_peerkey()) { INFO("Missing -h argument\n"); return 1;