From: Christian Couder <christian.couder@gmail.com>
To: sushmaunnibhavi <sushmaunnibhavi425@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [GSOC][PATCH] Fixed an issue which contained extra unnecessary code
Date: Sun, 10 Mar 2019 19:10:33 +0100 [thread overview]
Message-ID: <CAP8UFD03cjbWE1pKRj93BKxxQnNuAUPCHNxmtM8RqqfJO2nu-Q@mail.gmail.com> (raw)
In-Reply-To: <20190310143126.GA13588@hacker-queen>
On Sun, Mar 10, 2019 at 4:30 PM sushmaunnibhavi
<sushmaunnibhavi425@gmail.com> wrote:
>
> From 5a6c233c6bf0a35aca000b32b9e936a34532900a Mon Sep 17 00:00:00 2001
> From: sushmaunnibhavi <sushmaunnibhavi@gmail.com>
> Date: Sun, 10 Mar 2019 19:37:33 +0530
> Subject: [GSOC][PATCH] Fixed an issue which contained extra unnecessary code
> Signed-off-by: Sushma Unnibhavi <sushmaunnibhavi425@gmail.com>
> ---
> Since '\n' and '\0' are char_len==1,it is not necessary to check if the char_len<=1.
> compat/regex/regexec.c | 5 -----
> 1 file changed, 5 deletions(-)
It doesn't look like the patch is formatted correctly. I think that
the explanation line ("Since '\n' and '\0' are...") should be above
the line that contains your "Signed-off-by: ..." and there should be a
blank line between those two lines.
Also we ask for an author name in the "From: ..." header that looks
like "Firstname Lastname". A simple way to do that would be to make it
match the name in your "Signed-off-by: ...".
> diff --git a/compat/regex/regexec.c b/compat/regex/regexec.c
> index 1b5d89fd5e..df62597531 100644
> --- a/compat/regex/regexec.c
> +++ b/compat/regex/regexec.c
> @@ -3799,11 +3799,6 @@ check_node_accept_bytes (const re_dfa_t *dfa, int node_idx,
> char_len = re_string_char_size_at (input, str_idx);
> if (node->type == OP_PERIOD)
> {
> - if (char_len <= 1)
> - return 0;
> - /* FIXME: I don't think this if is needed, as both '\n'
> - and '\0' are char_len == 1. */
> - /* '.' accepts any one character except the following two cases. */
> if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
> re_string_byte_at (input, str_idx) == '\n') ||
> ((dfa->syntax & RE_DOT_NOT_NULL) &&
The code looks like:
char_len = re_string_char_size_at (input, str_idx);
if (node->type == OP_PERIOD)
{
if (char_len <= 1)
return 0;
/* FIXME: I don't think this if is needed, as both '\n'
and '\0' are char_len == 1. */
/* '.' accepts any one character except the following two cases. */
if ((!(dfa->syntax & RE_DOT_NEWLINE) &&
re_string_byte_at (input, str_idx) == '\n') ||
((dfa->syntax & RE_DOT_NOT_NULL) &&
re_string_byte_at (input, str_idx) == '\0'))
return 0;
return char_len;
}
If the byte at re_string_byte_at (input, str_idx) is indeed '\n' or
'\0', then yeah probably char_len == 1 so the current code should
return 0 just before the code below the FIXME comment is reached. So
in this case the 2 checks below the FIXME comment are useless because
they check re_string_byte_at (input, str_idx) == '\n') and
re_string_byte_at (input, str_idx) == '\0' which cannot happen.
So I would say that the right fix would be to remove those 2 checks,
not to remove the if (char_len <= 1) check above the FIXME comment.
Also note that I used "probably" when I wrote "then yeah probably
char_len == 1", because I think it is worth checking what
re_string_char_size_at() actually does before being too much
confident...
next prev parent reply other threads:[~2019-03-10 18:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-10 14:31 [GSOC][PATCH] Fixed an issue which contained extra unnecessary code sushmaunnibhavi
2019-03-10 18:10 ` Christian Couder [this message]
2019-03-10 18:26 ` Thomas Gummerer
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=CAP8UFD03cjbWE1pKRj93BKxxQnNuAUPCHNxmtM8RqqfJO2nu-Q@mail.gmail.com \
--to=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=sushmaunnibhavi425@gmail.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).