From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Petri Latvala <petri.latvala@intel.com>
Cc: igt-dev@lists.freedesktop.org, Intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH i-g-t 3/6] igt/core: Fix build warning
Date: Fri, 19 Nov 2021 15:34:54 +0000 [thread overview]
Message-ID: <8b1bdb41-fe31-8482-655d-724a6937d2c7@linux.intel.com> (raw)
In-Reply-To: <YZesawet06wfQ1SG@platvala-desk.ger.corp.intel.com>
On 19/11/2021 13:53, Petri Latvala wrote:
> On Fri, Nov 19, 2021 at 12:59:42PM +0000, Tvrtko Ursulin wrote:
>> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>>
>> .../lib/igt_thread.c: In function ‘__igt_unique____igt_constructor_l66’:
>> .../lib/igt_thread.c:68:9: warning: ‘pthread_setspecific’ expecting 1 byte in a region of size 0 [-Wstringop-overread]
>> 68 | pthread_setspecific(__igt_is_main_thread, (void*) 0x1);
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>> Cc: Petri Latvala <petri.latvala@intel.com>
>> ---
>> lib/igt_core.c | 6 ++++--
>> lib/igt_thread.c | 4 +++-
>> 2 files changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/lib/igt_core.c b/lib/igt_core.c
>> index ec05535cd56e..acb9743c4a24 100644
>> --- a/lib/igt_core.c
>> +++ b/lib/igt_core.c
>> @@ -2752,6 +2752,8 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format,
>> char *line, *formatted_line;
>> char *thread_id;
>> const char *program_name;
>> + const uintptr_t false_key = 0;
>> + const uintptr_t true_key = 1;
>> const char *igt_log_level_str[] = {
>> "DEBUG",
>> "INFO",
>> @@ -2796,9 +2798,9 @@ void igt_vlog(const char *domain, enum igt_log_level level, const char *format,
>> }
>>
>> if (line[strlen(line) - 1] == '\n')
>> - pthread_setspecific(__vlog_line_continuation, (void*) false);
>> + pthread_setspecific(__vlog_line_continuation, &false_key);
>> else
>> - pthread_setspecific(__vlog_line_continuation, (void*) true);
>> + pthread_setspecific(__vlog_line_continuation, &true_key);
>
> Quoting the usage of this:
> if (pthread_getspecific(__vlog_line_continuation)) {
>
> That's going to give a non-null pointer in both cases.
Doh..
>
>
>
>>
>> /* append log buffer */
>> _igt_log_buffer_append(formatted_line);
>> diff --git a/lib/igt_thread.c b/lib/igt_thread.c
>> index 5bdda4102def..f5de2d57eaaa 100644
>> --- a/lib/igt_thread.c
>> +++ b/lib/igt_thread.c
>> @@ -64,6 +64,8 @@ bool igt_thread_is_main(void)
>> }
>>
>> igt_constructor {
>> + const uintptr_t key = 1;
>> +
>> pthread_key_create(&__igt_is_main_thread, NULL);
>> - pthread_setspecific(__igt_is_main_thread, (void*) 0x1);
>> + pthread_setspecific(__igt_is_main_thread, &key);
>
> This is fine, __igt_is_main_thread key will have non-null only on the
> main thread. But still a bit sus slapping the address of a
> function-local variable to setspecific, we might just be trading a
> compiler warning for a new future one.
And this is then the same - why do you say this one is okay? :)
Okay I wasn't sufficiently focused while trying to fix this. No idea
then apart for playing with pragmas.
Regards,
Tvrtko
next prev parent reply other threads:[~2021-11-19 15:35 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 12:59 [Intel-gfx] [PATCH i-g-t 1/6] tests/api_intel_allocator: Fix build warning Tvrtko Ursulin
2021-11-19 12:59 ` [Intel-gfx] [PATCH i-g-t 2/6] igt/drm_read: " Tvrtko Ursulin
2021-11-19 12:59 ` [Intel-gfx] [PATCH i-g-t 3/6] igt/core: " Tvrtko Ursulin
2021-11-19 13:53 ` Petri Latvala
2021-11-19 15:34 ` Tvrtko Ursulin [this message]
2021-11-19 15:41 ` Petri Latvala
2021-11-19 15:54 ` [Intel-gfx] [igt-dev] " Petri Latvala
2021-11-22 9:03 ` Tvrtko Ursulin
2021-11-19 12:59 ` [Intel-gfx] [PATCH i-g-t 4/6] igt/drm_read: " Tvrtko Ursulin
2021-11-19 12:59 ` [Intel-gfx] [PATCH i-g-t 5/6] intel_gpu_top: Remove clients support Tvrtko Ursulin
2021-11-26 13:07 ` [Intel-gfx] [igt-dev] " Tvrtko Ursulin
2021-11-26 14:01 ` Petri Latvala
2021-11-26 14:16 ` Tvrtko Ursulin
2021-11-19 12:59 ` [Intel-gfx] [PATCH i-g-t 6/6] intel_gpu_top: Add a sanity check discovered busy metric is per engine Tvrtko Ursulin
2021-12-01 2:20 ` Rogozhkin, Dmitry V
2021-12-01 10:06 ` Tvrtko Ursulin
2021-11-22 5:58 ` [Intel-gfx] [PATCH i-g-t 1/6] tests/api_intel_allocator: Fix build warning Zbigniew Kempczyński
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=8b1bdb41-fe31-8482-655d-724a6937d2c7@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=igt-dev@lists.freedesktop.org \
--cc=petri.latvala@intel.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