From: zhang warden <zhangwarden@gmail.com>
To: Marcos Paulo de Souza <mpdesouza@suse.com>
Cc: Shresth Prasad <shresthprasad7@gmail.com>,
jpoimboe@kernel.org, jikos@kernel.org, mbenes@suse.cz,
pmladek@suse.com, joe.lawrence@redhat.com, shuah@kernel.org,
live-patching@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
skhan@linuxfoundation.org
Subject: Re: [PATCH] Fix implicit cast warning in test_klp_state.c
Date: Tue, 20 Feb 2024 14:06:10 +0800 [thread overview]
Message-ID: <FD18B42B-6B73-4B55-A9B2-272414531C26@gmail.com> (raw)
In-Reply-To: <20240219141606.6711-1-mpdesouza@suse.com>
Well, the repo location I use is git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git.
It seem klp_get_state return struct klp_state.
The definition of this function in my repo as follows:
struct klp_state *klp_get_state(struct klp_patch *patch, unsigned long id)
{
struct klp_state *state;
klp_for_each_state(patch, state) {
if (state->id == id)
return state;
}
return NULL;
}
EXPORT_SYMBOL_GPL(klp_get_state);
Are you sure there is really a need for forced conversion?
> 2024年2月19日 22:16,Marcos Paulo de Souza <mpdesouza@suse.com> 写道:
>
> On Sat, 17 Feb 2024 04:21:26 +0530 Shresth Prasad <shresthprasad7@gmail.com> wrote:
>
>> The function `klp_get_state` returns an `int` value, but the variable
>> `loglevel_state` is of type `struct klp_state *` and thus does an
>> implicit cast. Explicitly casting these values fixes:
>>
>> - warning: assignment to \u2018struct klp_state *\u2019 from \u2018int\u2019
>> makes pointer from integer without a cast [-Wint-conversion]
>>
>> on lines 38, 55, 68 and 80 of test_klp_state.c
>
> I was unable to find where you saw the klp_get_state returning int. I tried
> searching at the current master of live-patching repo[1], on linux-next. Can
> you point where do you saw it? For me, klp_get_state return a pointer to klp_state.
>
> Thanks,
> Marcos
>
> [1]: https://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching.git/tree/kernel/livepatch/state.c
>
>>
>> Signed-off-by: Shresth Prasad <shresthprasad7@gmail.com>
>> ---
>> .../selftests/livepatch/test_modules/test_klp_state.c | 8 ++++----
>> 1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_state.c b/tools/testing/selftests/livepatch/test_modules/test_klp_state.c
>> index 57a4253acb01..ae6b1ca15fc0 100644
>> --- a/tools/testing/selftests/livepatch/test_modules/test_klp_state.c
>> +++ b/tools/testing/selftests/livepatch/test_modules/test_klp_state.c
>> @@ -35,7 +35,7 @@ static int allocate_loglevel_state(void)
>> {
>> struct klp_state *loglevel_state;
>>
>> - loglevel_state = klp_get_state(&patch, CONSOLE_LOGLEVEL_STATE);
>> + loglevel_state = (struct klp_state *)klp_get_state(&patch, CONSOLE_LOGLEVEL_STATE);
>> if (!loglevel_state)
>> return -EINVAL;
>>
>> @@ -52,7 +52,7 @@ static void fix_console_loglevel(void)
>> {
>> struct klp_state *loglevel_state;
>>
>> - loglevel_state = klp_get_state(&patch, CONSOLE_LOGLEVEL_STATE);
>> + loglevel_state = (struct klp_state *)klp_get_state(&patch, CONSOLE_LOGLEVEL_STATE);
>> if (!loglevel_state)
>> return;
>>
>> @@ -65,7 +65,7 @@ static void restore_console_loglevel(void)
>> {
>> struct klp_state *loglevel_state;
>>
>> - loglevel_state = klp_get_state(&patch, CONSOLE_LOGLEVEL_STATE);
>> + loglevel_state = (struct klp_state *)klp_get_state(&patch, CONSOLE_LOGLEVEL_STATE);
>> if (!loglevel_state)
>> return;
>>
>> @@ -77,7 +77,7 @@ static void free_loglevel_state(void)
>> {
>> struct klp_state *loglevel_state;
>>
>> - loglevel_state = klp_get_state(&patch, CONSOLE_LOGLEVEL_STATE);
>> + loglevel_state = (struct klp_state *)klp_get_state(&patch, CONSOLE_LOGLEVEL_STATE);
>> if (!loglevel_state)
>> return;
>>
>> --
>> 2.43.1
>
next prev parent reply other threads:[~2024-02-20 6:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 22:51 [PATCH] Fix implicit cast warning in test_klp_state.c Shresth Prasad
2024-02-19 14:16 ` Marcos Paulo de Souza
2024-02-20 6:06 ` zhang warden [this message]
2024-02-20 11:53 ` Shresth Prasad
2024-02-20 12:00 ` Marcos Paulo de Souza
2024-02-20 13:20 ` Shresth Prasad
2024-02-21 2:38 ` zhang warden
2024-02-21 9:59 ` Shresth Prasad
2024-02-21 12:44 ` Nicolai Stange
2024-02-22 8:12 ` Shresth Prasad
[not found] ` <22981.124022107441100115@us-mta-655.us.mimecast.lan>
2024-02-21 18:26 ` Joe Lawrence
2024-02-22 8:35 ` Shresth Prasad
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=FD18B42B-6B73-4B55-A9B2-272414531C26@gmail.com \
--to=zhangwarden@gmail.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mpdesouza@suse.com \
--cc=pmladek@suse.com \
--cc=shresthprasad7@gmail.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.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