Re: [PATCH v4 3/3] imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT parsing
- From
Usman Akinyemi <usmanakinyemi202@gmail.com>
- Date
- Oct 23, 2024, 07:40 UTC
- Message-ID
- <CAPSxiM8vTABv-ZPe=qCNu1yFKStqZ-eKyrwdxy1+7YMetQfECw@mail.gmail.com>
- In-Reply-To
- <ZxiSIem-Gptk6Omi@pks.im>
On Wed, Oct 23, 2024 at 6:05 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 26 quoted lines
>
> On Tue, Oct 22, 2024 at 10:08:57PM +0000, Usman Akinyemi via GitGitGadget wrote:
> > @@ -686,8 +686,8 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb,
> > for (; isspace((unsigned char)*p); p++);
> > fprintf(stderr, "*** IMAP ALERT *** %s\n", p);
> > } else if (cb && cb->ctx && !strcmp("APPENDUID", arg)) {
> > - if (!(arg = next_arg(&s)) || !(ctx->uidvalidity = atoi(arg)) ||
> > - !(arg = next_arg(&s)) || !(*(int *)cb->ctx = atoi(arg))) {
> > + if (!(arg = next_arg(&s)) || (strtol_i(arg, 10, &ctx->uidvalidity) || !ctx->uidvalidity) ||
> > + !(arg = next_arg(&s)) || (strtol_i(arg, 10, (int *)cb->ctx) || !cb->ctx)) {
> > fprintf(stderr, "IMAP error: malformed APPENDUID status\n");
> > return RESP_BAD;
> > }
>
> Two last nits from my side, sorry that I didn't spot these earlier:
>
> - The second line is indented incorrectly. When you have a multi-line
> condition, subsequent lines should align with the opening brace like
> this:
>
> if (something_something ||
> something_else)
> frobnicate();
>
> - The braces around `(strtol_i() || !ctx->uidvalidity)` are a bit
> confusing and unnecessary.Thank you Patrick for bringing my attention to this. I fixed it now. Usman
> > Other than that I'm happy with this series, thanks! > > Patrick