From: Johannes Berg <johannes@sipsolutions.net>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
netdev <netdev@vger.kernel.org>,
Al Viro <viro@zeniv.linux.org.uk>
Subject: Re: [PATCH v3] bitfield: fix *_encode_bits()
Date: Mon, 18 Jun 2018 22:28:03 +0200 [thread overview]
Message-ID: <1529353683.3092.32.camel@sipsolutions.net> (raw)
In-Reply-To: <CAHp75VdY+PF0Edm_py+UiD3nz77HTQps_8uaRh+Sa3C+UKECKA@mail.gmail.com> (sfid-20180618_222109_796813_69F8BCFA)
> I think would be better to add test cases first, followed by fix. (1
> patch -> 2 patches)
> In this case Fixes tag would be only for the fix part and backporting
> (if needed) will be much easier.
Can't, unless I introduce a compilation issue in the tests first? That
seems weird. But I guess I can do it the other way around.
> > @@ -143,6 +143,7 @@ static __always_inline base type##_get_bits(__##type v, base field) \
> > ____MAKE_OP(le##size,u##size,cpu_to_le##size,le##size##_to_cpu) \
> > ____MAKE_OP(be##size,u##size,cpu_to_be##size,be##size##_to_cpu) \
> > ____MAKE_OP(u##size,u##size,,)
> > +____MAKE_OP(u8,u8,,)
>
> Is this one you need, or it's just for sake of tests?
All three ;-)
We'll probably need it eventually (we do have bytes to take bits out
of), for consistency I think we want it, and I wanted to add it to the
tests too.
> For me looks like for consistency we may add fake conversion macros
> for this, such as
>
> #define cpu_to_le8(x) x
> #define le8_to_cpu(x) x
> ...
> #undef le8_to_cpu
> #undef cpu_to_le8
>
> And do in the same way like below
>
> __MAKE_OP(8)
I disagree with this. I don't see why we should have le8_encode_bits()
and be8_encode_bits() and friends, that makes no sense.
> Perhaps
> // SPDX... GPL-2.0+
Yeah, I guess I should have that.
> > +/*
> > + * Test cases for bitfield helpers.
> > + */
> > +
> > +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> > +
> > +#include <linux/init.h>
> > +#include <linux/kernel.h>
> > +#include <linux/module.h>
>
> Either module.h (if we can compile as a module) or just init.h otherwise.
It can be a module ... guess I cargo-culted that from another test.
> > +/*
> > + * This should fail compilation:
> > + * CHECK_ENC_GET(16, 16, 0x0f00, 0x1000);
> > + */
>
> Perhaps we need some ifdeffery around this. It would allow you to try
> w/o altering the source code.
>
> #ifdef TEST_BITFIELD_COMPILE
> ...
> #endif
Yeah, I guess we could do that.
> I guess you rather continue and print a statistics X passed out of Y.
> Check how it's done, for example, in other test_* modules.
> (test_printf.c comes first to my mind).
I see it's done that way elsewhere, but I don't really see the point. It
makes the test code more complex, and if you fail here you'd better fix
it, and if you need a few iterations for that it's not really a problem?
johannes
next prev parent reply other threads:[~2018-06-18 20:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 19:56 [PATCH v3] bitfield: fix *_encode_bits() Johannes Berg
2018-06-18 20:21 ` Andy Shevchenko
2018-06-18 20:28 ` Johannes Berg [this message]
2018-06-18 20:33 ` Jakub Kicinski
2018-06-18 20:40 ` Andy Shevchenko
2018-06-18 20:42 ` Johannes Berg
2018-06-18 20:46 ` Andy Shevchenko
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=1529353683.3092.32.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=andy.shevchenko@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.