From: "George Spelvin" <linux@horizon.com>
To: linux@horizon.com, tj@kernel.org
Cc: akpm@linux-foundation.org, linux-ide@vger.kernel.org,
linux-kernel@vger.kernel.org, mingo@redhat.com,
torvalds@linux-foundation.org
Subject: Re: [PATCH 1/2] Add lib/glob.c
Date: 10 May 2014 10:03:04 -0400 [thread overview]
Message-ID: <20140510140304.15690.qmail@ns.horizon.com> (raw)
In-Reply-To: <20140510122309.GB4721@mtj.dyndns.org>
Thanks a lot for the feedback!
> On Fri, May 09, 2014 at 11:13:56PM -0400, George Spelvin wrote:
>> +/**
>> + * glob_match - Shell-style pattern matching, like !fnmatch(pat, str, 0)
>> + * @pat: Pattern to match. Metacharacters are ?, *, [ and \.
>> + * (And, inside character classes, !, - and ].)
> @ARG lines should be contained in a single line. Just "Pattern to
> match." should do. With detailed description in the body.
Huh, Documentation/kernel-doc-nano-HOWTO.txt (lines 57-59, to be precise)
implies otherwise pretty strongly. But I can certainly change it.
> Just adding glob.o to lib-y should be enough. It will be excluded
> from linking if unused.
Will that work right if the caller is a module? What will it get linked
into, the main kernel binary or the module?
A significant and very helpful simplification; I just want to be sure
it works right.
>> +#ifdef UNITTEST
>> +/* To do a basic sanity test, "cc -DUNITTEST glob.c" and run a.out. */
>> +
>> +#include <stdbool.h>
>> +#define __pure __attribute__((pure))
>> +#define NOP(x)
>> +#define EXPORT_SYMBOL NOP /* Two stages to avoid checkpatch complaints */
> These things tend to bitrot. Let's please keep testing harness out of
> tree.
Damn, when separated it bitrots a lot faster. That's *is* my testing
harness, and I wanted to keep it close so it has a chance on hell of
being used by someone who updates it.
Especially given that the function's interface is quite rigidly defined,
do you really think there will be a lot of rot?
> Do we make library routines separate modules usually?
A large number of files in lib/ are implemented that way (lib/crc-ccitt.c,
just for one example), and that's what I copied. But if I just do the
obj-y thing, all that goes away
>> +bool __pure
>> +glob_match(char const *pat, char const *str)
>
> The whole thing fits in a single 80 column line, right?
>
> bool __pure glob_match(char const *pat, char const *str)
Whoops, a residue of my personal code style. (I like to left-align
function names in definitions so they're easy to search for with ^func.)
But it's not kernel style. Will fix.
>> +{
>> + /*
>> + * Backtrack to previous * on mismatch and retry starting one
>> + * character later in the string. Because * matches all characters
>> + * (no exception for /), it can be easily proved that there's
>> + * never a need to backtrack multiple levels.
>> + */
>> + char const *back_pat = 0, *back_str = back_str;
> Blank line here.
I had considered the "/*" start of the following block comment as visually
enough separation between variable declarations and statements, but sure,
I can add one.
> I haven't delved into the actual implementation. Looks sane on the
> first glance.
That's the part I'm least worried about, actually.
> Again, I don't really think the userland testing code belongs here.
> If you want to keep them, please make it in-kernel selftesting. We
> don't really want to keep code which can't get built and tested in
> kernel tree proper.
I'll see if I can figure out how to do that. Simple as it is, I hate to
throw away regression tests.
Thank you very much.
next prev parent reply other threads:[~2014-05-10 14:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20140313121032.GA9981@htj.dyndns.org>
2014-05-10 3:13 ` George Spelvin
2014-05-10 3:14 ` [PATCH 2/2] libata: Use glob_match from lib/glob.c George Spelvin
2014-05-10 12:21 ` [PATCH 1/2] Add lib/glob.c Tejun Heo
2014-05-11 6:02 ` George Spelvin
2014-05-12 23:03 ` Andrew Morton
2014-05-10 12:23 ` Tejun Heo
2014-05-10 14:03 ` George Spelvin [this message]
2014-05-10 17:22 ` Randy Dunlap
2014-05-10 17:29 ` Randy Dunlap
2014-05-11 12:36 ` Tejun Heo
2014-06-07 2:44 ` [PATCH v2 1/3] " George Spelvin
2014-06-07 2:49 ` [PATCH v2 2/3] lib: glob.c: Add CONFIG_GLOB_SELFTEST George Spelvin
2014-06-11 23:04 ` Andrew Morton
2014-06-12 1:38 ` George Spelvin
2014-06-07 2:50 ` [PATCH v2 3/3] libata: Use glob_match from lib/glob.c George Spelvin
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140510140304.15690.qmail@ns.horizon.com \
--to=linux@horizon.com \
--cc=akpm@linux-foundation.org \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tj@kernel.org \
--cc=torvalds@linux-foundation.org \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®