mbox series

[v6,0/3] parse: replace atoi() with strtoul_ui() and strtol_i()

Message ID pull.1810.v6.git.git.1729729499.gitgitgadget@gmail.com (mailing list archive)
Headers show
Series parse: replace atoi() with strtoul_ui() and strtol_i() | expand

Message

Usman Akinyemi via GitGitGadget Oct. 24, 2024, 12:24 a.m. UTC
Changes from Version 5:

 * Save the content of .gitattributes in .gitattributes.bak before adding
   conflict-marker-size=3a, as subsequent tests do not depend on having
   invalid lines. Restore .gitattributes to its original state after
   testing.
 * Use test_grep for testing failure output, as it provides a cleaner
   approach.
 * Use err instead of actual_error for conciseness and to maintain
   consistency with the style of the rest of the test suite.

Usman Akinyemi (3):
  daemon: replace atoi() with strtoul_ui() and strtol_i()
  merge: replace atoi() with strtol_i() for marker size validation
  imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT
    parsing

 daemon.c              | 12 ++++++++----
 imap-send.c           | 13 ++++++++-----
 merge-ll.c            | 11 +++++++++--
 t/t5570-git-daemon.sh | 25 +++++++++++++++++++++++++
 t/t6406-merge-attr.sh |  8 ++++++++
 5 files changed, 58 insertions(+), 11 deletions(-)


base-commit: 90fe3800b92a49173530828c0a17951abd30f0e1
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1810%2FUnique-Usman%2Fr_atoi-v6
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1810/Unique-Usman/r_atoi-v6
Pull-Request: https://github.com/git/git/pull/1810

Range-diff vs v5:

 1:  d9c997d7a9c ! 1:  3daedaeb260 daemon: replace atoi() with strtoul_ui() and strtol_i()
     @@ t/t5570-git-daemon.sh: TEST_PASSES_SANITIZE_LEAK=true
      +test_expect_success 'daemon rejects invalid --init-timeout values' '
      +	for arg in "3a" "-3"
      +	do
     -+		test_must_fail git daemon --init-timeout="$arg" 2>actual_error &&
     -+		test_write_lines "fatal: invalid init-timeout ${SQ}$arg${SQ}, expecting a non-negative integer" >expected &&
     -+		test_cmp actual_error expected || return 1
     ++		test_must_fail git daemon --init-timeout="$arg" 2>err &&
     ++		test_grep "fatal: invalid init-timeout ${SQ}$arg${SQ}, expecting a non-negative integer" err ||
     ++		return 1
      +	done
      +'
      +
      +test_expect_success 'daemon rejects invalid --timeout values' '
      +	for arg in "3a" "-3"
      +	do
     -+		test_must_fail git daemon --timeout="$arg" 2>actual_error &&
     -+		test_write_lines "fatal: invalid timeout ${SQ}$arg${SQ}, expecting a non-negative integer" >expected &&
     -+		test_cmp actual_error expected || return 1
     ++		test_must_fail git daemon --timeout="$arg" 2>err &&
     ++		test_grep "fatal: invalid timeout ${SQ}$arg${SQ}, expecting a non-negative integer" err ||
     ++		return 1
      +	done
      +'
      +
      +test_expect_success 'daemon rejects invalid --max-connections values' '
      +	arg='3a' &&
     -+	test_must_fail git daemon --max-connections=3a 2>actual_error &&
     -+	test_write_lines "fatal: invalid max-connections ${SQ}$arg${SQ}, expecting an integer" >expected &&
     -+	test_cmp actual_error expected
     ++	test_must_fail git daemon --max-connections=3a 2>err &&
     ++	test_grep "fatal: invalid max-connections ${SQ}$arg${SQ}, expecting an integer" err
      +'
      +
       start_git_daemon
 2:  da9ea10e4e1 ! 2:  0ea3b349560 merge: replace atoi() with strtol_i() for marker size validation
     @@ t/t6406-merge-attr.sh: test_expect_success 'retry the merge with longer context'
       '
       
      +test_expect_success 'invalid conflict-marker-size 3a' '
     -+    echo "text conflict-marker-size=3a" >>.gitattributes &&
     -+    git checkout -m text 2>error &&
     -+    test_grep "warning: invalid marker-size ${SQ}3a${SQ}, expecting an integer" error
     ++	cp .gitattributes .gitattributes.bak &&
     ++	echo "text conflict-marker-size=3a" >>.gitattributes &&
     ++	test_when_finished "mv .gitattributes.bak .gitattributes" &&
     ++	git checkout -m text 2>err &&
     ++	test_grep "warning: invalid marker-size ${SQ}3a${SQ}, expecting an integer" err
      +'
      +
       test_expect_success 'custom merge backend' '
 3:  9b2b2dc8fc8 = 3:  17484df5200 imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT parsing

