qga: Invert logic on return value in main()
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 7 Jan 2025 14:52:06 +0000 (15:52 +0100)
committerKonstantin Kostiuk <kkostiuk@redhat.com>
Wed, 26 Feb 2025 11:34:25 +0000 (13:34 +0200)
commit5b567c21c6d517beeb1087399f733662d7e8ff62
tree4b097c7049786923c8ed72f9186e4d7e178cdbaf
parentad1e6843632555c771dda6a9425930fa25b71fb3
qga: Invert logic on return value in main()

Current logic on return value ('ret' variable) in main() is error
prone. The variable is initialized to EXIT_SUCCESS and then set
to EXIT_FAILURE on error paths. This makes it very easy to forget
to set the variable to indicate error when adding new error path,
as is demonstrated by handling of initialize_agent() failure.
It's simply lacking setting of the variable.

There's just one case where success should be indicated: when
dumping the config ('-D' cmd line argument).

To resolve this, initialize the variable to failure value and set
it explicitly to success value in that one specific case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Message-ID: <8a28265f50177a8dc4c10fcf4146e85a7fd748ee.1736261360.git.mprivozn@redhat.com>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
qga/main.c