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: Sat, 24 Jul 2021 15:57:16 +0800 [thread overview]
Message-ID: <CAOLTT8SggCXkajPG3om+6zhM_K8fyAb2qTBDj40JJa1pszshzg@mail.gmail.com> (raw)
In-Reply-To: <xmqqh7glouiw.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> 于2021年7月24日周六 上午12:38写道:
>
> "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > struct atom_value {
> > const char *s;
> > + size_t s_size;
> > int (*handler)(struct atom_value *atomv, struct ref_formatting_state *state,
> > struct strbuf *err);
> > uintmax_t value; /* used for sorting when not FIELD_STR */
> > struct used_atom *atom;
> > };
> >
> > +#define ATOM_VALUE_INIT { \
> > + .s_size = -1 \
> > +}
>
> This will get turned into size_t that is unsigned, and comparisons
> like this one and ...
>
> > case QUOTE_NONE:
> > - strbuf_addstr(s, str);
> > + if (len != -1)
> > + strbuf_add(s, str, len);
> > + else
> > + strbuf_addstr(s, str);
>
> this one ...
>
> > + if (v->s_size != -1)
> > + strbuf_add(&state->stack->output, v->s, v->s_size);
> > + else
> > + strbuf_addstr(&state->stack->output, v->s);
> > return 0;
> > }
>
> may work as expected, but it makes readers wonder if there is
> significance to negative values other than -1 (in other words, what
> does it mean if v->s_size == -2, for example?).
>
Yes, any value less than -1 is meaningless here.
> 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.
> Other changes in the whole series relative to what has been queued
> looked all sensible to me.
>
> THanks.
>
Thanks.
--
ZheNing Hu
next prev parent reply other threads:[~2021-07-24 7:56 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 [this message]
2021-07-24 17:41 ` Junio C Hamano
2021-07-25 12:47 ` ZheNing Hu
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=CAOLTT8SggCXkajPG3om+6zhM_K8fyAb2qTBDj40JJa1pszshzg@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).