Re: [PATCH v3 1/3] daemon: replace atoi() with strtoul_ui() and strtol_i()
- From
Usman Akinyemi <usmanakinyemi202@gmail.com>
- Date
- Oct 22, 2024, 22:06 UTC
- Message-ID
- <CAPSxiM_YbO_AamPb7kmMEK8icSQ2YqqupFoSLHeCMNXsjGtoEQ@mail.gmail.com>
- In-Reply-To
- <ZxfRIIcd2H4S3i3+@nand.local>
On Tue, Oct 22, 2024 at 4:21 PM Taylor Blau <me@ttaylorr.com> wrote:
Show 22 quoted lines
>
> On Tue, Oct 22, 2024 at 05:23:41AM +0000, Usman Akinyemi via GitGitGadget wrote:
> > diff --git a/daemon.c b/daemon.c
> > index cb946e3c95f..09a31d2344d 100644
> > --- a/daemon.c
> > +++ b/daemon.c
> > @@ -1308,17 +1308,20 @@ int cmd_main(int argc, const char **argv)
> > continue;
> > }
> > if (skip_prefix(arg, "--timeout=", &v)) {
> > - timeout = atoi(v);
> > + if (strtoul_ui(v, 10, &timeout))
> > + die("invalid timeout '%s', expecting a non-negative integer", v);
>
> The conversion you made to both (a) use warning() and (b) mark the
> string for translation in the second patch were good, but I would have
> expected to see them here as well.
>
> Perhaps leaving this one as a die() makes sense, because we are taking
> direct input from the user, so invoking 'git daemon' with bogus options
> should result in us dying. But these strings should be marked as
> translate-able regardless.As you said, since the git daemon takes direct input from the user, compared to the other which takes input from .gitattributes leaving as die is okay here. I have marked it as translate-able in my fourth patch. Thank you very much for the review. Usman Akinyemi.
> > Thanks, > Taylor