From patchwork Wed Sep 25 08:20:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11160177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66E9376 for ; Wed, 25 Sep 2019 08:20:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 41DF520673 for ; Wed, 25 Sep 2019 08:20:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K4nDs+GM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406867AbfIYIU6 (ORCPT ); Wed, 25 Sep 2019 04:20:58 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39679 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405820AbfIYIU6 (ORCPT ); Wed, 25 Sep 2019 04:20:58 -0400 Received: by mail-pf1-f194.google.com with SMTP id v4so2932075pff.6 for ; Wed, 25 Sep 2019 01:20:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Y4y/D8zv33L9ePnaNbr7hbkgJuk1SAD4LmlOAkXliKo=; b=K4nDs+GMrBFyObRImny42Wztj1UBKjWOV9kLs/zFQMbe29HEBR5q/7zZ4f7bRl2bFo dlcrjxMNePD+UT3x8nG19MzjC/vCR364DqRgulhum/t271Cm3q5qYwCXxLeE8d1JVmPI hKf8jXNXBUfmMLVyjO3RVXJeeC0IdfJRk5bPb6Iup7rbiIEGVWpdimhrQOc39xXzpgmB mwv+QvwFag7kjJlUWeS0ZIIEwU+TOo9StlSakeMEHvClaY1Iorqww9jvw+ifE8veLjAa LrqAhjc7e9d9QkFBkv2JJdPLaWBd3ZVnCRxfjctdqZLczrKlJwyRAKD4zhvm4h2wUMdU NvNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Y4y/D8zv33L9ePnaNbr7hbkgJuk1SAD4LmlOAkXliKo=; b=Tf5iE9xSKnxxuQhXuyq5ab+ugbcHmBu/YQzBkSOgiCYJSo+BefVLrvyRREIe1mdNHF QEu/bqIAAzAFom+bHK+jIfNydmVU2SG+AhhHcdfA7B6KzXvR6lafZdFU9uZFHXkbLqdk FlmM8Lfn1WojJyUIJpQoQ9uWUhfLzYTqENYUOycGnJYppvVs/uqm+4pEiXlt1bceuS7x u5u2rA3rhfyOLYHwqlymUqKDM3xVSkhUsZxmJUexPPmeaAw6qn2k5LIdpns8m/dJV3VT Av8riF+OkO/Od+1mD8BtO9C26yHy9LTmG8eJBJFwEhefr9VRCHkzg7ELb2eTENBJ8C/5 nj1g== X-Gm-Message-State: APjAAAW9eqcB9Akh65Np86iGfcMVuHCxQV7GD3nKjg1F9IIh/XH9XtM7 h7A0EJTvbV652mItIh2eJtLtgIKx X-Google-Smtp-Source: APXvYqyhtwmPBrcYETgMpscpONx1P8cJJiM3ljGNMhQLcgiU1opozzdZHtRvr77l0GI+Lmwgk5/B5w== X-Received: by 2002:a63:120a:: with SMTP id h10mr7266187pgl.29.1569399656047; Wed, 25 Sep 2019 01:20:56 -0700 (PDT) Received: from archbookpro.localdomain ([2601:646:280:1b30::6486]) by smtp.gmail.com with ESMTPSA id i6sm6076326pfq.20.2019.09.25.01.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 01:20:55 -0700 (PDT) Date: Wed, 25 Sep 2019 01:20:53 -0700 From: Denton Liu To: Git Mailing List Cc: Jeff King Subject: [PATCH v2 1/4] apply.h: include missing header Message-ID: <74efb6c04c1081d73be4c2666fa45ff2807464c3.1569398897.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When running `make hdr-check`, we got the following error messages: apply.h:146:22: error: use of undeclared identifier 'GIT_MAX_HEXSZ' char old_oid_prefix[GIT_MAX_HEXSZ + 1]; ^ apply.h:147:22: error: use of undeclared identifier 'GIT_MAX_HEXSZ' char new_oid_prefix[GIT_MAX_HEXSZ + 1]; ^ apply.h:151:33: error: array has incomplete element type 'struct object_id' struct object_id threeway_stage[3]; ^ ./strbuf.h:79:8: note: forward declaration of 'struct object_id' struct object_id; ^ 3 errors generated. make: *** [apply.hco] Error 1 Include the missing "hash.h" header to fix these errors. Signed-off-by: Denton Liu --- apply.h | 1 + 1 file changed, 1 insertion(+) diff --git a/apply.h b/apply.h index a795193435..da3d95fa50 100644 --- a/apply.h +++ b/apply.h @@ -1,6 +1,7 @@ #ifndef APPLY_H #define APPLY_H +#include "hash.h" #include "lockfile.h" #include "string-list.h" From patchwork Wed Sep 25 08:20:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11160179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2A39F76 for ; Wed, 25 Sep 2019 08:21:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08F5B2082F for ; Wed, 25 Sep 2019 08:21:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mTKo40GT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406889AbfIYIVA (ORCPT ); Wed, 25 Sep 2019 04:21:00 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43647 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405820AbfIYIVA (ORCPT ); Wed, 25 Sep 2019 04:21:00 -0400 Received: by mail-pf1-f194.google.com with SMTP id a2so2920301pfo.10 for ; Wed, 25 Sep 2019 01:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=lFcV47DB4Mjsk7x9zpQCBh38AxGXQgtojKWMVnYNzUs=; b=mTKo40GTFYAtlGk9Yb99nnhh9FNb8F9uB5I258SZciKS/2fdZAjZLBji+rYgsbTQCg qPKiGT49erRFEQxxxpSDOqgGeK0BuS0fnQg/7ZG81EmXbRzKCQg00R9NOxO1OYMfU0nc Ese9KqrZ2SAS1FJENO5fas0KJwBNKR9zU7xF8eRkSxz1wkmnOOLU3QsLsQKL3LZuHaAo WPF8HaHeJs2IND7CsoH/DUUIOZdRMJga5sOi1v5frj+JPSeZ6fI90KA/q3tPNpJ6ru6Q 1eII2NEfd1sGLN6y+TM8IrOjz2HC6TYhsa15bpdPC+/0r6FLyCJIDK/tD+l8pDP+9QKK No0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=lFcV47DB4Mjsk7x9zpQCBh38AxGXQgtojKWMVnYNzUs=; b=YYfjSErdx0qLGH3iIkOVIKZR4lxnI9oYOgIk3c9NUJ48LH/KlUAxIbatb68RGVt01r BG3io21bFyhbAnstblnV7qS12CoLxaENF1kmSO+AJ1pc7FtT0RiDeNNBjYk3VTTtTZoc Bp3jCn8sII/ZIkNsMzms/f1AMV2lrRnvR6Ez8glKQROvnJYlHxcqCJTMsmenCKOUeHZo rDtf316efC9blKJnzZPyUU0rhOJvyw790oUnBX3xrvsMUStWRo+uGM9E4xMdXpHkU8mT MFOaFpdu4RsGrTHAXKpSQ5nugqv5IdUdAHmXRj70pkCV8ZuV7WEtmAs2hAMNXhhU7Vp7 2tBQ== X-Gm-Message-State: APjAAAVOVotS4Mp2cMHZRLY2MZi/KGOz8JIySR3IcVI7RlkmYnCv3Y3/ PVJCpOuQ0yf7ZY12AFAWHXwP1eRe X-Google-Smtp-Source: APXvYqwWPb5N4B0LfK6+CdliO0figB2p/4EerY4ZMVaOPmWaSJmMpjtmL1ClFNhL8c7mETnHL7LIbQ== X-Received: by 2002:a17:90a:630b:: with SMTP id e11mr5209829pjj.132.1569399658857; Wed, 25 Sep 2019 01:20:58 -0700 (PDT) Received: from archbookpro.localdomain ([2601:646:280:1b30::6486]) by smtp.gmail.com with ESMTPSA id cx22sm1911596pjb.19.2019.09.25.01.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 01:20:58 -0700 (PDT) Date: Wed, 25 Sep 2019 01:20:56 -0700 From: Denton Liu To: Git Mailing List Cc: Jeff King Subject: [PATCH v2 2/4] promisor-remote.h: include missing header Message-ID: <2befc450fb04dde1f676ec9d0cf04da9b1a1ca70.1569398897.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When we ran `make hdr-check`, we got the following warning message: promisor-remote.h:21:46: warning: declaration of 'struct repository' will not be visible outside of this function [-Wvisibility] extern int promisor_remote_get_direct(struct repository *repo, ^ 1 warning generated. This was caused by a missing reference to `struct repository`, which is defined in "repository.h". Include this missing header to fix this warning. Signed-off-by: Denton Liu --- promisor-remote.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/promisor-remote.h b/promisor-remote.h index 8200dfc940..76e8d86c7c 100644 --- a/promisor-remote.h +++ b/promisor-remote.h @@ -1,6 +1,8 @@ #ifndef PROMISOR_REMOTE_H #define PROMISOR_REMOTE_H +#include "repository.h" + struct object_id; /* From patchwork Wed Sep 25 08:20:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11160181 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 906E476 for ; Wed, 25 Sep 2019 08:21:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6E7902082F for ; Wed, 25 Sep 2019 08:21:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X0bIL4We" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2442651AbfIYIVC (ORCPT ); Wed, 25 Sep 2019 04:21:02 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:46673 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405820AbfIYIVC (ORCPT ); Wed, 25 Sep 2019 04:21:02 -0400 Received: by mail-pf1-f194.google.com with SMTP id q5so2916509pfg.13 for ; Wed, 25 Sep 2019 01:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=dtq4xAmfsfRMOQJaGqblLA4XTcbRUfguxhPPP41y5Is=; b=X0bIL4WeyGKrlKNJ+0ZdkiWzeejMsBBiqTTzcIAWdFhfeFA6WEM5O0F1XE4xs0fvT6 As6gIOsjaMvVnvWHSzI4N8bqn4pKu/yaZtmhNHJUzEhDG88Yhx1SLuRMnDEpYOPwcVeb hG7iWPv6XYzTm6Wug+TpJ3HlBlgk+XBpXe4/aFdD/RgJQVXOc8LlraDraFK2PiMOyIMz zhzf7P4zCVFulCjpSquk6PBGBmozZ46XXrz/irf2CANEblYUciIL9M6vBaJYjNCV1xV9 w5IqC9WRYV2xDJGKfosUWZv8Ka4LhrYIq9rjnEG1ZS8+XNdJ8EIqg8NeHnCQ8WZQAglJ QU6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=dtq4xAmfsfRMOQJaGqblLA4XTcbRUfguxhPPP41y5Is=; b=LmLNtf6BzE/+gUdySzf2M4+A2yMqeyIho4rCixyK8Imxa1vakVk4MnOlbQDeXSzbiB 3mmb6Yujv1Jfj0en4DiPJd5wcP8xCO8kQCYeXrR70i8Fl/OUu8eDZdu5DSbwNnNSzEUy nJHacuTXy2S3FJehCyRWpm9V9PINYd3jcdCVcCyIXg1WfrB6KiSgw7cjzK5dYxLaJQ/g ZD+7l0Nv2UvShHGXMJXV1AXSAc2haopI8kBbKVRtTRecnD43OfyesG53J9VYFqu8RCZq gKBPNNOiKxKb8QSIAvndlw18+ooCyQrK2kX5VOwqDpEJPcPvKo17EsnWUwJgqeHD+ncL gdGA== X-Gm-Message-State: APjAAAX6gbXNgkFsBLkD/rXhUogTcCa/Yai8yIJN+3OCRCybpVAKG+Ny 92Khk6b5xJ6eFhHujmXAmLnz7SRc X-Google-Smtp-Source: APXvYqyZd2cAqnsoohmqBgO/XPZFn1Zrw55O9F1yHYQoW95GZM+sxTpMFDwOtPiiHX22uw6k5S6ygw== X-Received: by 2002:a63:1b07:: with SMTP id b7mr7586706pgb.90.1569399661284; Wed, 25 Sep 2019 01:21:01 -0700 (PDT) Received: from archbookpro.localdomain ([2601:646:280:1b30::6486]) by smtp.gmail.com with ESMTPSA id f89sm2478923pje.20.2019.09.25.01.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 01:21:00 -0700 (PDT) Date: Wed, 25 Sep 2019 01:20:59 -0700 From: Denton Liu To: Git Mailing List Cc: Jeff King Subject: [PATCH v2 3/4] pack-bitmap.h: remove magic number Message-ID: <50e37c16f9715bb6bc41940545c779f6aa9f6be4.1569398897.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When we ran `make hdr-check` with the following patch diff --git a/Makefile b/Makefile index f879697ea3..d8df4e316b 100644 --- a/Makefile +++ b/Makefile @@ -2773,7 +2773,7 @@ CHK_HDRS = $(filter-out $(EXCEPT_HDRS),$(patsubst ./%,%,$(LIB_H))) HCO = $(patsubst %.h,%.hco,$(CHK_HDRS)) $(HCO): %.hco: %.h FORCE - $(QUIET_HDR)$(CC) -include git-compat-util.h -I. -o /dev/null -c -xc $< + $(QUIET_HDR)$(CC) -include git-compat-util.h -I. -o /dev/null -c -xc $(ALL_CFLAGS) $< .PHONY: hdr-check $(HCO) hdr-check: $(HCO) and with `DEVELOPER=1`, we got the following warning on Arch Linux: pack-bitmap.h:20:19: error: ‘BITMAP_IDX_SIGNATURE’ defined but not used [-Werror=unused-const-variable=] 20 | static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'}; | ^~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors "Use" the BITMAP_IDX_SIGNATURE variable by making the size of bitmap_disk_header.magic equal to the size of BITMAP_IDX_SIGNATURE, thereby eliminating the magic number (4). An alternative was to simply add MAYBE_UNUSED, however that does not eliminate the magic number. Another alternative was to change the definition to extern const char BITMAP_IDX_SIGNATURE[4]; However, this design was also not chosen as the static definition allows us to keep the declaration together for readability along with removing the magic number. Signed-off-by: Denton Liu --- pack-bitmap.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pack-bitmap.h b/pack-bitmap.h index 00de3ec8e4..466c5afa09 100644 --- a/pack-bitmap.h +++ b/pack-bitmap.h @@ -9,16 +9,16 @@ struct commit; struct repository; struct rev_info; +static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'}; + struct bitmap_disk_header { - char magic[4]; + char magic[ARRAY_SIZE(BITMAP_IDX_SIGNATURE)]; uint16_t version; uint16_t options; uint32_t entry_count; unsigned char checksum[GIT_MAX_RAWSZ]; }; -static const char BITMAP_IDX_SIGNATURE[] = {'B', 'I', 'T', 'M'}; - #define NEEDS_BITMAP (1u<<22) enum pack_bitmap_opts { From patchwork Wed Sep 25 08:21:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11160183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8FD2D76 for ; Wed, 25 Sep 2019 08:21:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6D6F42082F for ; Wed, 25 Sep 2019 08:21:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dT60H5tu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406904AbfIYIVF (ORCPT ); Wed, 25 Sep 2019 04:21:05 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44151 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405820AbfIYIVF (ORCPT ); Wed, 25 Sep 2019 04:21:05 -0400 Received: by mail-pf1-f193.google.com with SMTP id q21so2920728pfn.11 for ; Wed, 25 Sep 2019 01:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=c1yeFComJdT3K3FcVq/cpP/e6NGVkjr/1fSwE2QW0lU=; b=dT60H5tu4USejW7X0oc9uhIQo+4RMy+CPKjttAne6wW3siPZ/4f/2fYLNsA995BFy4 eW/4qlty7FfrxrF2iTCKserKIw/ZVmkdwB5Fprm/3Ey9YwpE8zJ0dJ/CXKnIyrMDMNTQ iZWtTeS3IkOCPnVFX/w72RpZPoYfcRWbnxfKn7yTht+21wiq6R2h9iGB10nZL6os/0nJ FFozHCbjRMVl0By/uqAsuPCfHRFXA3leLur0oPyeAjz6czDW/dmrLCyXOv5UYnF+XDsV yjqlNmmjL1SJHacZhn1P6LreH0r2+cI2bvQd9X1Y9Eao/tyXRR858GOUCLhMolaoccsv 4hCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=c1yeFComJdT3K3FcVq/cpP/e6NGVkjr/1fSwE2QW0lU=; b=gWWS68EWnSHrV9y43gYpHfN3x6h53LztXytqo7QCTXMyt104nF/I7xsoXQipyKSyaj 2OronVZGiBdnKhnIbHWUuWAN0PmVyEb7/sppyXw2wpUDBOdvBUZf+Dpr4uHhRZX6H/yd Np6c3WCjoZ4w3K8nwhUeaX5QFIfQxTDJnzbqW+8lEAjbAjD8azR/xBlZqAo69j8D5nXW 5WadKP4+OoPNRp3KMMEZJ6Yojn8whKy+4wgteR4QftAgVzX7fi+fZQjzWkFaO+sn030Y B5py7tX78it2y01NE4NkllN2bLBI0xIdSzLHRPozll/iE14czTk6qibjQbYPCn1CkQXW rdKQ== X-Gm-Message-State: APjAAAV4XyhX6XMpt2dasmg/98TVvTEAjNAtjzegUU2Mg6Tj1dHX2RLI Zo8UV3VzfO2yq1bSDIg6IODpCmWo X-Google-Smtp-Source: APXvYqyRXbcaQIiYUINnZJ+SY9P3AFi2YgjZHEa7lxhnkWU1OTHg4xcOXRMWNHnzLpruckWGodstQQ== X-Received: by 2002:a63:4661:: with SMTP id v33mr7584944pgk.258.1569399664143; Wed, 25 Sep 2019 01:21:04 -0700 (PDT) Received: from archbookpro.localdomain ([2601:646:280:1b30::6486]) by smtp.gmail.com with ESMTPSA id g12sm8317913pfb.97.2019.09.25.01.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2019 01:21:03 -0700 (PDT) Date: Wed, 25 Sep 2019 01:21:01 -0700 From: Denton Liu To: Git Mailing List Cc: Jeff King Subject: [PATCH v2 4/4] Makefile: emulate compile in $(HCO) target better Message-ID: <14def72319521d7380fb6a8ec570d014c0f5361b.1569398897.git.liu.denton@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.1 (2019-06-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, when testing headers using `make hdr-check`, headers are directly compiled. Although this seems to test the headers, this is too strict since we treat the headers as C sources. As a result, this will cause warnings to appear that would otherwise not, such as a static variable definition intended for later use throwing a unused variable warning. In addition, on platforms that can run `make hdr-check` but require custom flags, this target was failing because none of them were being passed to the compiler. For example, on MacOS, the NO_OPENSSL flag was being set but it was not being passed into compiler so the check was failing. Fix these problems by emulating the compile process better, including test compiling dummy *.hcc C sources generated from the *.h files and passing $(ALL_CFLAGS) into the compiler for the $(HCO) target so that these custom flags can be used. Helped-by: Jeff King Signed-off-by: Denton Liu --- Peff, thanks for the suggestion! I modified it a little bit so that we wouldn't have to keep regenerating the *.hcc files unnecessarily. I also considered piping into the compiler's stdin directly which I know works for GCC (and _probably_ Clang) but I opted against it because I'm not sure it's portable for other compilers. Maybe it's alright for this to be less portable since it's a developer target? .gitignore | 1 + Makefile | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 521d8f4fb4..34efe125cb 100644 --- a/.gitignore +++ b/.gitignore @@ -216,6 +216,7 @@ /tags /TAGS /cscope* +*.hcc *.obj *.lib *.res diff --git a/Makefile b/Makefile index f879697ea3..581cc617e3 100644 --- a/Makefile +++ b/Makefile @@ -1872,7 +1872,7 @@ ifndef V QUIET_MSGFMT = @echo ' ' MSGFMT $@; QUIET_GCOV = @echo ' ' GCOV $@; QUIET_SP = @echo ' ' SP $<; - QUIET_HDR = @echo ' ' HDR $<; + QUIET_HDR = @echo ' ' HDR $(<:hcc=h); QUIET_RC = @echo ' ' RC $@; QUIET_SUBDIR0 = +@subdir= QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \ @@ -2771,9 +2771,14 @@ ifndef GCRYPT_SHA256 endif CHK_HDRS = $(filter-out $(EXCEPT_HDRS),$(patsubst ./%,%,$(LIB_H))) HCO = $(patsubst %.h,%.hco,$(CHK_HDRS)) +HCC = $(HCO:hco=hcc) -$(HCO): %.hco: %.h FORCE - $(QUIET_HDR)$(CC) -include git-compat-util.h -I. -o /dev/null -c -xc $< +%.hcc: %.h + @echo '#include "git-compat-util.h"' >$@ + @echo '#include "$<"' >>$@ + +$(HCO): %.hco: %.hcc FORCE + $(QUIET_HDR)$(CC) $(ALL_CFLAGS) -o /dev/null -c -xc $< .PHONY: hdr-check $(HCO) hdr-check: $(HCO) @@ -3082,6 +3087,7 @@ clean: profile-clean coverage-clean cocciclean $(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X $(RM) $(TEST_PROGRAMS) $(RM) $(FUZZ_PROGRAMS) + $(RM) $(HCC) $(RM) -r bin-wrappers $(dep_dirs) $(RM) -r po/build/ $(RM) *.pyc *.pyo */*.pyc */*.pyo command-list.h $(ETAGS_TARGET) tags cscope*