From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by sourceware.org (Postfix) with ESMTPS id 2F8FC384403E for ; Tue, 27 Apr 2021 22:58:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2F8FC384403E Received: by mail-qv1-xf29.google.com with SMTP id j3so29876750qvs.1 for ; Tue, 27 Apr 2021 15:58:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=2joQQCWE7xVTANyvEHKaBM9DHwLhiA6C7vRqqGkYzdQ=; b=rY5UPGh3AW2CzcE15BNkhcaMTUi1TvhthdQVi9FhE/BdG6e6xww2kybeRzqa3p/A4J s/+UlWp2l4c9Hx1wLm6vRmvt/uf/Mm5zQ411u7GLk3v9gWZpEOPPETXt1Hlf8r81qxnk 8U8TIeSouX9zkzlNCGBKRwDn8dcn1MHVf3pTwUmoj/W89zDb2viEBbsxxmQyi9uOIFsT 2VY5TRNJDbebFlX12D3pEdnI84CE7k5Py2mi2bvB97qmmXZ2lPqguI5XX34pgUwZCXtK JbJWc9/pLF/MuQCWP9rJ19stS3n4dBvSJ0Q5NzVNWyi1TCKBEvyklp1B6msDGzUKDWRz T1Lg== X-Gm-Message-State: AOAM531Gt4GjTGAgVdk63wWgXhD4XbSUtlpoh/bB1t8aj9jWIv3n5f1g lhChT48sgqtkwQPemfQM1w51d5u2YrM= X-Google-Smtp-Source: ABdhPJwM+oXqiL0M/6pyDymegHiGoyJhwNk+Jyc0ZTi9K5oRgUXxMxpOW+sGPgMSxOQxBVVE6TgGEA== X-Received: by 2002:ad4:4729:: with SMTP id l9mr3253357qvz.30.1619564280546; Tue, 27 Apr 2021 15:58:00 -0700 (PDT) Received: from [192.168.0.41] (71-218-14-121.hlrn.qwest.net. [71.218.14.121]) by smtp.gmail.com with ESMTPSA id l16sm885959qtj.30.2021.04.27.15.57.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Apr 2021 15:57:59 -0700 (PDT) Subject: Re: [PATCH] add attribute none to pthread_setspecific (BZ #27714) To: Joseph Myers Cc: Florian Weimer , Martin Sebor via Libc-alpha References: <2ec7fadb-cc15-a005-f708-d2adecc8cc39@gmail.com> <875z08qqy8.fsf@oldenburg.str.redhat.com> <571eb466-8979-8579-3b52-38f29a628a39@gmail.com> From: Martin Sebor Message-ID: <47fc35d1-05b0-c02e-77dc-b3193aefd865@gmail.com> Date: Tue, 27 Apr 2021 16:57:58 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------8B9D2FC5CDDA0F6DD1ADD00C" Content-Language: en-US X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2021 22:58:02 -0000 This is a multi-part message in MIME format. --------------8B9D2FC5CDDA0F6DD1ADD00C Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit On 4/27/21 3:58 PM, Joseph Myers wrote: > On Tue, 27 Apr 2021, Martin Sebor via Libc-alpha wrote: > >> These are warnings in my build (I've seen a few others scroll by >> and have always assumed they were expected(*)). Those you pasted > > Most warnings are errors by default (unless you use --disable-werror, > which should never normally be used in glibc development unless you're > e.g. reviewing the warnings you get if you add extra warning options to > those with which glibc is built by default, in order to fix those warnings > before adding the extra options). Ah, that's what my build script does and I keep forgetting to change that when working on Glibc (as opposed to testing new GCC warnings). My bad. The attached diff patches up the tests to pass the function a valid argument. I'll plan to commit it shortly unless you prefer some other solution. Martin > >> I test by simply running make check. I can make the change to >> the test if you expect warning-free test builds. > > We expect builds, for all glibc ABIs, free from compile errors or failures > of tests that can run without needing to execute any code for the glibc > architecture. That means no warnings that are turned into errors by > -Werror. There are some warnings for which -Wno-error or pragmas are used > to stop them being errors; all other warnings are disallowed. > >> [*] Here's an example of a warning I just noticed while rerunning >> make check: >> >> tst-chk1.c: In function ‘do_test’: > > That's an example covered by -Wno-error. > > # We know these tests have problems with format strings, this is what > # we are testing. Disable that warning. They are also testing > # deprecated functions (notably gets) so disable that warning as well. > # And they also generate warnings from warning attributes, which > # cannot be disabled via pragmas, so require -Wno-error to be used. > CFLAGS-tst-chk1.c += -Wno-format -Wno-deprecated-declarations -Wno-error > > (Any code disabling any warnings or disabling -Werror for them is expected > to have a comment explaining why it's OK to do so in that case.) > --------------8B9D2FC5CDDA0F6DD1ADD00C Content-Type: text/x-patch; charset=UTF-8; name="glibc-tests-pthread_setspecific.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="glibc-tests-pthread_setspecific.diff" diff --git a/nptl/tst-tsd3.c b/nptl/tst-tsd3.c index 0dd39ccb2b..45c7e4e1ea 100644 --- a/nptl/tst-tsd3.c +++ b/nptl/tst-tsd3.c @@ -37,7 +37,8 @@ destr1 (void *arg) { puts ("set key2"); - if (pthread_setspecific (key2, (void *) 1l) != 0) + /* Use an arbirary but valid pointer to avoid GCC warnings. */ + if (pthread_setspecific (key2, (void *) &left) != 0) { puts ("destr1: setspecific failed"); exit (1); @@ -53,7 +54,8 @@ destr2 (void *arg) { puts ("set key1"); - if (pthread_setspecific (key1, (void *) 1l) != 0) + /* Use an arbirary but valid pointer to avoid GCC warnings. */ + if (pthread_setspecific (key1, (void *) &left) != 0) { puts ("destr2: setspecific failed"); exit (1); @@ -68,8 +70,9 @@ tf (void *arg) /* Let the destructors work. */ left = 7; - if (pthread_setspecific (key1, (void *) 1l) != 0 - || pthread_setspecific (key2, (void *) 1l) != 0) + /* Use an arbirary but valid pointer to avoid GCC warnings. */ + if (pthread_setspecific (key1, (void *) &left) != 0 + || pthread_setspecific (key2, (void *) &left) != 0) { puts ("tf: setspecific failed"); exit (1); diff --git a/nptl/tst-tsd4.c b/nptl/tst-tsd4.c index cc1ada4d4d..f45cf70e37 100644 --- a/nptl/tst-tsd4.c +++ b/nptl/tst-tsd4.c @@ -34,7 +34,8 @@ destr (void *arg) { ++rounds; - if (pthread_setspecific (key, (void *) 1l) != 0) + /* Use an arbirary but valid pointer to avoid GCC warnings. */ + if (pthread_setspecific (key, (void *) &rounds) != 0) { puts ("destr: setspecific failed"); exit (1); @@ -45,7 +46,7 @@ destr (void *arg) static void * tf (void *arg) { - if (pthread_setspecific (key, (void *) 1l) != 0) + if (pthread_setspecific (key, (void *) &rounds) != 0) { puts ("tf: setspecific failed"); exit (1); diff --git a/sysdeps/pthread/tst-key2.c b/sysdeps/pthread/tst-key2.c index 6828873e41..5662842035 100644 --- a/sysdeps/pthread/tst-key2.c +++ b/sysdeps/pthread/tst-key2.c @@ -56,7 +56,7 @@ tf (void *arg) { pthread_key_t *key = (pthread_key_t *) arg; - if (pthread_setspecific (*key, (void *) -1l) != 0) + if (pthread_setspecific (*key, (void *) arg) != 0) { write_message ("setspecific failed\n"); _exit (1); --------------8B9D2FC5CDDA0F6DD1ADD00C--