From patchwork Fri Sep 14 23:29:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramsay Jones X-Patchwork-Id: 10601301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1B8BE112B for ; Fri, 14 Sep 2018 23:29:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDCEF2B989 for ; Fri, 14 Sep 2018 23:29:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E278A2B98C; Fri, 14 Sep 2018 23:29:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E5CE2B989 for ; Fri, 14 Sep 2018 23:29:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726379AbeIOEqB (ORCPT ); Sat, 15 Sep 2018 00:46:01 -0400 Received: from avasout06.plus.net ([212.159.14.18]:43221 "EHLO avasout06.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725198AbeIOEqB (ORCPT ); Sat, 15 Sep 2018 00:46:01 -0400 Received: from [10.0.2.15] ([80.189.70.183]) by smtp with ESMTPA id 0xWcg6RG5WLW20xWdgsirF; Sat, 15 Sep 2018 00:29:24 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.3 cv=fJUXI6Se c=1 sm=1 tr=0 a=6SF67mWK+VR8hB1Kjo6y2g==:117 a=6SF67mWK+VR8hB1Kjo6y2g==:17 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=9kUiEBAvZ1GatkcJHBQA:9 a=QEXdDO2ut3YA:10 a=yJM6EZoI5SlJf8ks9Ge_:22 X-AUTH: ramsayjones@:2500 To: Ben Peart Cc: Junio C Hamano , GIT Mailing-list From: Ramsay Jones Subject: [PATCH] read-cache.c: fix a sparse warning Message-ID: Date: Sat, 15 Sep 2018 00:29:22 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Language: en-GB X-CMAE-Envelope: MS4wfN33B43BSkh6NjLLPXiaTLA/dDNRyBHDaBM2yvjatRo0aObgMfRg+ra4QupxW57rirpKhlFKnKUs0xhaX1c981Q4l+G8ACH1OhcpzkaHhyw2G1GSQpZ0 SOqujADaeK3zQXaNd1Wg8iVANj6ebqA7HkBWrrwgnsr42EN5cevq9qeTzMgJVOFJy7kUF3K1AzLj5Q== Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP At one time, the POSIX standard required the type used to represent a thread handle (pthread_t) be an arithmetic type. This is no longer the case, probably because different platforms used to regularly ignore that requirement. For example, on cygwin a pthread_t is a pointer to a structure (a quite common choice), whereas on Linux it is defined as an 'unsigned long int'. On cygwin, but not on Linux, 'sparse' currently complains about an initialiser used on a 'struct load_index_extensions' variable, whose first field may be a pthread handle (if not compiled with NO_PTHREADS set). In order to fix the warning, move the (conditional) pthread field to the end of the struct and change the initialiser to use a NULL, since the new (unconditional) first field is a pointer type. Signed-off-by: Ramsay Jones --- Hi Ben, If you need to re-roll your 'bp/read-cache-parallel' branch, could you please squash this into the relevant patch (commit a090af334, "read-cache: load cache extensions on a worker thread", 2018-09-12). Thanks. ATB, Ramsay Jones read-cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/read-cache.c b/read-cache.c index b27dc01696..6254291742 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1908,13 +1908,13 @@ static void write_eoie_extension(struct strbuf *sb, git_hash_ctx *eoie_context, struct load_index_extensions { -#ifndef NO_PTHREADS - pthread_t pthread; -#endif struct index_state *istate; const char *mmap; size_t mmap_size; unsigned long src_offset; +#ifndef NO_PTHREADS + pthread_t pthread; +#endif }; static void *load_index_extensions(void *data) @@ -2145,7 +2145,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) const struct cache_header *hdr; const char *mmap; size_t mmap_size; - struct load_index_extensions p = { 0 }; + struct load_index_extensions p = { NULL }; unsigned long extension_offset = 0; #ifndef NO_PTHREADS int cpus, nr_threads;