]> git.ipfire.org Git - thirdparty/nftables.git/commit
cli: Make cli_init() return to caller
authorPhil Sutter <phil@nwl.cc>
Wed, 21 Jun 2023 23:10:59 +0000 (01:10 +0200)
committerPhil Sutter <phil@nwl.cc>
Tue, 4 Jul 2023 11:03:09 +0000 (13:03 +0200)
commit75bfaeb7edd1fc2ae7a72318af808d8b010262b4
tree0471270dd9be78c8f14a0c9c71a72ff8e204b6a3
parent516a36c8d01fa03aafaf56a7eafa31ec0a9084db
cli: Make cli_init() return to caller

Avoid direct exit() calls as that leaves the caller-allocated nft_ctx
object in place. Making sure it is freed helps with valgrind-analyses at
least.

To signal desired exit from CLI, introduce global cli_quit boolean and
make all cli_exit() implementations also set cli_rc variable to the
appropriate return code.

The logic is to finish CLI only if cli_quit is true which asserts proper
cleanup as it is set only by the respective cli_exit() function.

Signed-off-by: Phil Sutter <phil@nwl.cc>
include/cli.h
src/cli.c