Re: [PATCH v2 1/5] scalar-unregister: handle error codes greater than 0
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 17, 2022, 14:33 UTC
- Message-ID
- <xmqq4jyb0wju.fsf@gitster.g>
- In-Reply-To
- <36fc3cb604d835f06bd5eca22b6eeff73e7117c8.1660694290.git.gitgitgadget@gmail.com>
"Victoria Dye via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 6 quoted lines
> From: Victoria Dye <vdye@github.com> > > When 'scalar unregister' tries to disable maintenance and remove an > enlistment, ensure that the return value is nonzero if either operation > produces *any* nonzero return value, not just when they return a value less > than 0.
Interesting. Did this actually cause problems in the wild? Just being curious.
The return values from toggle_maintenance() and add_or_remove() are what scalar.c::run_git() returns, which in turn come from run_command() and eventually come from wait_or_whine(), so it very well can be a positive non-zero value that signals a failure. It is good to be prepared to see not just negative values but also positive ones.
Show 22 quoted lines
> Signed-off-by: Victoria Dye <vdye@github.com>
> ---
> contrib/scalar/scalar.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/scalar/scalar.c b/contrib/scalar/scalar.c
> index 97e71fe19cd..e888fa5408e 100644
> --- a/contrib/scalar/scalar.c
> +++ b/contrib/scalar/scalar.c
> @@ -253,10 +253,10 @@ static int unregister_dir(void)
> {
> int res = 0;
>
> - if (toggle_maintenance(0) < 0)
> + if (toggle_maintenance(0))
> res = -1;
>
> - if (add_or_remove_enlistment(0) < 0)
> + if (add_or_remove_enlistment(0))
> res = -1;
>
> return res;