Comments

Taylor Blau Oct. 24, 2024, 6:03 p.m. UTC | #1
On Thu, Oct 24, 2024 at 12:24:55AM +0000, Usman Akinyemi via GitGitGadget wrote:
> Usman Akinyemi (3):
>   daemon: replace atoi() with strtoul_ui() and strtol_i()
>   merge: replace atoi() with strtol_i() for marker size validation
>   imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT
>     parsing

Thanks, this new round looks quite good to me. Do others have thoughts
on this, or are we ready to start merging it down?

Thanks,
Taylor
Patrick Steinhardt Oct. 25, 2024, 5:06 a.m. UTC | #2
On Thu, Oct 24, 2024 at 02:03:12PM -0400, Taylor Blau wrote:
> On Thu, Oct 24, 2024 at 12:24:55AM +0000, Usman Akinyemi via GitGitGadget wrote:
> > Usman Akinyemi (3):
> >   daemon: replace atoi() with strtoul_ui() and strtol_i()
> >   merge: replace atoi() with strtol_i() for marker size validation
> >   imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT
> >     parsing
> 
> Thanks, this new round looks quite good to me. Do others have thoughts
> on this, or are we ready to start merging it down?

I'm happy with this version.

Patrick
Usman Akinyemi Oct. 25, 2024, 6:11 a.m. UTC | #3
On Fri, Oct 25, 2024 at 5:07 AM Patrick Steinhardt <ps@pks.im> wrote:
>
> On Thu, Oct 24, 2024 at 02:03:12PM -0400, Taylor Blau wrote:
> > On Thu, Oct 24, 2024 at 12:24:55AM +0000, Usman Akinyemi via GitGitGadget wrote:
> > > Usman Akinyemi (3):
> > >   daemon: replace atoi() with strtoul_ui() and strtol_i()
> > >   merge: replace atoi() with strtol_i() for marker size validation
> > >   imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT
> > >     parsing
> >
> > Thanks, this new round looks quite good to me. Do others have thoughts
> > on this, or are we ready to start merging it down?
>
> I'm happy with this version.
>
> Patrick
Thanks to Patrick and Taylor, I really appreciate your time and mentorship.
Taylor Blau Oct. 25, 2024, 2:44 p.m. UTC | #4
On Fri, Oct 25, 2024 at 06:11:05AM +0000, Usman Akinyemi wrote:
> On Fri, Oct 25, 2024 at 5:07 AM Patrick Steinhardt <ps@pks.im> wrote:
> >
> > On Thu, Oct 24, 2024 at 02:03:12PM -0400, Taylor Blau wrote:
> > > On Thu, Oct 24, 2024 at 12:24:55AM +0000, Usman Akinyemi via GitGitGadget wrote:
> > > > Usman Akinyemi (3):
> > > >   daemon: replace atoi() with strtoul_ui() and strtol_i()
> > > >   merge: replace atoi() with strtol_i() for marker size validation
> > > >   imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT
> > > >     parsing
> > >
> > > Thanks, this new round looks quite good to me. Do others have thoughts
> > > on this, or are we ready to start merging it down?
> >
> > I'm happy with this version.
> >
> > Patrick
>
> Thanks to Patrick and Taylor, I really appreciate your time and mentorship.

Thanks, both, for working on and reviewing this topic.

Thanks,
Taylor