From: Petr Mladek <pmladek@suse.com>
To: Yannick Cote <ycote@redhat.com>
Cc: live-patching@vger.kernel.org, linux-kselftest@vger.kernel.org,
joe.lawrence@redhat.com
Subject: Re: [PATCH 2/4] selftests/livepatch: rework test-klp-shadow-vars
Date: Tue, 2 Jun 2020 11:25:00 +0200 [thread overview]
Message-ID: <20200602092500.GJ27273@linux-b0ei> (raw)
In-Reply-To: <20200528134849.7890-3-ycote@redhat.com>
On Thu 2020-05-28 09:48:47, Yannick Cote wrote:
> The initial idea was to make a change to please cppcheck and remove void
> pointer arithmetics found a few times:
>
> portability: 'obj' is of type 'void *'. When using void pointers
> in calculations, the behaviour is undefined.
> [arithOperationsOnVoidPointer]
>
> The rest of the changes are to help make the test read as an example
> while continuing to verify the shadow variable code. The logic of the
> test is unchanged but restructured to use descriptive names.
First, I really like this change. There are only few comments, see below.
> Signed-off-by: Yannick Cote <ycote@redhat.com>
> ---
> lib/livepatch/test_klp_shadow_vars.c | 101 +++++++++++++++------------
> 1 file changed, 57 insertions(+), 44 deletions(-)
>
> diff --git a/lib/livepatch/test_klp_shadow_vars.c b/lib/livepatch/test_klp_shadow_vars.c
> index f0b5a1d24e55..ec2635cff974 100644
> --- a/lib/livepatch/test_klp_shadow_vars.c
> +++ b/lib/livepatch/test_klp_shadow_vars.c
> + * The main test case adds/removes new fields (shadow var) to each of these
> + * test structure instances. The last group of fields in the struct represent
> + * the idea that shadow variables may be added and removed to and from the
> + * struct during execution.
> + */
> +struct test_object {
> + /* add anything here below and avoid to define an empty struct */
> + struct shadow_ptr sp;
I was confused why the orignal structure included shadow pointer
from the start. And it is because struct shadow_ptr is unrelated
to the tested livepatch shadow variable API.
This selftest is quite complicated even without this confusion.
It would be nice to rename struct shadow_ptr to struct ptr_id and
the varible to p_id. Or something to something like this.
It should be done in separate patch before or on top of this patchset.
I could send it if you do not want to invest more time into it.
>
> - int **sv;
> + /* these represent shadow vars added and removed with SV_ID{1,2} */
> + /* char nfield1; */
> + /* int nfield2; */
> +};
>
> @@ -188,23 +200,24 @@ static int test_klp_shadow_vars_init(void)
> * Verify we can find our new shadow variables and that they point
> * to expected data.
> */
> - sv = shadow_get(obj, id);
> + sv = shadow_get(&obj1, SV_ID1);
> if (!sv)
> return -EINVAL;
> - if (sv == sv1 && *sv1 == pv1)
> + if ((char **)sv == sv1 && *sv1 == pnfield1)
Are these casts of "sv" variable enough to get rid of the cppcheck
warnings? It would have been better to split the two changes
(warning fixes and code refactoring into two patches).
It is a hint for future patchse. I do not want to block this one
because of it. Feel free to use:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Best Regards,
Petr
next prev parent reply other threads:[~2020-06-02 9:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-28 13:48 [PATCH 0/4] selftests/livepatch: rework of test-klp-{callbacks,shadow_vars} Yannick Cote
2020-05-28 13:48 ` [PATCH 1/4] selftests/livepatch: rework test-klp-callbacks to use completion variables Yannick Cote
2020-06-02 8:16 ` Petr Mladek
2020-05-28 13:48 ` [PATCH 2/4] selftests/livepatch: rework test-klp-shadow-vars Yannick Cote
2020-06-02 9:25 ` Petr Mladek [this message]
2020-05-28 13:48 ` [PATCH 3/4] selftests/livepatch: more verification in test-klp-shadow-vars Yannick Cote
2020-06-01 11:27 ` Miroslav Benes
2020-06-01 11:39 ` Miroslav Benes
2020-06-02 12:35 ` Petr Mladek
2020-05-28 13:48 ` [PATCH 4/4] selftests/livepatch: fix mem leaks " Yannick Cote
2020-06-02 9:57 ` Petr Mladek
2020-05-29 15:12 ` [PATCH 0/4] selftests/livepatch: rework of test-klp-{callbacks,shadow_vars} Joe Lawrence
2020-06-01 11:48 ` Miroslav Benes
2020-06-02 5:01 ` Kamalesh Babulal
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=20200602092500.GJ27273@linux-b0ei \
--to=pmladek@suse.com \
--cc=joe.lawrence@redhat.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=ycote@redhat.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.
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 NNTP newsgroup(s).