Skip to content

Commit

Permalink
Unify variable initialization
Browse files Browse the repository at this point in the history
We initialized some variables at the top of main(), and some before the
first use. Since these variables are used during cleanup it makes sense
to initialize all of them at the top.

Use one variable per line to make the code easier to read.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Dec 14, 2024
1 parent 0f61b07 commit 1a5c1d8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,9 @@ static void on_accept(struct state *state, int accept_fd, interface_ref iface);

int main(int argc, char *argv[]) {
debug = getenv("DEBUG") != NULL;
int rc = 1, listen_fd = -1;
int rc = 1;
int listen_fd = -1;
int pidfile_fd = -1;
__block interface_ref iface = NULL;

struct state state = {0};
Expand All @@ -409,7 +411,6 @@ int main(int argc, char *argv[]) {
WARN("Seems running with SETUID. This is insecure and highly discouraged: See README.md");
}

int pidfile_fd = -1;
if (cliopt->pidfile != NULL) {
pidfile_fd = create_pidfile(cliopt->pidfile);
if (pidfile_fd == -1) {
Expand Down

0 comments on commit 1a5c1d8

Please sign in to comment.