From: ZheNing Hu <adlternative@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com>,
"Git List" <git@vger.kernel.org>,
"Christian Couder" <christian.couder@gmail.com>,
"Hariom Verma" <hariom18599@gmail.com>,
"Bagas Sanjaya" <bagasdotme@gmail.com>,
"Jeff King" <peff@peff.net>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Philip Oakley" <philipoakley@iee.email>
Subject: Re: [PATCH v2 2/5] [GSOC] ref-filter: add %(raw) atom
Date: Sun, 25 Jul 2021 20:47:16 +0800 [thread overview]
Message-ID: <CAOLTT8Sm=qs0K84C=yJOL7Ct5GUeHYe=ODXiGpwCSx11vgEnwA@mail.gmail.com> (raw)
In-Reply-To: <xmqqy29vk3sp.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 于2021年7月25日周日 上午1:41写道:
>
> ZheNing Hu <adlternative@gmail.com> writes:
>
> >> It may make sense to
> >>
> >> * Turn atom_value.s_size field into ssize_t instead of size_t
> >>
> >
> > Will the conversion of size_t and ssize_t break -Wsign-conversion?
> > Although there is a lot of code in Git that has broken it, but I am not
> > sure if it is wise to use ssize_t here.
> >
> >> * Rewrite (v->s_size != -1) comparison to (v->s_size < 0)
> >>
> >
> > For size_t, this scheme is wrong.
> >
> >>
> >> Optionally we could introduce #define ATOM_SIZE_UNSPECIFIED (-1) and
> >> use it to initialize .s_size in ATOM_VALUE_INIT, but if we are just
> >> going to test "is it negative, then it is not given", then it probably
> >> is not needed.
> >>
> >
> > It seems that this is the only method left. Although I think
> > ATOM_SIZE_UNSPECIFIED
> > is not very useful becasue we already have ATOM_VALUE_INIT.
>
> Sorry, but I think you misread what I wrote.
>
> These three were not offered as "you can do one of these three, pick
> one you like" choices. I meant to say "I think it makes sense to do
> all these three things, but the last one is optional, doing only the
> first two may be good enough". As the second one requires that the
> first is done, of course, doing only the second one would not make
> sense.
>
OK. I know it now, I will do all of them.
> Also, you seem to have missed the distinction between _INIT and
> _UNSPECIFIED. You can initialize something to (1) a reasonable
> default value, or (2) unusable value that you can detect at runtime
> and notice that it was not set. If you called something to
> FOO_INIT, your readers cannot tell which one it is, but if you call
> it FOO_UNSPECIFIED, it is clear it is the latter case.
>
Thanks for clarification, I understand the difference between them now.
> In many places, we do use ssize_t for "normally this is size, but we
> can express exception cases (like errors) by storing negative value"
> in our codebase (grep for it), and I think the member in question is
> prime candidate for such use.
>
Yeah, as abspath.c:137, `ssize_t len` used to distinguish situations
if an error is
returned from strbuf_readlink().
ssize_t len;
...
len = strbuf_readlink(&symlink, resolved->buf,
st.st_size);
if (len < 0) {
if (flags & REALPATH_DIE_ON_ERROR)
die_errno("Invalid symlink '%s'",
resolved->buf);
else
goto error_out;
}
...
Or just read() and write(), they return is ssize_t too,
which can return -1 and set errno when an exception occurs.
Thanks.
--
ZheNing Hu
next prev parent reply other threads:[~2021-07-25 12:46 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-22 7:39 [PATCH 0/5] [GSOC] ref-filter: add %(raw) and %(rest) atoms ZheNing Hu via GitGitGadget
2021-07-22 7:39 ` [PATCH 1/5] [GSOC] ref-filter: add obj-type check in grab contents ZheNing Hu via GitGitGadget
2021-07-22 8:51 ` Christian Couder
2021-07-22 9:15 ` ZheNing Hu
2021-07-22 7:39 ` [PATCH 2/5] [GSOC] ref-filter: add %(raw) atom ZheNing Hu via GitGitGadget
2021-07-22 8:06 ` Ævar Arnfjörð Bjarmason
2021-07-22 8:31 ` ZheNing Hu
2021-07-22 7:39 ` [PATCH 3/5] [GSOC] ref-filter: --format=%(raw) re-support --perl ZheNing Hu via GitGitGadget
2021-07-22 7:39 ` [PATCH 4/5] [GSOC] ref-filter: use non-const ref_format in *_atom_parser() ZheNing Hu via GitGitGadget
2021-07-22 7:39 ` [PATCH 5/5] [GSOC] ref-filter: add %(rest) atom ZheNing Hu via GitGitGadget
2021-07-22 8:11 ` Ævar Arnfjörð Bjarmason
2021-07-22 9:10 ` ZheNing Hu
2021-07-23 9:09 ` Jacob Keller
2021-07-23 14:11 ` ZheNing Hu
2021-07-22 8:08 ` [PATCH 0/5] [GSOC] ref-filter: add %(raw) and %(rest) atoms Christian Couder
2021-07-22 8:22 ` ZheNing Hu
2021-07-23 9:03 ` [PATCH v2 " ZheNing Hu via GitGitGadget
2021-07-23 9:03 ` [PATCH v2 1/5] [GSOC] ref-filter: add obj-type check in grab contents ZheNing Hu via GitGitGadget
2021-07-23 9:04 ` [PATCH v2 2/5] [GSOC] ref-filter: add %(raw) atom ZheNing Hu via GitGitGadget
2021-07-23 16:38 ` Junio C Hamano
2021-07-24 7:57 ` ZheNing Hu
2021-07-24 17:41 ` Junio C Hamano
2021-07-25 12:47 ` ZheNing Hu [this message]
2021-07-23 9:04 ` [PATCH v2 3/5] [GSOC] ref-filter: --format=%(raw) re-support --perl ZheNing Hu via GitGitGadget
2021-07-23 9:04 ` [PATCH v2 4/5] [GSOC] ref-filter: use non-const ref_format in *_atom_parser() ZheNing Hu via GitGitGadget
2021-07-23 9:04 ` [PATCH v2 5/5] [GSOC] ref-filter: add %(rest) atom ZheNing Hu via GitGitGadget
2021-07-24 14:14 ` [PATCH v3 0/5] [GSOC] ref-filter: add %(raw) and %(rest) atoms ZheNing Hu via GitGitGadget
2021-07-24 14:14 ` [PATCH v3 1/5] [GSOC] ref-filter: add obj-type check in grab contents ZheNing Hu via GitGitGadget
2021-07-25 8:22 ` Jacob Keller
2021-07-24 14:14 ` [PATCH v3 2/5] [GSOC] ref-filter: add %(raw) atom ZheNing Hu via GitGitGadget
2021-07-24 14:14 ` [PATCH v3 3/5] [GSOC] ref-filter: --format=%(raw) re-support --perl ZheNing Hu via GitGitGadget
2021-07-25 8:27 ` Jacob Keller
2021-07-25 13:18 ` ZheNing Hu
2021-07-24 14:14 ` [PATCH v3 4/5] [GSOC] ref-filter: use non-const ref_format in *_atom_parser() ZheNing Hu via GitGitGadget
2021-07-24 14:14 ` [PATCH v3 5/5] [GSOC] ref-filter: add %(rest) atom ZheNing Hu via GitGitGadget
2021-07-25 8:29 ` Jacob Keller
2021-07-26 17:34 ` Junio C Hamano
2021-07-26 3:26 ` [PATCH v4 0/5] [GSOC] ref-filter: add %(raw) and %(rest) atoms ZheNing Hu via GitGitGadget
2021-07-26 3:26 ` [PATCH v4 1/5] [GSOC] ref-filter: add obj-type check in grab contents ZheNing Hu via GitGitGadget
2021-07-26 19:15 ` Junio C Hamano
2021-07-27 1:41 ` ZheNing Hu
2021-07-26 3:26 ` [PATCH v4 2/5] [GSOC] ref-filter: add %(raw) atom ZheNing Hu via GitGitGadget
2021-07-26 3:26 ` [PATCH v4 3/5] [GSOC] ref-filter: --format=%(raw) support --perl ZheNing Hu via GitGitGadget
2021-07-26 3:26 ` [PATCH v4 4/5] [GSOC] ref-filter: use non-const ref_format in *_atom_parser() ZheNing Hu via GitGitGadget
2021-07-26 3:26 ` [PATCH v4 5/5] [GSOC] ref-filter: add %(rest) atom ZheNing Hu via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAOLTT8Sm=qs0K84C=yJOL7Ct5GUeHYe=ODXiGpwCSx11vgEnwA@mail.gmail.com' \
--to=adlternative@gmail.com \
--cc=avarab@gmail.com \
--cc=bagasdotme@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.com \
--cc=hariom18599@gmail.com \
--cc=peff@peff.net \
--cc=philipoakley@iee.email \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).