From patchwork Tue Mar 16 16:17:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C496C433E0 for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26AE364FF2 for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238568AbhCPQSP (ORCPT ); Tue, 16 Mar 2021 12:18:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238588AbhCPQR4 (ORCPT ); Tue, 16 Mar 2021 12:17:56 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9850C061756 for ; Tue, 16 Mar 2021 09:17:55 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id e10so10766191wro.12 for ; Tue, 16 Mar 2021 09:17:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BrjHOAcGbWnM3qrLtxpCpFY34ylFHw5YWtJbZd8GhSg=; b=mPEWm78hqvbBpmJphtSs4/O4emed9GHagk3FPTIUVPm0fR8TdFb35Fee1nXJYEDUUq maDzGDlTkdnJCj3l0q+IuXdgxfVi8hj5tzDhXoVX4nFcr1O1zd4DVdA8pLeXcVTinTo0 VsSVS+3NA+nONUqMWKUn/cWw+T4epf/xoysckAQwFeTFkaOffZJAonsbuGMUVjkyb660 g3PIy1sUYBsM10G6rGO240q9YhmJ2APs/0nNa/u+iUswHbrOKvtS/+0qjv4mS0hC7J/F y79dIp4Pof9TdgJrwXh1HbdSHZe8VdLKLv7xcpd6nMRsfN7yh4RS/ycZbJ79+ZQ2CcTX lGww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BrjHOAcGbWnM3qrLtxpCpFY34ylFHw5YWtJbZd8GhSg=; b=AtAUhi7KkYWDyBgjLr3Bb6BWF77cjc+zapH5rLvY7XzRjZNivRzovxYhROXjpivzjK rVBL7Jgp0lK3FRbvZo8QAlisrzIr7xLogmvLmBi24rdfGzqjGbRzVHmgizYu8dlKBk7o kpccyJC1itlpSwZ4l6g2WV/GU+Vocrl5z0wqDznaTFz/bzeZNbud8fStsd+Z0Hsop26N SOfcvV0EwEZjOkX7ejbmVFY6YR6n4226fW98ZyFM9q9owdTSXufe1whwcGw+cTGQNkZY B10uxB+qNUPKUh+ZrhTAVl0FtC4wi/bn1P/lCH2uYR99L5JmgdIazO8XEIt+qsh6SHFq ZyNg== X-Gm-Message-State: AOAM533QmW2qmFCv88rwVnE4cjL32ep2qfSqsqN0Doa3e51cfO5FruYA Tf15LIOWaktUzxjqY6gJi9KHGKQa+n1Nnw== X-Google-Smtp-Source: ABdhPJyo3GH0XHYPzLd29HcCUrmKmqTaPlXNOO4WwfaZodRg6ynlO21xqufUChjqmiO0dLfb0OssbQ== X-Received: by 2002:a5d:42ca:: with SMTP id t10mr5785896wrr.274.1615911474300; Tue, 16 Mar 2021 09:17:54 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.17.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:17:53 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 01/22] fsck.h: update FSCK_OPTIONS_* for object_name Date: Tue, 16 Mar 2021 17:17:17 +0100 Message-Id: <20210316161738.30254-2-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add the object_name member to the initialization macro. This was omitted in 7b35efd734e (fsck_walk(): optionally name objects on the go, 2016-07-17) when the field was added. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fsck.h b/fsck.h index 733378f126..2274843ba0 100644 --- a/fsck.h +++ b/fsck.h @@ -43,8 +43,8 @@ struct fsck_options { kh_oid_map_t *object_names; }; -#define FSCK_OPTIONS_DEFAULT { NULL, fsck_error_function, 0, NULL, OIDSET_INIT } -#define FSCK_OPTIONS_STRICT { NULL, fsck_error_function, 1, NULL, OIDSET_INIT } +#define FSCK_OPTIONS_DEFAULT { NULL, fsck_error_function, 0, NULL, OIDSET_INIT, NULL } +#define FSCK_OPTIONS_STRICT { NULL, fsck_error_function, 1, NULL, OIDSET_INIT, NULL } /* descend in all linked child objects * the return value is: From patchwork Tue Mar 16 16:17:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142803 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D170AC4332B for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B26D065109 for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238599AbhCPQSY (ORCPT ); Tue, 16 Mar 2021 12:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238589AbhCPQR5 (ORCPT ); Tue, 16 Mar 2021 12:17:57 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC7BDC06175F for ; Tue, 16 Mar 2021 09:17:56 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id 124-20020a1c00820000b029010b871409cfso1780684wma.4 for ; Tue, 16 Mar 2021 09:17:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dPM5okOEyHNvWKGhu2yCkFeGzGVb7nwFgDrmg+xjHVM=; b=kgEvBfs8M/4bZAPVt6vcxrxGS++digd56ieIpjDv1l31qsL5LXXxawvbUqlE567k6y OpWe8RGKCgJBPoGC+xLfoo8uNl8FE2yHB9Q+tw4rQSJ5SyGBRAvzQM2U94KxxVo+l3u6 eNqRasugVuSiY5smBpeAkIbUkgfBqSeu2UDgvHIVlwqk3I2dCKTktiBDJ5EKhoiP1gZ+ fQfHm24XbpMrttA1tum7ZqUkZc1tsnBvBXQRZc+xZ0Ree7nkIiqKHLtQdoSJtWBcS2YZ 8wyekro2dw2dPleayA6lD9gbJaAEJ1TSRrwRoM5vUHXlMvGjlIFzfFUohNCtU7UL6s9p fUEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dPM5okOEyHNvWKGhu2yCkFeGzGVb7nwFgDrmg+xjHVM=; b=Zc5a6xQT1jCu1giWdTHDnUvcZySCfn9b6eUWu8jn9b/Eynjc7ZOt1uF/GylITEHEgI XOudL5/tUbcMcY2l4fapZsAny/RtT8W/yxdFOFc/tdbZJj3t8hmSWB90A5IaPIP2d+FG 9Y5b2etEpwuRuwhGeykkiV1CaQYus9XFp2UV8fFfaWqog88QiuZZyPhxKKydn7YgRp8Q Xc3STaapjI7UErZQWpa+loXEfmIKvlnYOjaNpd4PfwoN6+HLasAjIc5LSwucKKXzkbY4 Zc0x/hArQTaH3a5qBFz9zSDO8GFQNAC/TqlAfPxql+4fatgxJ6ber3fO90r2BCEvISCS judA== X-Gm-Message-State: AOAM5315Gbz2xGwibTK2DJQ9d88xAL0tjVYk+Q+3JBqb5rguc7bv2okr P3k41hTe6DBViYeMWQpI7ltHy7qBm6GUgw== X-Google-Smtp-Source: ABdhPJydE1Ow+KKs6zMTydJ8ljZLzCwpZuVfzS6S9yXI+/p/oyPzCLFP/o3Co6YyD8pP1P0ktLq/Iw== X-Received: by 2002:a7b:cf18:: with SMTP id l24mr381278wmg.182.1615911475292; Tue, 16 Mar 2021 09:17:55 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:17:54 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 02/22] fsck.h: use designed initializers for FSCK_OPTIONS_{DEFAULT,STRICT} Date: Tue, 16 Mar 2021 17:17:18 +0100 Message-Id: <20210316161738.30254-3-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fsck.h b/fsck.h index 2274843ba0..40f3cb3f64 100644 --- a/fsck.h +++ b/fsck.h @@ -43,8 +43,22 @@ struct fsck_options { kh_oid_map_t *object_names; }; -#define FSCK_OPTIONS_DEFAULT { NULL, fsck_error_function, 0, NULL, OIDSET_INIT, NULL } -#define FSCK_OPTIONS_STRICT { NULL, fsck_error_function, 1, NULL, OIDSET_INIT, NULL } +#define FSCK_OPTIONS_DEFAULT { \ + .walk = NULL, \ + .error_func = fsck_error_function, \ + .strict = 0, \ + .msg_type = NULL, \ + .skiplist = OIDSET_INIT, \ + .object_names = NULL, \ +} +#define FSCK_OPTIONS_STRICT { \ + .walk = NULL, \ + .error_func = fsck_error_function, \ + .strict = 1, \ + .msg_type = NULL, \ + .skiplist = OIDSET_INIT, \ + .object_names = NULL, \ +} /* descend in all linked child objects * the return value is: From patchwork Tue Mar 16 16:17:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142799 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C007EC43381 for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C31F6510A for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238610AbhCPQSU (ORCPT ); Tue, 16 Mar 2021 12:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235768AbhCPQR6 (ORCPT ); Tue, 16 Mar 2021 12:17:58 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1B70C061762 for ; Tue, 16 Mar 2021 09:17:57 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id r10-20020a05600c35cab029010c946c95easo1795618wmq.4 for ; Tue, 16 Mar 2021 09:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OpLn7XGIn7pKLLWVv9gQ+E/AKkWZ4G6PYzVuT44exgk=; b=eLQWL1D/5TB0VX/5n+rajtaDFCNa2agX1e6AE+/OkKcrztkk9v4NXu0N7y8bOSFSZK u+uP1+uPjAmIFoeKU05aR/9mpH7MNdLVUpLq7rE7pJbPODgJSmCzGL9van/Ea0hsjOnA P+igi5rciXSlySmjXdPUiEgECr9ZFUm0g/eupnPHC1o0VC3AaSKUtU7QcZDWyQXFSVAs rZtKM1pcrN4G8irrDwEL729a+u3i7ZiiFHusaz5i6bON4/S8QSJy+lf3HT7wv97grjaC gj0AdeJAa+zOccGg7dXa++DhAu/+aBHPBgMIuBw6tGkxHintq/hiSEuOXa6915t+yDEQ RXtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OpLn7XGIn7pKLLWVv9gQ+E/AKkWZ4G6PYzVuT44exgk=; b=eewp8pfE+YsXWE33+TBnqoBhYd61jnA8AmCI85isTFq2AiV6Xi4ZhJL2HAVWaQ6wnJ xr7fxOCXqAaqEhdLy+lSvLHq75e0Pjn8fIMf12V5fUcssBJlZ3aUK1/mX9apuPK/8ilw Mj/ieSZLWBp72UQiQ0D4WgKDa0TgJmBTvknl0zZW8YHWHKl+T8vjw7WI5cpkAENlJVg8 Tq/jkSkt8QGOFQmPBWh3JTkXKwwdfC2+KI3M7VxMSVfIaq0iiiHCDgBLu4qC7aa53OpZ LYu2lS8Gf6KxtU+51eJhBF/QM8sE53OhSoFctgnLD7pg3fgYteMGLUTlQFvolM5ROtpP L4Mw== X-Gm-Message-State: AOAM532fHmI1ZbzAjeTqnC7G0kPDjVuph5Lu7I+Kyh0R/0FjCIddh509 aB/z7SPaK7P8EHn8s4CUWbEyBPKIqBp50Q== X-Google-Smtp-Source: ABdhPJyDRJuEa8M4FcHW9ZsZRXSl4ohvC0prP5Q4ckwFYE39ltafLTKa5bPl9OinNXE62tDJT+OI9Q== X-Received: by 2002:a1c:7210:: with SMTP id n16mr380055wmc.13.1615911476243; Tue, 16 Mar 2021 09:17:56 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:17:55 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 03/22] fsck.h: reduce duplication between FSCK_OPTIONS_{DEFAULT,STRICT} Date: Tue, 16 Mar 2021 17:17:19 +0100 Message-Id: <20210316161738.30254-4-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Use a temporary macro to define what FSCK_OPTIONS_{DEFAULT,STRICT} have in common, and define the two in terms of that macro. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/fsck.h b/fsck.h index 40f3cb3f64..ea3a907ec3 100644 --- a/fsck.h +++ b/fsck.h @@ -43,22 +43,14 @@ struct fsck_options { kh_oid_map_t *object_names; }; -#define FSCK_OPTIONS_DEFAULT { \ +#define FSCK_OPTIONS_COMMON \ .walk = NULL, \ .error_func = fsck_error_function, \ - .strict = 0, \ .msg_type = NULL, \ .skiplist = OIDSET_INIT, \ - .object_names = NULL, \ -} -#define FSCK_OPTIONS_STRICT { \ - .walk = NULL, \ - .error_func = fsck_error_function, \ - .strict = 1, \ - .msg_type = NULL, \ - .skiplist = OIDSET_INIT, \ - .object_names = NULL, \ -} + .object_names = NULL, +#define FSCK_OPTIONS_DEFAULT { .strict = 0, FSCK_OPTIONS_COMMON } +#define FSCK_OPTIONS_STRICT { .strict = 1, FSCK_OPTIONS_COMMON } /* descend in all linked child objects * the return value is: From patchwork Tue Mar 16 16:17:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142797 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAEC3C433E9 for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7016E65108 for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238583AbhCPQSR (ORCPT ); Tue, 16 Mar 2021 12:18:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238590AbhCPQR7 (ORCPT ); Tue, 16 Mar 2021 12:17:59 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE75DC06174A for ; Tue, 16 Mar 2021 09:17:58 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id d15so10776593wrv.5 for ; Tue, 16 Mar 2021 09:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uqG/oiypWxs/T2AFfrd+LlTiGmoLK7qKkujxPs+b1Sg=; b=NAuGCNl4jBA1qa6K5T1AbJViarGslrVOcw7mp20Hp9Kz55AOw4CIho9AQPpuLM4l1D F6Ks06O9UNjL/kgfT8YyuTwe3u3TXJT55ZtsWTVOXohvHxhgVJwDTMXE6Hh/ZIjU0bsP qoMZSJJzTnXFxZB7UVTTVLlJojZSETlPYCOjQ44vHcqOS1q8o9nO9y21DK4S9KTPLlAg LHoUXlUhJLICinjr0oo5O30d7ohbg0DOsNZCMIVfH21i8j84a+SDqA+VwoNPBYNMytNF o1XwqVi1e9TywEczpuvOqtZX5vInPM8uMFYdOJOyc8LF8IXArsY5g5XYDH+tcMHp4Qc2 q8Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uqG/oiypWxs/T2AFfrd+LlTiGmoLK7qKkujxPs+b1Sg=; b=fDQY8GYFnF/mX8PiZCddq6gT1l/zM4LwB0VrerUmzYjpR+KCHYRjtUKglDJKc1KVVq lYdVgvmvSU2eu9u6uP7T5FBXSzRYMtdxOyY+TocC7VsJm9uF9hYH2GBRBQmF9bWdkdpe VVE+KVcB64TbjlhHLpeeQ4pIzlCXdVPh14hosEYYyL9GdnsrXKS537NLXJfPPWpPjXDE 8iJaKWywJlE2BdI8DRLn5WCFlP0ogeubxewZtHQFCqLXTX3yGOTMB2Zc6FPC0rEAG0ck PxZwnbqG5jh2TKptyuf9dyQ2dgWkTrLkmHL8T/DbrvwBJhFB4Ks9fUDjJTorG15rr8Bl QDkw== X-Gm-Message-State: AOAM533xgD14UlVtX5vh0/w1jC5PnnNVLJN/OB8UHjXDin9Hz8wom2Rn ctTkmv69k3EVOIP9c9YRJZKAh7XjPTqD9A== X-Google-Smtp-Source: ABdhPJyxyqZpsW6k8zjYbCcq3M5nzpmVeWHJgTL87iQbQMFXE3sJkp8bjHra11BW3/HkuJgTBgEZ6g== X-Received: by 2002:adf:83c2:: with SMTP id 60mr5668301wre.386.1615911477147; Tue, 16 Mar 2021 09:17:57 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:17:56 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 04/22] fsck.h: add a FSCK_OPTIONS_COMMON_ERROR_FUNC macro Date: Tue, 16 Mar 2021 17:17:20 +0100 Message-Id: <20210316161738.30254-5-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Add a FSCK_OPTIONS_COMMON_ERROR_FUNC macro for those that would like to use FSCK_OPTIONS_COMMON in their own initialization, but supply their own error functions. Nothing is being changed to use this yet, but in some subsequent commits we'll make use of this macro. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fsck.h b/fsck.h index ea3a907ec3..dc35924cbf 100644 --- a/fsck.h +++ b/fsck.h @@ -45,12 +45,15 @@ struct fsck_options { #define FSCK_OPTIONS_COMMON \ .walk = NULL, \ - .error_func = fsck_error_function, \ .msg_type = NULL, \ .skiplist = OIDSET_INIT, \ .object_names = NULL, -#define FSCK_OPTIONS_DEFAULT { .strict = 0, FSCK_OPTIONS_COMMON } -#define FSCK_OPTIONS_STRICT { .strict = 1, FSCK_OPTIONS_COMMON } +#define FSCK_OPTIONS_COMMON_ERROR_FUNC \ + FSCK_OPTIONS_COMMON \ + .error_func = fsck_error_function + +#define FSCK_OPTIONS_DEFAULT { .strict = 0, FSCK_OPTIONS_COMMON_ERROR_FUNC } +#define FSCK_OPTIONS_STRICT { .strict = 1, FSCK_OPTIONS_COMMON_ERROR_FUNC } /* descend in all linked child objects * the return value is: From patchwork Tue Mar 16 16:17:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142805 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDB7CC4332D for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE7256508A for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238619AbhCPQS3 (ORCPT ); Tue, 16 Mar 2021 12:18:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238591AbhCPQSA (ORCPT ); Tue, 16 Mar 2021 12:18:00 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6289CC06174A for ; Tue, 16 Mar 2021 09:17:59 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id w11so10752733wrr.10 for ; Tue, 16 Mar 2021 09:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=t5GujOGyCc6XRlnwNp5URnFxXJJA8BzYLaOfJ3L3J4o=; b=D+++QcDgGbOYfk62KwWfAKjySaxueeCTbE1G+pLwW2qZku0QLh2evL5EJdB3fgXt2o bYClImydSKvOvf76eNGEhdudI7cLqXfNdTqz8Kfr9HW7M7FrcFlaGpaCEUpkNUN0Is1N CvBj6xx7/q0PkpoCwHqeSJ1dpvOTf3/8vMqZMTiEGYF115msjhZEmFy3RN/XA5daReRa pVxeIwdfTkTXnqU2iXneFHIHdcFRf499swXD9NfPs/Xx/dhVax8wbdj5AXTm7R47P8fm pWIN5/JMOj4SHvKNExs4PUFxuZ/agNjIJ+wls+9j6gt4Fs0VZadeyQl6yEwyzrySc4e2 i8xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=t5GujOGyCc6XRlnwNp5URnFxXJJA8BzYLaOfJ3L3J4o=; b=QGxcYbIpmQpy7hqGF24jGXHxcff3hBBUmwkQ1vjoSP4zrpUqB9SFTbuk4/YnX1bH/9 VDABKlzAXbn+L4qLKaTOXllgAxKHE27p86yu73P6p+WTigcPhlTLM7DhHn/IXGMlEVfn mN2xU+G5tWTFxzpGthsUfBsLqzz+U3HM9FRKu5OxOEr9nViBxzgFD8oWoqlHMjBNxtsD +vB8lHY9SYW94TWo9NMGoxCG+eBU1DN4BtEUEa0pocXTDlIlLDK+rl3/KzoGdy6grq9Z D2HjA/Ui+yg/qYwOJ9xHUWo/BI8XbNRxzF7QwO39ZCaeRwi4vwVApll6gegNM6QZUXeD wkgA== X-Gm-Message-State: AOAM530C1PNq+F5NWTfly/WA74RYXoATlkzWxHoC+cr+yF1SA2NDCiSG 5lU2HUpR41SeiQV9bEetPAMcSMbLcwvavA== X-Google-Smtp-Source: ABdhPJy0UdoHJulEekTmucCVEXzy4ZxRGjZEP5aH6oPf11ME/LRCEd241Ba7nQNliHHm28xgh1ibpg== X-Received: by 2002:adf:ab52:: with SMTP id r18mr5671106wrc.65.1615911477898; Tue, 16 Mar 2021 09:17:57 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:17:57 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 05/22] fsck.h: indent arguments to of fsck_set_msg_type Date: Tue, 16 Mar 2021 17:17:21 +0100 Message-Id: <20210316161738.30254-6-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsck.h b/fsck.h index dc35924cbf..5e488cef6b 100644 --- a/fsck.h +++ b/fsck.h @@ -11,7 +11,7 @@ struct fsck_options; struct object; void fsck_set_msg_type(struct fsck_options *options, - const char *msg_id, const char *msg_type); + const char *msg_id, const char *msg_type); void fsck_set_msg_types(struct fsck_options *options, const char *values); int is_valid_msg_type(const char *msg_id, const char *msg_type); From patchwork Tue Mar 16 16:17:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142807 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42EE2C43331 for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0058765105 for ; Tue, 16 Mar 2021 16:18:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238626AbhCPQSc (ORCPT ); Tue, 16 Mar 2021 12:18:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238592AbhCPQSA (ORCPT ); Tue, 16 Mar 2021 12:18:00 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 427BFC06174A for ; Tue, 16 Mar 2021 09:18:00 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id u16so10789838wrt.1 for ; Tue, 16 Mar 2021 09:18:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cBCmIkWtBmNrWWPR0WtxQafc5Roe9t3epbPWHb3M448=; b=QMnlwdXpqLTxesGdLCIm3i4SVt18kgrGg/nU3xuKvJAxTO0NDD4k7N9FLUVJ88v2vS 1LjOpjORfNkGSTai5jXIksAvLj7XuE73VD6K4d/aiRCVrVmXXTZr7DiD48d+RtHjLLqz Y77BGpZ1NG2a2s0Knv7lqQw7AoQRLwMo7nnnj46TA5TerM7tA4u7lWPhOP+mSwchddqD +lHT+YWyozfDX++Fk5eSbo/KyRtEvXfxKgmKwDifnL0GA0B+NIr72QnhN9oaa7StVVyk QWi3gbSBauEiVQFv+UdGcmT38qglSGhDrUSRb9tKdOHeXVMncwQasNTE4w3ujzJYcUs+ /WVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cBCmIkWtBmNrWWPR0WtxQafc5Roe9t3epbPWHb3M448=; b=Y9hBxi4pmwmbLTX+rQyNdr2TDDynFQlq6Y4yTIW3B/2HkFAvHaNMgPOpLl64Y7rrA2 jPsaiVjIjXyECvFGwkJq8+e7qQjODaJq7ZxupTuHnAfUGN95FAeJmF8itoOHI2hQBsvv dP7Ktu6nfJroSJTkZhO3vfCZh/uiRSUGQrwBcxPDwp5oYMZnJOzxIgNtlparO9cJuqhl YnXqCQ63Yv/uF5Tnq1KEyq5/D0TKV69Dczuuw5V9lZ1qD1D/0CahTyHbYj1bZcKyiwTb mgCn3ZEAgg+bJuoNHK14uZFmaB0G2dIoH5f2JwFBS6XnoQ5X3gixAxY7FLHxcFlaW8Ua 9dBA== X-Gm-Message-State: AOAM531DYVMFDPOb04cXeYH42rLf/1irS/zyZ4x2W31FtEd/QTVaxp1c 4QVpA66J8msIb5n+GTHerSOs5SQ1j+s/lQ== X-Google-Smtp-Source: ABdhPJzAO+kJtzcwQDBFcMOQvdte1bC60Ober8rSVB+Vs8/xsKWaiNVe3PZZ+Fd2bqQqTch0zjZSzA== X-Received: by 2002:adf:ee8f:: with SMTP id b15mr5686613wro.314.1615911478716; Tue, 16 Mar 2021 09:17:58 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:17:58 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 06/22] fsck.h: use "enum object_type" instead of "int" Date: Tue, 16 Mar 2021 17:17:22 +0100 Message-Id: <20210316161738.30254-7-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the fsck_walk_func to use an "enum object_type" instead of an "int" type. The types are compatible, and ever since this was added in 355885d5315 (add generic, type aware object chain walker, 2008-02-25) we've used entries from object_type (OBJ_BLOB etc.). So this doesn't really change anything as far as the generated code is concerned, it just gives the compiler more information and makes this easier to read. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/fsck.c | 3 ++- builtin/index-pack.c | 3 ++- builtin/unpack-objects.c | 3 ++- fsck.h | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index 821e7798c7..68f0329e69 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -197,7 +197,8 @@ static int traverse_reachable(void) return !!result; } -static int mark_used(struct object *obj, int type, void *data, struct fsck_options *options) +static int mark_used(struct object *obj, enum object_type object_type, + void *data, struct fsck_options *options) { if (!obj) return 1; diff --git a/builtin/index-pack.c b/builtin/index-pack.c index bad5748807..69f24fe9f7 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -212,7 +212,8 @@ static void cleanup_thread(void) free(thread_data); } -static int mark_link(struct object *obj, int type, void *data, struct fsck_options *options) +static int mark_link(struct object *obj, enum object_type type, + void *data, struct fsck_options *options) { if (!obj) return -1; diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index dd4a75e030..ca54fd1668 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -187,7 +187,8 @@ static void write_cached_object(struct object *obj, struct obj_buffer *obj_buf) * that have reachability requirements and calls this function. * Verify its reachability and validity recursively and write it out. */ -static int check_object(struct object *obj, int type, void *data, struct fsck_options *options) +static int check_object(struct object *obj, enum object_type type, + void *data, struct fsck_options *options) { struct obj_buffer *obj_buf; diff --git a/fsck.h b/fsck.h index 5e488cef6b..f67edd8f1f 100644 --- a/fsck.h +++ b/fsck.h @@ -23,7 +23,8 @@ int is_valid_msg_type(const char *msg_id, const char *msg_type); * <0 error signaled and abort * >0 error signaled and do not abort */ -typedef int (*fsck_walk_func)(struct object *obj, int type, void *data, struct fsck_options *options); +typedef int (*fsck_walk_func)(struct object *obj, enum object_type object_type, + void *data, struct fsck_options *options); /* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */ typedef int (*fsck_error)(struct fsck_options *o, From patchwork Tue Mar 16 16:17:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 68C92C43332 for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 497FA65108 for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238631AbhCPQSe (ORCPT ); Tue, 16 Mar 2021 12:18:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238533AbhCPQSB (ORCPT ); Tue, 16 Mar 2021 12:18:01 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13464C06174A for ; Tue, 16 Mar 2021 09:18:01 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id o16so7736757wrn.0 for ; Tue, 16 Mar 2021 09:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sZvrXnUSR3FGp70tn6p9guMsLgypSNY98WE8DxmiBVQ=; b=i3pQBesNtm+0qsfrO9bv+jKFbaF24jTpw5bpx3o5d75rMxZaBELtMm0gBnT50G3ugY uApfVPpKxABnwwB0YPEnBTP/HBxMmw9YWQWh/13m7kIu9AOfnBCb1rqYP1UFiCR+E2Q2 ABMI3d3BrxinKzADWkAecE4uvvfHaVeLBFesavzaoZMLqq8NjExyO0J1mNtb6K6puZLv heRqoANMHCH0Jdrh0ozppRf3Q7vUlLcrE1qUAaISuzcogl0ucp0mYFYx3qsKrcZoiTy6 HtJiJE+CPQon+LeAZUrnXobROyly3rNy2c569aFxG2N5Waoiy7R3PAP6hNZxeDHh8Yrf ov3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sZvrXnUSR3FGp70tn6p9guMsLgypSNY98WE8DxmiBVQ=; b=mzsAeVzHsIHsJZRA7kUHu2RzxGKFhMQQF16xO4BH4t6vR2QNN+y8TdIuXw9X9Dg40m eJSV9FpRbbZefzYQtAA1ElMqlVxyYvqLHqwEE7t+eyWCToZN06p7Bm913P+geQn8QpwF AJO6Ehy83PatnELoqh1htz67XKvOg4olUamiZ08B5Ub/Ey6DPWtr4uDFniEGOEjjqoeU Ag4wK/4p8PmmZJp7XkXP3nTdIE+u07M9b+q+P4X2MrXrPq8rP7s6npKckcKbWUtjnMcY yY08uhCbyedxXD/5TIaB8+Zls2z2ZFbIgCTOLsqo64J62k/yfqpgEvaqP87+jQOIqf21 Yi0A== X-Gm-Message-State: AOAM531zN7+DBxg2EzyozvvIje1TiQOmt37AK2XlcTh57Cca57KlohFh /yYmk5wyKnoBqnL6on+JobU4ZeAAeIQfLg== X-Google-Smtp-Source: ABdhPJzT+n6SkBxvHSPYLSusbwANK6t1mNMOR2m4Z6OswL8XUNF9rZpSD0DYq1rCru64jLVLcugWGA== X-Received: by 2002:a5d:4f0e:: with SMTP id c14mr5662873wru.78.1615911479605; Tue, 16 Mar 2021 09:17:59 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:17:58 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 07/22] fsck.c: rename variables in fsck_set_msg_type() for less confusion Date: Tue, 16 Mar 2021 17:17:23 +0100 Message-Id: <20210316161738.30254-8-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Rename variables in a function added in 0282f4dced0 (fsck: offer a function to demote fsck errors to warnings, 2015-06-22). It was needlessly confusing that it took a "msg_type" argument, but then later declared another "msg_type" of a different type. Let's rename that to "severity", and rename "id" to "msg_id" and "msg_id" to "msg_id_str" etc. This will make a follow-up change smaller. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fsck.c b/fsck.c index e3030f3b35..0a9ac9ca07 100644 --- a/fsck.c +++ b/fsck.c @@ -203,27 +203,27 @@ int is_valid_msg_type(const char *msg_id, const char *msg_type) } void fsck_set_msg_type(struct fsck_options *options, - const char *msg_id, const char *msg_type) + const char *msg_id_str, const char *msg_type_str) { - int id = parse_msg_id(msg_id), type; + int msg_id = parse_msg_id(msg_id_str), msg_type; - if (id < 0) - die("Unhandled message id: %s", msg_id); - type = parse_msg_type(msg_type); + if (msg_id < 0) + die("Unhandled message id: %s", msg_id_str); + msg_type = parse_msg_type(msg_type_str); - if (type != FSCK_ERROR && msg_id_info[id].msg_type == FSCK_FATAL) - die("Cannot demote %s to %s", msg_id, msg_type); + if (msg_type != FSCK_ERROR && msg_id_info[msg_id].msg_type == FSCK_FATAL) + die("Cannot demote %s to %s", msg_id_str, msg_type_str); if (!options->msg_type) { int i; - int *msg_type; - ALLOC_ARRAY(msg_type, FSCK_MSG_MAX); + int *severity; + ALLOC_ARRAY(severity, FSCK_MSG_MAX); for (i = 0; i < FSCK_MSG_MAX; i++) - msg_type[i] = fsck_msg_type(i, options); - options->msg_type = msg_type; + severity[i] = fsck_msg_type(i, options); + options->msg_type = severity; } - options->msg_type[id] = type; + options->msg_type[msg_id] = msg_type; } void fsck_set_msg_types(struct fsck_options *options, const char *values) From patchwork Tue Mar 16 16:17:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142809 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BAF7C4332E for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 27E7965106 for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238628AbhCPQSd (ORCPT ); Tue, 16 Mar 2021 12:18:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238594AbhCPQSC (ORCPT ); Tue, 16 Mar 2021 12:18:02 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E239CC06174A for ; Tue, 16 Mar 2021 09:18:01 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id e9so7741395wrw.10 for ; Tue, 16 Mar 2021 09:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dLAiRuRu64Y3lZpUoso5lquaEiBZ9TQvktgCtzp7Q44=; b=cOau4CwNi9Pq50DwtTuJ1vDoLrbgX81wHbL4s5bNZiDWupsxlJUgDJlZuXN+NsSbsl ocJxVOMDYiOLa0fRIPnH90XxvHBlxvNMQJwYcICQFGwxBLjTU9GmnAnD85O33OH1snA9 POaWqYM+U8ZrIUpnZHvof8zRramE3aNAIxXfvn5E+N7bYQ/ECZ9XxRkRgELyVgzd/W3G l3giZWBS/PMM5eubeMqngmqhJeAyRDvVkrXQr64AaB4E0G7nodn8j7B7bU7h4g6eGgmQ nF/nHFnbPtWET81cli/aytN33rKvYMvi6OCUn+nLG/aNeQXVfYg3iCwpjL+dIitYPBEd +nLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dLAiRuRu64Y3lZpUoso5lquaEiBZ9TQvktgCtzp7Q44=; b=a3NaKGJVPLw1G8R3yP7KSFZT9IuqyD4/fHANKPnoHBtJo7TLdlC0KSMwWGCBiauxes qTpS9Tq+dp/HZPzY3qglDXf/XF13dy5ds5PO41dwSLINmxTUHBfiEi6Lhu4IFCb2lzbY 1WWScwXN2JLkYze7bKmVAIL019lhQVj3lSKQhNkBhzIkHcL2QBCGaeCLK34B04aNTyC5 kUDwIA5PB4u7ntvXJKDOler7Q+YOUA/ZICq5U8T3WIUaq4PkVlWqz4UVQ0C4euuvt2kJ HB4KHhVBT1cKlhDRwxPjpljzVHk2BVorXuiSa7B9zHD7I9hOWQohrJRPS/7KGqWFp/74 HfYA== X-Gm-Message-State: AOAM5302RLC80UTdKhVV4wo1pasahGUtwnwqF7wiV9nlhrgsxvFrtyW0 SzoZR8YhIitkyt2LCPx4SUR+RN2I9aij2g== X-Google-Smtp-Source: ABdhPJy4s45ULi3Y3hxbTVNXsB4DwqnblTFrWI295XZYRW26o63ptOe0cNN3/GUqWYRzIPrrXWC7Qg== X-Received: by 2002:adf:bbc2:: with SMTP id z2mr5570415wrg.180.1615911480447; Tue, 16 Mar 2021 09:18:00 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:17:59 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 08/22] fsck.c: move definition of msg_id into append_msg_id() Date: Tue, 16 Mar 2021 17:17:24 +0100 Message-Id: <20210316161738.30254-9-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor code added in 71ab8fa840f (fsck: report the ID of the error/warning, 2015-06-22) to resolve the msg_id to a string in the function that wants it, instead of doing it in report(). Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fsck.c b/fsck.c index 0a9ac9ca07..b977493f57 100644 --- a/fsck.c +++ b/fsck.c @@ -264,8 +264,9 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values) free(to_free); } -static void append_msg_id(struct strbuf *sb, const char *msg_id) +static void append_msg_id(struct strbuf *sb, enum fsck_msg_id id) { + const char *msg_id = msg_id_info[id].id_string; for (;;) { char c = *(msg_id)++; @@ -308,7 +309,7 @@ static int report(struct fsck_options *options, else if (msg_type == FSCK_INFO) msg_type = FSCK_WARN; - append_msg_id(&sb, msg_id_info[id].id_string); + append_msg_id(&sb, id); va_start(ap, fmt); strbuf_vaddf(&sb, fmt, ap); From patchwork Tue Mar 16 16:17:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7717C43333 for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8933065109 for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238633AbhCPQSf (ORCPT ); Tue, 16 Mar 2021 12:18:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238595AbhCPQSD (ORCPT ); Tue, 16 Mar 2021 12:18:03 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AAE4FC06174A for ; Tue, 16 Mar 2021 09:18:02 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id t9so7736176wrn.11 for ; Tue, 16 Mar 2021 09:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mvQXr8EWUZCeWeNeD/zKglA/tT8vx2hz3jJ7VSqFZek=; b=in1xQkwV6HfPWeqUBJtr7AzjTyWX8LHyL0twKeu2PQtxKGMKaaZmEdH3Oga8zI7snG UAnvM27tePzMrcUbJCG0i538hxLiDeHGpnFvTJKitSaxqwBkvRqrUNJlhRXEhEf4ZcYz O9MrZH7XByHvyGZWYCRcTYWQta7BWNg/iHzkkma6tnlZDw3Z+brXvwiXfjRVpGyItZPa CAWDQpyMQTD9kESlU1V7CYhDX/r55pcM8gqH8aHjljvJmBqYRsGjVHkwoFKIpYWnpVao Q9Ka3Mz530zDkASaNK6bTLPK0Ygv8az8AyA/+XT/iKjHFd6kLdLOr3i7q18sbLlDMprl 1HZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mvQXr8EWUZCeWeNeD/zKglA/tT8vx2hz3jJ7VSqFZek=; b=o/pu5khO8vXYWkuM9Ug34orlpa3dwvcstJOKsAu1t2Sg4DG5qMACmzgNDAiXofyT6q GU+EtFpuRiz4zebOM7u+czFZlifapkQoYckTDGnTnWNRLZPR5ap4LIRNoYqI9a6nTSOr xL0W+u3xFYGA+pu5w2zEs5vXzFWtthVwx7swvpJLGMFkBWnYGMFEtQrJwEgH+3vE/0CS AXgq0llm/7iga6CkLf6Uoj1lqrpyPBtAB1qiQsskiRkFXfxy3QiOQ3VE0CrLw86B8Cdq EZcPO117HkqzLYA5Os5I+CC6Pz1E4+LwJkQKPTq3GscmR3uapdk1oiwoN3jVMQuF3Tir XOyg== X-Gm-Message-State: AOAM531QzIR5B5GskUoVqmzOrenshgFMCUzkewfeVmG6FnP40yozuycv /bUkgnuCwnErLr8Pq7J2ZIBb7KRv9wrWcA== X-Google-Smtp-Source: ABdhPJw896S8myEVlnlOG75ZwCjjO/WY2CAm1slejh2A7avcl5Bl3SjO2yjGvg9f0WBCENb8buifWA== X-Received: by 2002:a05:6000:118c:: with SMTP id g12mr5747637wrx.353.1615911481149; Tue, 16 Mar 2021 09:18:01 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:00 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 09/22] fsck.c: rename remaining fsck_msg_id "id" to "msg_id" Date: Tue, 16 Mar 2021 17:17:25 +0100 Message-Id: <20210316161738.30254-10-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Rename the remaining variables of type fsck_msg_id from "id" to "msg_id". This change is relatively small, and is worth the churn for a later change where we have different id's in the "report" function. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fsck.c b/fsck.c index b977493f57..6b72ddaa51 100644 --- a/fsck.c +++ b/fsck.c @@ -264,19 +264,19 @@ void fsck_set_msg_types(struct fsck_options *options, const char *values) free(to_free); } -static void append_msg_id(struct strbuf *sb, enum fsck_msg_id id) +static void append_msg_id(struct strbuf *sb, enum fsck_msg_id msg_id) { - const char *msg_id = msg_id_info[id].id_string; + const char *msg_id_str = msg_id_info[msg_id].id_string; for (;;) { - char c = *(msg_id)++; + char c = *(msg_id_str)++; if (!c) break; if (c != '_') strbuf_addch(sb, tolower(c)); else { - assert(*msg_id); - strbuf_addch(sb, *(msg_id)++); + assert(*msg_id_str); + strbuf_addch(sb, *(msg_id_str)++); } } @@ -292,11 +292,11 @@ static int object_on_skiplist(struct fsck_options *opts, __attribute__((format (printf, 5, 6))) static int report(struct fsck_options *options, const struct object_id *oid, enum object_type object_type, - enum fsck_msg_id id, const char *fmt, ...) + enum fsck_msg_id msg_id, const char *fmt, ...) { va_list ap; struct strbuf sb = STRBUF_INIT; - int msg_type = fsck_msg_type(id, options), result; + int msg_type = fsck_msg_type(msg_id, options), result; if (msg_type == FSCK_IGNORE) return 0; @@ -309,7 +309,7 @@ static int report(struct fsck_options *options, else if (msg_type == FSCK_INFO) msg_type = FSCK_WARN; - append_msg_id(&sb, id); + append_msg_id(&sb, msg_id); va_start(ap, fmt); strbuf_vaddf(&sb, fmt, ap); From patchwork Tue Mar 16 16:17:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F24C432C3 for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65ADF6510B for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238636AbhCPQSg (ORCPT ); Tue, 16 Mar 2021 12:18:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238597AbhCPQSE (ORCPT ); Tue, 16 Mar 2021 12:18:04 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E40C061756 for ; Tue, 16 Mar 2021 09:18:03 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id e18so7741011wrt.6 for ; Tue, 16 Mar 2021 09:18:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MtCav4KWt1syzHsHDbfgPm6VU5dv31bdnl77nmT93O0=; b=Vo8Nv1SGACtbbFEAIEHU3v49rEk8OFAH70QJ91REOSHWdkpTc15S6gHR+pg87mW3kf yQXmDCzOLkyGZRvDHcjvn4lAf7NUg8RsVpW0xClwreEThpzj1ONF/Rz8dQAuX2GbV0HM md3znaURReS84mn1IlyN0FwxXRy/Y1WTJeEqNnDt8aGN1CX6+exbgRkSQPU6rzsALTrn zI4mE98tAgL/DO7PeY+e8xAGJL4Ka6ivOfX7ehqxi6TdBz0rKA+2i1aQEq+aM+SnWDY1 Ib7/fAK8TEBJm3grBilEmkorRBENYaufQ92xtePMX7VWJwnKPug3Yd1XCkmyS1dNGQke mMGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MtCav4KWt1syzHsHDbfgPm6VU5dv31bdnl77nmT93O0=; b=MvhwMETyMG1s5EXNjiD+HLOLO1eoX5QX2bCBW3Bum7BqSemubJwL5JAKhNvIqQz7Uf EVNzmNYMOrUQ4yWg0pWAoS3Azv3gT8fHQ/P46e65lh/sbg0Z5+Wzqg3JsMwCuKQTbqd7 ezF1COkFbsjH+9nvEIBAUobMG6MmT/fCYBjVl7OAZLdhQArVtha2lGDRvr+Ip84SFVy0 SnXfSJbjh0HD58WC5aWoHEC+nsafn8/ytZ4oCBdvl//fhGA9jjU4y0YgQC1148FZlaYo TiSWRts7+qtCrcwRdr9CnucWnb2I/tzf07c8FusPwQY70p7DwaHJzhmWVCx4nXR1sr0s hulw== X-Gm-Message-State: AOAM530P6m0AUB+ocp9ZRzPA3pYiIYAvo3kY/pTwpXrxGFzAlgBxuJ/E dZB6KCpqvAMJDJq3iGi1CS27d8dOPReZ1A== X-Google-Smtp-Source: ABdhPJxZJ2fVFjpXZXZcm2ao9zrTrt8AxO5ADcoQogM1619+Z5jFSlVaVVxWXtFzY5Njhf7PM3wNRw== X-Received: by 2002:a5d:58c9:: with SMTP id o9mr5793784wrf.181.1615911481970; Tue, 16 Mar 2021 09:18:01 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:01 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 10/22] fsck.c: refactor fsck_msg_type() to limit scope of "int msg_type" Date: Tue, 16 Mar 2021 17:17:26 +0100 Message-Id: <20210316161738.30254-11-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor "if options->msg_type" and other code added in 0282f4dced0 (fsck: offer a function to demote fsck errors to warnings, 2015-06-22) to reduce the scope of the "int msg_type" variable. This is in preparation for changing its type in a subsequent commit, only using it in the "!options->msg_type" scope makes that change This also brings the code in line with the fsck_set_msg_type() function (also added in 0282f4dced0), which does a similar check for "!options->msg_type". Another minor benefit is getting rid of the style violation of not having braces for the body of the "if". Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fsck.c b/fsck.c index 6b72ddaa51..0988ab6579 100644 --- a/fsck.c +++ b/fsck.c @@ -167,19 +167,17 @@ void list_config_fsck_msg_ids(struct string_list *list, const char *prefix) static int fsck_msg_type(enum fsck_msg_id msg_id, struct fsck_options *options) { - int msg_type; - assert(msg_id >= 0 && msg_id < FSCK_MSG_MAX); - if (options->msg_type) - msg_type = options->msg_type[msg_id]; - else { - msg_type = msg_id_info[msg_id].msg_type; + if (!options->msg_type) { + int msg_type = msg_id_info[msg_id].msg_type; + if (options->strict && msg_type == FSCK_WARN) msg_type = FSCK_ERROR; + return msg_type; } - return msg_type; + return options->msg_type[msg_id]; } static int parse_msg_type(const char *str) From patchwork Tue Mar 16 16:17:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D51EBC4321A for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD1B365108 for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238637AbhCPQSh (ORCPT ); Tue, 16 Mar 2021 12:18:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238598AbhCPQSF (ORCPT ); Tue, 16 Mar 2021 12:18:05 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55364C06174A for ; Tue, 16 Mar 2021 09:18:04 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id v11so7745415wro.7 for ; Tue, 16 Mar 2021 09:18:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XuDmrbI3YRgPU8vjBPfu3IOOLOX8Z3LwlKyicz3ofus=; b=fEyloe8ZuwwV6msRxtqBfb+Fb73doZcxmEbCIP5HJsaEm+NfG6gmn8OxpILuVDaWv+ JOmSrmWt/p6juowz1B5T23bvhaCJmwGhBq1pG8yC7s8ajpKcf14uaSeCCf+c1/ueHybh LAm05f7knA7+38L0lWZ8v3EKoWU4AbvptkQRK1ni01b7Oxs7M9Q7RN9ILaOejIwYpksZ a+2M7uemvL81XhEQeGWO1Ue0u/PpCJFs4kaqwIKHbhyWQoTNHYH82JPwoNmLf0E8XkDg 0h3Y5vDH/W1YAyqsKfAsWyogPlEUBfE+C4lijclsCrE2aewPwKq8zTwZhuGdeib7pq0G n/9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XuDmrbI3YRgPU8vjBPfu3IOOLOX8Z3LwlKyicz3ofus=; b=dgrrbJz56ZIhNAdv/n4Mc19OK7ntWa9Qspob/IG+1SFEXFkfebkrRIBUUyhStd2Pvk DQ5LuGyh+PUPwQ71QPFInTMugZHHnNR9NQ6fye8ZMacjl/JqSdrZYb7seDIHJSEWn2Pm D/afZHnCnbwRIj5Oa/AcaUxv7Npl8qXQ4+DUEgvTWvye43SZ4oiFX+voXaTFCH/+M3U8 sVMfKUNvKUwOj+u8+hYU93LjGiy9EycBolZa8SI8CGrfhE68RHBzXc54ZI7JSxbJhMCG 2po6EMQiji+ngA0HzFPiuGfgDuXSxD8EfxNQVDl7e/hC6d7mOZMcBg532k0e4XHthfjp OLDA== X-Gm-Message-State: AOAM532DGqL9ZtrNB+Vf61gtmpkRYV97LNdfQEI+1QmhqBFOnDDK1XSI lWnYc3/OY9hn4nonERTEcmIRtMNyLIgD3A== X-Google-Smtp-Source: ABdhPJyk7HsSNfMkpvctY2rBK7PofDBK3k5tLKc5IjecwfmTIv8+3cyBN8nfNBhjC+R7d23GFOzRnA== X-Received: by 2002:adf:83c2:: with SMTP id 60mr5668703wre.386.1615911482752; Tue, 16 Mar 2021 09:18:02 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:02 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 11/22] fsck.h: move FSCK_{FATAL,INFO,ERROR,WARN,IGNORE} into an enum Date: Tue, 16 Mar 2021 17:17:27 +0100 Message-Id: <20210316161738.30254-12-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the FSCK_{FATAL,INFO,ERROR,WARN,IGNORE} defines into a new fsck_msg_type enum. These defines were originally introduced in: - ba002f3b28a (builtin-fsck: move common object checking code to fsck.c, 2008-02-25) - f50c4407305 (fsck: disallow demoting grave fsck errors to warnings, 2015-06-22) - efaba7cc77f (fsck: optionally ignore specific fsck issues completely, 2015-06-22) - f27d05b1704 (fsck: allow upgrading fsck warnings to errors, 2015-06-22) The reason these were defined in two different places is because we use FSCK_{IGNORE,INFO,FATAL} only in fsck.c, but FSCK_{ERROR,WARN} are used by external callbacks. Untangling that would take some more work, since we expose the new "enum fsck_msg_type" to both. Similar to "enum object_type" it's not worth structuring the API in such a way that only those who need FSCK_{ERROR,WARN} pass around a different type. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/fsck.c | 2 +- builtin/index-pack.c | 3 ++- builtin/mktag.c | 3 ++- fsck.c | 21 ++++++++++----------- fsck.h | 16 ++++++++++------ 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index 68f0329e69..d6d745dc70 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -89,7 +89,7 @@ static int objerror(struct object *obj, const char *err) static int fsck_error_func(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - int msg_type, const char *message) + enum fsck_msg_type msg_type, const char *message) { switch (msg_type) { case FSCK_WARN: diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 69f24fe9f7..56b8efaa89 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1716,7 +1716,8 @@ static void show_pack_info(int stat_only) static int print_dangling_gitmodules(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - int msg_type, const char *message) + enum fsck_msg_type msg_type, + const char *message) { /* * NEEDSWORK: Plumb the MSG_ID (from fsck.c) here and use it diff --git a/builtin/mktag.c b/builtin/mktag.c index 41a399a69e..1834394a9b 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -22,7 +22,8 @@ static int mktag_config(const char *var, const char *value, void *cb) static int mktag_fsck_error_func(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - int msg_type, const char *message) + enum fsck_msg_type msg_type, + const char *message) { switch (msg_type) { case FSCK_WARN: diff --git a/fsck.c b/fsck.c index 0988ab6579..fb7d071bbf 100644 --- a/fsck.c +++ b/fsck.c @@ -22,9 +22,6 @@ static struct oidset gitmodules_found = OIDSET_INIT; static struct oidset gitmodules_done = OIDSET_INIT; -#define FSCK_FATAL -1 -#define FSCK_INFO -2 - #define FOREACH_MSG_ID(FUNC) \ /* fatal errors */ \ FUNC(NUL_IN_HEADER, FATAL) \ @@ -97,7 +94,7 @@ static struct { const char *id_string; const char *downcased; const char *camelcased; - int msg_type; + enum fsck_msg_type msg_type; } msg_id_info[FSCK_MSG_MAX + 1] = { FOREACH_MSG_ID(MSG_ID) { NULL, NULL, NULL, -1 } @@ -164,13 +161,13 @@ void list_config_fsck_msg_ids(struct string_list *list, const char *prefix) list_config_item(list, prefix, msg_id_info[i].camelcased); } -static int fsck_msg_type(enum fsck_msg_id msg_id, +static enum fsck_msg_type fsck_msg_type(enum fsck_msg_id msg_id, struct fsck_options *options) { assert(msg_id >= 0 && msg_id < FSCK_MSG_MAX); if (!options->msg_type) { - int msg_type = msg_id_info[msg_id].msg_type; + enum fsck_msg_type msg_type = msg_id_info[msg_id].msg_type; if (options->strict && msg_type == FSCK_WARN) msg_type = FSCK_ERROR; @@ -180,7 +177,7 @@ static int fsck_msg_type(enum fsck_msg_id msg_id, return options->msg_type[msg_id]; } -static int parse_msg_type(const char *str) +static enum fsck_msg_type parse_msg_type(const char *str) { if (!strcmp(str, "error")) return FSCK_ERROR; @@ -203,7 +200,8 @@ int is_valid_msg_type(const char *msg_id, const char *msg_type) void fsck_set_msg_type(struct fsck_options *options, const char *msg_id_str, const char *msg_type_str) { - int msg_id = parse_msg_id(msg_id_str), msg_type; + int msg_id = parse_msg_id(msg_id_str); + enum fsck_msg_type msg_type; if (msg_id < 0) die("Unhandled message id: %s", msg_id_str); @@ -214,7 +212,7 @@ void fsck_set_msg_type(struct fsck_options *options, if (!options->msg_type) { int i; - int *severity; + enum fsck_msg_type *severity; ALLOC_ARRAY(severity, FSCK_MSG_MAX); for (i = 0; i < FSCK_MSG_MAX; i++) severity[i] = fsck_msg_type(i, options); @@ -294,7 +292,8 @@ static int report(struct fsck_options *options, { va_list ap; struct strbuf sb = STRBUF_INIT; - int msg_type = fsck_msg_type(msg_id, options), result; + enum fsck_msg_type msg_type = fsck_msg_type(msg_id, options); + int result; if (msg_type == FSCK_IGNORE) return 0; @@ -1265,7 +1264,7 @@ int fsck_object(struct object *obj, void *data, unsigned long size, int fsck_error_function(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - int msg_type, const char *message) + enum fsck_msg_type msg_type, const char *message) { if (msg_type == FSCK_WARN) { warning("object %s: %s", fsck_describe_object(o, oid), message); diff --git a/fsck.h b/fsck.h index f67edd8f1f..2ecc15eee7 100644 --- a/fsck.h +++ b/fsck.h @@ -3,9 +3,13 @@ #include "oidset.h" -#define FSCK_ERROR 1 -#define FSCK_WARN 2 -#define FSCK_IGNORE 3 +enum fsck_msg_type { + FSCK_INFO = -2, + FSCK_FATAL = -1, + FSCK_ERROR = 1, + FSCK_WARN, + FSCK_IGNORE +}; struct fsck_options; struct object; @@ -29,17 +33,17 @@ typedef int (*fsck_walk_func)(struct object *obj, enum object_type object_type, /* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */ typedef int (*fsck_error)(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - int msg_type, const char *message); + enum fsck_msg_type msg_type, const char *message); int fsck_error_function(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - int msg_type, const char *message); + enum fsck_msg_type msg_type, const char *message); struct fsck_options { fsck_walk_func walk; fsck_error error_func; unsigned strict:1; - int *msg_type; + enum fsck_msg_type *msg_type; struct oidset skiplist; kh_oid_map_t *object_names; }; From patchwork Tue Mar 16 16:17:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DF53C433DB for ; Tue, 16 Mar 2021 16:19:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4538F650FD for ; Tue, 16 Mar 2021 16:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235780AbhCPQSn (ORCPT ); Tue, 16 Mar 2021 12:18:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238601AbhCPQSH (ORCPT ); Tue, 16 Mar 2021 12:18:07 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55517C06175F for ; Tue, 16 Mar 2021 09:18:05 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id y124-20020a1c32820000b029010c93864955so1781807wmy.5 for ; Tue, 16 Mar 2021 09:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aZXo0k/PeJc5QgNB2lSMf3sq1jDJDvbwkZfK9poiwd8=; b=uoe80b/GDZ9Du7v3jxPQQdpLWKUlzKbWqT0mPQSUJkUVMWjBR9aSbtLB0kBovPHTJ/ HIgGuTbmo7F7y7SOxor8+5/fTGaPIzBcaYiiF1ely5trAc311PP7wDHJ/VbaDIp4Z06F RZWpYD0t5e85bOIi2ZIV0SHTmtGELPl7F86WtZUVS5hzvcVOItJ5jlDXrNUWqDpmzUaU GcXLGD9VX8odW0+EkzLBn92zZ/s10sIIVKK3Hjyoi/FtRmHtoe8Hfa5G8rEOZvOnxWmQ +8y5w3e+EgqLULtQDz7izLT4LT+E+tOLFbXUh9AhMpCVMc+LdQ5cI9vY0jzlxsJ5mAQr oCLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aZXo0k/PeJc5QgNB2lSMf3sq1jDJDvbwkZfK9poiwd8=; b=OkA8UWcdnm33EN7+c/jzZvPaSIBHXmf49YHR3ut3M63Zk7EosckBbB0zDg1HMz9eH5 C9nFRYK38G4m9hDwntZvv/bCeYd2u8dYkFvIuKcoG88y4o1V0AexxGCgzB9bp6mE0yBP 2fvlXAABYBaz+QWsjOuypwnY6FcSXpWrNPpIPa/q58MKf+82g9HnyTDsVugarCxQCVuR DhVPLCf2ovOo5xxWfk9pSlGrHDsFfmqPyHAy3ZmNTM4HBcAovt+cGXvmw8gP6hPtHZNQ YjscGLazdORwOqGVQjkTpkg2VsugDT8LKDU6yPU5wWtZCkYri7SoNG0TtRc9S7qJ3Xg6 kmzQ== X-Gm-Message-State: AOAM530upgIt1PinRISJo/oB6grgRw1Fd0WpOd/dr+U4/ux5hEnqbMUk TBn01kxlhK1XYEpzgulF6sjH5nuEYOls8Q== X-Google-Smtp-Source: ABdhPJzwEI9cpT/Xnybeo4yRGCfCrdtFrYZKvILkhnXq8Bpz7QWBlfUa8d82k/k37++WdKaSAlWUlw== X-Received: by 2002:a7b:c083:: with SMTP id r3mr359989wmh.177.1615911483664; Tue, 16 Mar 2021 09:18:03 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:03 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 12/22] fsck.h: re-order and re-assign "enum fsck_msg_type" Date: Tue, 16 Mar 2021 17:17:28 +0100 Message-Id: <20210316161738.30254-13-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the values in the "enum fsck_msg_type" from being manually assigned to using default C enum values. This means we end up with a FSCK_IGNORE=0, which was previously defined as "2". I'm confident that nothing relies on these values, we always compare them explicitly. Let's not omit "0" so it won't be assumed that we're using these as a boolean somewhere. This also allows us to re-structure the fields to mark which are "private" v.s. "public". See the preceding commit for a rationale for not simply splitting these into two enums, namely that this is used for both the private and public fsck API. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fsck.h b/fsck.h index 2ecc15eee7..fce9981a0c 100644 --- a/fsck.h +++ b/fsck.h @@ -4,11 +4,13 @@ #include "oidset.h" enum fsck_msg_type { - FSCK_INFO = -2, - FSCK_FATAL = -1, - FSCK_ERROR = 1, + /* for internal use only */ + FSCK_IGNORE, + FSCK_INFO, + FSCK_FATAL, + /* "public", fed to e.g. error_func callbacks */ + FSCK_ERROR, FSCK_WARN, - FSCK_IGNORE }; struct fsck_options; From patchwork Tue Mar 16 16:17:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03CB2C4360C for ; Tue, 16 Mar 2021 16:18:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1B5365109 for ; Tue, 16 Mar 2021 16:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238639AbhCPQSi (ORCPT ); Tue, 16 Mar 2021 12:18:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235569AbhCPQSH (ORCPT ); Tue, 16 Mar 2021 12:18:07 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8980FC061762 for ; Tue, 16 Mar 2021 09:18:06 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id w203-20020a1c49d40000b029010c706d0642so4102012wma.0 for ; Tue, 16 Mar 2021 09:18:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FrJ7XLTyJL5GQz5dbFbvH4a6OfCD2eBY/5CfuFOZ5J8=; b=J5Vn9yDUSZqAUt3g0ZmS1v4TAaRtkNH9EcQrVcrvrHhW7IxLNx7hsWc3Y6hD7nCCMh fh4v2W4JjWjr9FsLw9Rt8hbxedvJiI+szEI3NiKi0XjprHpyY5dfd/9RF2fBMZyde8lU RlRPDwGM5KMnDwOYhhwOiocD1uwq3CnDWb2ciOKZ4I6RJWwjLEaR3ztNkKRayMfqXcFz rInYiuOQvU3ncuvnCTjqUzh3htLltYxaIgOwbJiApcu6OLNicSiUakznDAiUOPEVtxMP shH5TctSdPBUjtIgPgbBP/j9yPABiec0RMT1+yhW6TdEwUptppnFup9d1U96oj69fgdv sP6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FrJ7XLTyJL5GQz5dbFbvH4a6OfCD2eBY/5CfuFOZ5J8=; b=VCqU/pnpuS1NOIkyHlBIc5VKsnqZxdya92J4QsUE2gQ/9LsaUrP6t1bGQx26XkW4wp juNy0XYmV6fhziw11wAaDw0kCjM5YhC2Ep+17vYMbkDbFPFreaolLCOAJ6aO4VHHEsLS nMW81WeUBnXSqzNVTs0yqiagrgZcYBccboXupuVuAIlnSVe4jKkOdiqfub6OPq29/PJg 7uEqNguHPrAVnsnWUm+oyuXCsAwQqhpkIoJ/R1VZEj68o45FFPgygBGpuonTgo5thk6F 51GT8xm1eQeqaYymkEdBv10mPLygXdFOINGGU6tdyxsfX8PSQnBK9Vql0GvnNrixmnM7 D1Aw== X-Gm-Message-State: AOAM531zIXlJwJmXAe1TPqnQ8JI7Q3mEKL5i9i+/XXs+9ppTgPYwIYEK uBn3SuoZhp2kE8hHJOgOeqRlkL092Zuq/w== X-Google-Smtp-Source: ABdhPJxm+EY9r44LIUHvSSXiBrVdU/o4O/JjUUqzl2ObmjYO9TP3tjQ1UVAhQv+17W5GVseUwTiTLQ== X-Received: by 2002:a1c:6745:: with SMTP id b66mr411520wmc.114.1615911484973; Tue, 16 Mar 2021 09:18:04 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:03 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 13/22] fsck.c: call parse_msg_type() early in fsck_set_msg_type() Date: Tue, 16 Mar 2021 17:17:29 +0100 Message-Id: <20210316161738.30254-14-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org There's no reason to defer the calling of parse_msg_type() until after we've checked if the "id < 0". This is not a hot codepath, and parse_msg_type() itself may die on invalid input. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fsck.c b/fsck.c index fb7d071bbf..2ccf1a2f0f 100644 --- a/fsck.c +++ b/fsck.c @@ -201,11 +201,10 @@ void fsck_set_msg_type(struct fsck_options *options, const char *msg_id_str, const char *msg_type_str) { int msg_id = parse_msg_id(msg_id_str); - enum fsck_msg_type msg_type; + enum fsck_msg_type msg_type = parse_msg_type(msg_type_str); if (msg_id < 0) die("Unhandled message id: %s", msg_id_str); - msg_type = parse_msg_type(msg_type_str); if (msg_type != FSCK_ERROR && msg_id_info[msg_id].msg_type == FSCK_FATAL) die("Cannot demote %s to %s", msg_id_str, msg_type_str); From patchwork Tue Mar 16 16:17:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25F07C433E6 for ; Tue, 16 Mar 2021 16:19:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0054765108 for ; Tue, 16 Mar 2021 16:19:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238588AbhCPQSq (ORCPT ); Tue, 16 Mar 2021 12:18:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238596AbhCPQSI (ORCPT ); Tue, 16 Mar 2021 12:18:08 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CE01C061756 for ; Tue, 16 Mar 2021 09:18:07 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 12so5401806wmf.5 for ; Tue, 16 Mar 2021 09:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UH/bG5OnB9ke/iwQjcfkfuNpIKU95iVA6ZwPiYliLI4=; b=A3BE24IdAfQSNeOaUvEfHmf+vx1p36oX1f8/Y6Fhivr2TsMiGTEx4Juo+X1KsYF7nQ 62Uy3e+eBMLvHfZPDT3CJez4OhSnGKEn8PSg1GeETxVWpw+CGozhagFkbO1hDa5fclvz PxKgXWc6bMlcbzncPBL5h9tsa5sOTRF24pgPN1RgdYyFeJpNsN0BGxgBjdbew0/Z7BT1 4U3NFx3HsXeSC0Uuul4zCJEWZFQQcfx9FodgbB68Xcx/vIU4HG7hF4keTyvTTuAGRj8I Cu72iREA4xa62j2GofgTfzCE29AbGyAX9Pkhbxso1bgLgXZiyefbUmVIMAdHlZs6yh8j NqeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UH/bG5OnB9ke/iwQjcfkfuNpIKU95iVA6ZwPiYliLI4=; b=b69ZW0j/yPJ3Y0JF7EJGRaWL4pEVE0jNflw9gYsVSbcCe4CNBwCe2ZOI+PVGBSfboD I0FzyEUEmzQuiGj75+HzLz2INQQ9UnZIGznir70KPooaegTg3lArojpyweKT+jcpHvY7 jzBzcKb2vAyI89Jl5GujgCFnYF8vwlof7ZwVT7qmM9SIhzr1TlxxsRAqZYZIm2GLxxaN /jGzKTggHK637OLE3hh31r/Mn9FV6V7359a5sEInLQyVXh1FdczM59NFiNwzcjqTkW5k UZ6HJSyx7tNh2DJXxl+0gbHNmKcBUihR4s2RBmPTXgDLMLKgPwdGtgjxLOBHvhzKT9VR +F6w== X-Gm-Message-State: AOAM5323CjZiWX9vEFKD09Nr3UYY6no6brXHqA/vzzf10q8JV2zw8u5T iE9UZvrc6dF2NbJvOxdwmhu1xRGIOJYOqg== X-Google-Smtp-Source: ABdhPJw+i//zvywUVifGblq2OaWg4KeaBg5YRCFi/hVKVWY5XjDFbo+hll8r30niOgPqkvriHc07lQ== X-Received: by 2002:a05:600c:3546:: with SMTP id i6mr399007wmq.104.1615911485925; Tue, 16 Mar 2021 09:18:05 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:05 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 14/22] fsck.c: undefine temporary STR macro after use Date: Tue, 16 Mar 2021 17:17:30 +0100 Message-Id: <20210316161738.30254-15-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In f417eed8cde (fsck: provide a function to parse fsck message IDs, 2015-06-22) the "STR" macro was introduced, but that short macro name was not undefined after use as was done earlier in the same series for the MSG_ID macro in c99ba492f1c (fsck: introduce identifiers for fsck messages, 2015-06-22). Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fsck.c b/fsck.c index 2ccf1a2f0f..f4c924ed04 100644 --- a/fsck.c +++ b/fsck.c @@ -100,6 +100,7 @@ static struct { { NULL, NULL, NULL, -1 } }; #undef MSG_ID +#undef STR static void prepare_msg_ids(void) { From patchwork Tue Mar 16 16:17:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C63E6C43381 for ; Tue, 16 Mar 2021 16:19:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9AAC165106 for ; Tue, 16 Mar 2021 16:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238625AbhCPQSt (ORCPT ); Tue, 16 Mar 2021 12:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238603AbhCPQSI (ORCPT ); Tue, 16 Mar 2021 12:18:08 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20920C061763 for ; Tue, 16 Mar 2021 09:18:08 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id g25so10405260wmh.0 for ; Tue, 16 Mar 2021 09:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tIB5hS2d2UvV6EfMdHp8V8iDI/rMwg/YNvvqqAS/v80=; b=aNjFqnzCV8vmII8OH4kHHr7YZwJo7+FaMq5XvqpkbLq4V7hDb0jN0vjhEJyITNCQEr 0Yq+P5qD3Fw9yvEg6K/5vpm8HNGCGz4RkXPq6e3/zHLtlOoZB8c49XGZ3fI2y1DFFoXo Sq/HfTiA16K6sTmGeHpffE8LcmcmNQ99649iO9trPXSMuP6gyuNhpNcL+aV3QZTnl+S9 ye2T/2cHu6+udkGGtxumEO0GUiLtQPhODK7HnTmCfau38KaT0npRj5RdFpH9PX/Gc68a EpwLYPZYg+xfgHspNWchCml7dngyhKRrRLYu7GbDZlaOkY47LdyvULVU/cuKTlneMhTY i07g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tIB5hS2d2UvV6EfMdHp8V8iDI/rMwg/YNvvqqAS/v80=; b=aIA2PoB+owVKIMVawqqveDRI/N24nuvLhd/JGj37lTNv+6UqxN7J8pWAdV46ZHTBaf 1LchXG3eGnAmyt44pfkRS9IF3vwrGKyeQh7L5GO2K7bjH6BdHP/u2RtzI7sJfPNH8I/t l3P8jJuwE4cCOZV/Ne8p7qnGWjchuXv8U+UfU9qCnSOcdNmozWTenAvbhWTvd2njl4VR FfgCMLLIwK/bwRANvyJCk/ni+q0y8iLxMI+jPTcfIA+PeUp4A9xBJAe4VDpPDBrF0WLi MBMDfkUxTL3yAHfnVeVZapby39Mx6k46kjJ0PmJ9Wkfg7tw2sFWUpQ7azCcPc4j1tGzy jjgg== X-Gm-Message-State: AOAM531h+amvfuVdwzCuKOPaSXoYXDCEPaiKqJVyKTb2wesgB0xvYlPr pG+vuCJAHtnbVMOi1O/uCbo7fKLAjFyR2w== X-Google-Smtp-Source: ABdhPJyHGMtrF8MQPkYCqlG27NuWXsJGFKlBS+Vr7oSRqKJviT2Fyaitmpq7MWz4Xz+YnzIiJFI+jA== X-Received: by 2002:a1c:4e07:: with SMTP id g7mr396807wmh.29.1615911486652; Tue, 16 Mar 2021 09:18:06 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:06 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 15/22] fsck.c: give "FOREACH_MSG_ID" a more specific name Date: Tue, 16 Mar 2021 17:17:31 +0100 Message-Id: <20210316161738.30254-16-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Rename the FOREACH_MSG_ID macro to FOREACH_FSCK_MSG_ID in preparation for moving it over to fsck.h. It's good convention to name macros in *.h files in such a way as to clearly not clash with any other names in other files. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fsck.c b/fsck.c index f4c924ed04..6fbc56e9fa 100644 --- a/fsck.c +++ b/fsck.c @@ -22,7 +22,7 @@ static struct oidset gitmodules_found = OIDSET_INIT; static struct oidset gitmodules_done = OIDSET_INIT; -#define FOREACH_MSG_ID(FUNC) \ +#define FOREACH_FSCK_MSG_ID(FUNC) \ /* fatal errors */ \ FUNC(NUL_IN_HEADER, FATAL) \ FUNC(UNTERMINATED_HEADER, FATAL) \ @@ -83,7 +83,7 @@ static struct oidset gitmodules_done = OIDSET_INIT; #define MSG_ID(id, msg_type) FSCK_MSG_##id, enum fsck_msg_id { - FOREACH_MSG_ID(MSG_ID) + FOREACH_FSCK_MSG_ID(MSG_ID) FSCK_MSG_MAX }; #undef MSG_ID @@ -96,7 +96,7 @@ static struct { const char *camelcased; enum fsck_msg_type msg_type; } msg_id_info[FSCK_MSG_MAX + 1] = { - FOREACH_MSG_ID(MSG_ID) + FOREACH_FSCK_MSG_ID(MSG_ID) { NULL, NULL, NULL, -1 } }; #undef MSG_ID From patchwork Tue Mar 16 16:17:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UPPERCASE_50_75,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0600AC4332B for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C867E65119 for ; Tue, 16 Mar 2021 16:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238655AbhCPQSx (ORCPT ); Tue, 16 Mar 2021 12:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238605AbhCPQSL (ORCPT ); Tue, 16 Mar 2021 12:18:11 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44F77C06174A for ; Tue, 16 Mar 2021 09:18:09 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id r15-20020a05600c35cfb029010e639ca09eso1797495wmq.1 for ; Tue, 16 Mar 2021 09:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=86wOUpqgY1AI409imnR0FBW39DXCAtH+DIkXM2heYs8=; b=iIVHce+u1gvFzm3Ulr+oRQHjgmvXISdW+xk6G0g9fyNKAnJO/C5p0atwBYIPlJ6x4b mLsmtNAbuEf2ZzjFU04tyfhexrID8Ou87GqCLPmGC7485/ObLne5E/GG+OXgUJYGzmkn oFxMKPVKFojt7K/R1Au6cgw+mApWydEz4MDF67ajyYnVqfoMJOZVHcv1KEIkS/p3+777 2BrCVdqhQ1ommmfCS/cDizsYz3FmR5ytQrutqJN/bMMncqCcHiHtQ8IoPfgXp8+Hws8q 8vMGSNxGiuYwKS7RSn+3B0dMrElmUXJc0+n9KuenGWpPtqp7MKo70SOdlqHd4bx9VWmo VVGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=86wOUpqgY1AI409imnR0FBW39DXCAtH+DIkXM2heYs8=; b=EVmslPCaUuuzM/Pw0FGOOwedR7nIpQ6H0+04+mhpPDzZ10FQ/7CREpaij1DofH2Hhm 9aNFIbdRVDKG3amzA/0tHqZ1xdhevmhCZu1XLhv6KW39dkvniAMTfnzgXbleyu+M7UW9 CaTKTVN8lKZcaafV5MTFNkrHAA7HlzPi5M0n+a9sYYKU1hPq2vq4xOmL5adUlrIH7JZd dgS1wf+k4sXgjrqeu53z3qIsrU+ogc/uelfA+VSmgSEI7dGK2qn32EH6X0IhBl6dQ9G2 HzOnv0LuU3sC/SEJ0IpjRIHUNBv0rTicqoZIXzPeYxcJtOQs6IbiO//a5PZL9sjf/EZS R+mQ== X-Gm-Message-State: AOAM5318Bm/ddPu9WlL/OxH6sSHg7OJSBq0V8JW4Lcp63flw4BtvLx+y gePdNJOuwn+9fYhdwxzHgTAOFLGjriFh7Q== X-Google-Smtp-Source: ABdhPJwWtFgi8zgyn4Qt65+C4xWPQE0UcS+Ft7Tkg+NM4EdWhZI664Cp92v2OiCOpzkyTuEkYstZhQ== X-Received: by 2002:a1c:e208:: with SMTP id z8mr361330wmg.111.1615911487739; Tue, 16 Mar 2021 09:18:07 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:06 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 16/22] fsck.[ch]: move FOREACH_FSCK_MSG_ID & fsck_msg_id from *.c to *.h Date: Tue, 16 Mar 2021 17:17:32 +0100 Message-Id: <20210316161738.30254-17-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the FOREACH_FSCK_MSG_ID macro and the fsck_msg_id enum it helps define from fsck.c to fsck.h. This is in preparation for having non-static functions take the fsck_msg_id as an argument. Signed-off-by: Ævar Arnfjörð Bjarmason --- fsck.c | 66 ---------------------------------------------------------- fsck.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/fsck.c b/fsck.c index 6fbc56e9fa..8a66168e51 100644 --- a/fsck.c +++ b/fsck.c @@ -22,72 +22,6 @@ static struct oidset gitmodules_found = OIDSET_INIT; static struct oidset gitmodules_done = OIDSET_INIT; -#define FOREACH_FSCK_MSG_ID(FUNC) \ - /* fatal errors */ \ - FUNC(NUL_IN_HEADER, FATAL) \ - FUNC(UNTERMINATED_HEADER, FATAL) \ - /* errors */ \ - FUNC(BAD_DATE, ERROR) \ - FUNC(BAD_DATE_OVERFLOW, ERROR) \ - FUNC(BAD_EMAIL, ERROR) \ - FUNC(BAD_NAME, ERROR) \ - FUNC(BAD_OBJECT_SHA1, ERROR) \ - FUNC(BAD_PARENT_SHA1, ERROR) \ - FUNC(BAD_TAG_OBJECT, ERROR) \ - FUNC(BAD_TIMEZONE, ERROR) \ - FUNC(BAD_TREE, ERROR) \ - FUNC(BAD_TREE_SHA1, ERROR) \ - FUNC(BAD_TYPE, ERROR) \ - FUNC(DUPLICATE_ENTRIES, ERROR) \ - FUNC(MISSING_AUTHOR, ERROR) \ - FUNC(MISSING_COMMITTER, ERROR) \ - FUNC(MISSING_EMAIL, ERROR) \ - FUNC(MISSING_NAME_BEFORE_EMAIL, ERROR) \ - FUNC(MISSING_OBJECT, ERROR) \ - FUNC(MISSING_SPACE_BEFORE_DATE, ERROR) \ - FUNC(MISSING_SPACE_BEFORE_EMAIL, ERROR) \ - FUNC(MISSING_TAG, ERROR) \ - FUNC(MISSING_TAG_ENTRY, ERROR) \ - FUNC(MISSING_TREE, ERROR) \ - FUNC(MISSING_TREE_OBJECT, ERROR) \ - FUNC(MISSING_TYPE, ERROR) \ - FUNC(MISSING_TYPE_ENTRY, ERROR) \ - FUNC(MULTIPLE_AUTHORS, ERROR) \ - FUNC(TREE_NOT_SORTED, ERROR) \ - FUNC(UNKNOWN_TYPE, ERROR) \ - FUNC(ZERO_PADDED_DATE, ERROR) \ - FUNC(GITMODULES_MISSING, ERROR) \ - FUNC(GITMODULES_BLOB, ERROR) \ - FUNC(GITMODULES_LARGE, ERROR) \ - FUNC(GITMODULES_NAME, ERROR) \ - FUNC(GITMODULES_SYMLINK, ERROR) \ - FUNC(GITMODULES_URL, ERROR) \ - FUNC(GITMODULES_PATH, ERROR) \ - FUNC(GITMODULES_UPDATE, ERROR) \ - /* warnings */ \ - FUNC(BAD_FILEMODE, WARN) \ - FUNC(EMPTY_NAME, WARN) \ - FUNC(FULL_PATHNAME, WARN) \ - FUNC(HAS_DOT, WARN) \ - FUNC(HAS_DOTDOT, WARN) \ - FUNC(HAS_DOTGIT, WARN) \ - FUNC(NULL_SHA1, WARN) \ - FUNC(ZERO_PADDED_FILEMODE, WARN) \ - FUNC(NUL_IN_COMMIT, WARN) \ - /* infos (reported as warnings, but ignored by default) */ \ - FUNC(GITMODULES_PARSE, INFO) \ - FUNC(BAD_TAG_NAME, INFO) \ - FUNC(MISSING_TAGGER_ENTRY, INFO) \ - /* ignored (elevated when requested) */ \ - FUNC(EXTRA_HEADER_ENTRY, IGNORE) - -#define MSG_ID(id, msg_type) FSCK_MSG_##id, -enum fsck_msg_id { - FOREACH_FSCK_MSG_ID(MSG_ID) - FSCK_MSG_MAX -}; -#undef MSG_ID - #define STR(x) #x #define MSG_ID(id, msg_type) { STR(id), NULL, NULL, FSCK_##msg_type }, static struct { diff --git a/fsck.h b/fsck.h index fce9981a0c..c3d3b47b88 100644 --- a/fsck.h +++ b/fsck.h @@ -13,6 +13,72 @@ enum fsck_msg_type { FSCK_WARN, }; +#define FOREACH_FSCK_MSG_ID(FUNC) \ + /* fatal errors */ \ + FUNC(NUL_IN_HEADER, FATAL) \ + FUNC(UNTERMINATED_HEADER, FATAL) \ + /* errors */ \ + FUNC(BAD_DATE, ERROR) \ + FUNC(BAD_DATE_OVERFLOW, ERROR) \ + FUNC(BAD_EMAIL, ERROR) \ + FUNC(BAD_NAME, ERROR) \ + FUNC(BAD_OBJECT_SHA1, ERROR) \ + FUNC(BAD_PARENT_SHA1, ERROR) \ + FUNC(BAD_TAG_OBJECT, ERROR) \ + FUNC(BAD_TIMEZONE, ERROR) \ + FUNC(BAD_TREE, ERROR) \ + FUNC(BAD_TREE_SHA1, ERROR) \ + FUNC(BAD_TYPE, ERROR) \ + FUNC(DUPLICATE_ENTRIES, ERROR) \ + FUNC(MISSING_AUTHOR, ERROR) \ + FUNC(MISSING_COMMITTER, ERROR) \ + FUNC(MISSING_EMAIL, ERROR) \ + FUNC(MISSING_NAME_BEFORE_EMAIL, ERROR) \ + FUNC(MISSING_OBJECT, ERROR) \ + FUNC(MISSING_SPACE_BEFORE_DATE, ERROR) \ + FUNC(MISSING_SPACE_BEFORE_EMAIL, ERROR) \ + FUNC(MISSING_TAG, ERROR) \ + FUNC(MISSING_TAG_ENTRY, ERROR) \ + FUNC(MISSING_TREE, ERROR) \ + FUNC(MISSING_TREE_OBJECT, ERROR) \ + FUNC(MISSING_TYPE, ERROR) \ + FUNC(MISSING_TYPE_ENTRY, ERROR) \ + FUNC(MULTIPLE_AUTHORS, ERROR) \ + FUNC(TREE_NOT_SORTED, ERROR) \ + FUNC(UNKNOWN_TYPE, ERROR) \ + FUNC(ZERO_PADDED_DATE, ERROR) \ + FUNC(GITMODULES_MISSING, ERROR) \ + FUNC(GITMODULES_BLOB, ERROR) \ + FUNC(GITMODULES_LARGE, ERROR) \ + FUNC(GITMODULES_NAME, ERROR) \ + FUNC(GITMODULES_SYMLINK, ERROR) \ + FUNC(GITMODULES_URL, ERROR) \ + FUNC(GITMODULES_PATH, ERROR) \ + FUNC(GITMODULES_UPDATE, ERROR) \ + /* warnings */ \ + FUNC(BAD_FILEMODE, WARN) \ + FUNC(EMPTY_NAME, WARN) \ + FUNC(FULL_PATHNAME, WARN) \ + FUNC(HAS_DOT, WARN) \ + FUNC(HAS_DOTDOT, WARN) \ + FUNC(HAS_DOTGIT, WARN) \ + FUNC(NULL_SHA1, WARN) \ + FUNC(ZERO_PADDED_FILEMODE, WARN) \ + FUNC(NUL_IN_COMMIT, WARN) \ + /* infos (reported as warnings, but ignored by default) */ \ + FUNC(GITMODULES_PARSE, INFO) \ + FUNC(BAD_TAG_NAME, INFO) \ + FUNC(MISSING_TAGGER_ENTRY, INFO) \ + /* ignored (elevated when requested) */ \ + FUNC(EXTRA_HEADER_ENTRY, IGNORE) + +#define MSG_ID(id, msg_type) FSCK_MSG_##id, +enum fsck_msg_id { + FOREACH_FSCK_MSG_ID(MSG_ID) + FSCK_MSG_MAX +}; +#undef MSG_ID + struct fsck_options; struct object; From patchwork Tue Mar 16 16:17:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142835 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48C76C43331 for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26BC46511C for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238685AbhCPQTD (ORCPT ); Tue, 16 Mar 2021 12:19:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238606AbhCPQSL (ORCPT ); Tue, 16 Mar 2021 12:18:11 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20795C061764 for ; Tue, 16 Mar 2021 09:18:10 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id o14so6976204wrm.11 for ; Tue, 16 Mar 2021 09:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aOJ/WwzjdP5YoN4cI05g8XpERVSTnf1CtrzFMFsUeEA=; b=ZGNGEMoqiaUq9Vgu5hIAzHwtBBvn1YwYePdhdtYG6YZG2fH/YA1a7HuNcY7vWxUTPV k9o/EM/fxu5rcuylbx3Jvpj2x+OM7x3MQzS1hvYhU7wzJW/vlWEm3CtHvSLjTEWnMVnG qkOa4avQB2hqJxy39D+wZxhddxZSv6LM4X6V7nfKwWUjMK5DfWserjurn3CMgaA+5iyy 0d+NC4sqbntDM7WztUMIOrLpKsF7Ya2fyNZ89Jjt1ziLLM95l3vi9PrBurPTrUx7ipXV 52s+q1EItQ+e4mksre8ksx0crpaTrvWIrZ3lcDZlZrFnGunPkqP6oh2I7Cl/F6rAgcoL TMmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aOJ/WwzjdP5YoN4cI05g8XpERVSTnf1CtrzFMFsUeEA=; b=fiwzCy2JU5Yf9b9ifG52wn3mJSsAiYnEwUydGF0PU6Cx7028nOUWQsXug7lbzZb+LI jf5D+Gie4SxcvpuzVQKNoCyeO2cGbcMOs/pePgC4+SP0Z84JTeDllAcpTWY6wzTVO7Wz qts1PHwYbujvd/G9vND2xJXYrUMezXC5SpCOi48S1wJsCbWf0BkWHV4w4hf35YioeJ+B MIUBISYUY0cJSjpo5mNShduzYGuNB943jNISoT4InteKkB2FiZP6fQYdC7oolVyuLidM a03qv/D3WVVmzTZ1h+AU5PlsYQfKTQDdn+UC2x7JMaYdCqfcaqekU7m0wWPOwT/rLgI5 NIew== X-Gm-Message-State: AOAM5324MilOYQbzCDI/7ImsQDR4cR3elSs4wwVnZEWs0J3VmscH/uX5 DxvhTS6fo+XzMHUbkie4MG1S/1FiAW7JIQ== X-Google-Smtp-Source: ABdhPJxoJYAYEudIBJbeFw1Apzy2SeJi1eRH8gvLAgw7+5GcS7twLHj76jGXD8embAkx/RJJQkVD+w== X-Received: by 2002:adf:dd0a:: with SMTP id a10mr5912459wrm.145.1615911488604; Tue, 16 Mar 2021 09:18:08 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:07 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 17/22] fsck.c: pass along the fsck_msg_id in the fsck_error callback Date: Tue, 16 Mar 2021 17:17:33 +0100 Message-Id: <20210316161738.30254-18-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the fsck_error callback to also pass along the fsck_msg_id. Before this change the only way to get the message id was to parse it back out of the "message". Let's pass it down explicitly for the benefit of callers that might want to use it, as discussed in [1]. Passing the msg_type is now redundant, as you can always get it back from the msg_id, but I'm not changing that convention. It's really common to need the msg_type, and the report() function itself (which calls "fsck_error") needs to call fsck_msg_type() to discover it. Let's not needlessly re-do that work in the user callback. 1. https://lore.kernel.org/git/87blcja2ha.fsf@evledraar.gmail.com/ Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/fsck.c | 4 +++- builtin/index-pack.c | 3 ++- builtin/mktag.c | 1 + fsck.c | 6 ++++-- fsck.h | 6 ++++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index d6d745dc70..b71fac4cec 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -89,7 +89,9 @@ static int objerror(struct object *obj, const char *err) static int fsck_error_func(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - enum fsck_msg_type msg_type, const char *message) + enum fsck_msg_type msg_type, + enum fsck_msg_id msg_id, + const char *message) { switch (msg_type) { case FSCK_WARN: diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 56b8efaa89..2b2266a4b7 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1717,6 +1717,7 @@ static int print_dangling_gitmodules(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, enum fsck_msg_type msg_type, + enum fsck_msg_id msg_id, const char *message) { /* @@ -1727,7 +1728,7 @@ static int print_dangling_gitmodules(struct fsck_options *o, printf("%s\n", oid_to_hex(oid)); return 0; } - return fsck_error_function(o, oid, object_type, msg_type, message); + return fsck_error_function(o, oid, object_type, msg_type, msg_id, message); } int cmd_index_pack(int argc, const char **argv, const char *prefix) diff --git a/builtin/mktag.c b/builtin/mktag.c index 1834394a9b..dc989c356f 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -23,6 +23,7 @@ static int mktag_fsck_error_func(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, enum fsck_msg_type msg_type, + enum fsck_msg_id msg_id, const char *message) { switch (msg_type) { diff --git a/fsck.c b/fsck.c index 8a66168e51..5a040eb4fd 100644 --- a/fsck.c +++ b/fsck.c @@ -245,7 +245,7 @@ static int report(struct fsck_options *options, va_start(ap, fmt); strbuf_vaddf(&sb, fmt, ap); result = options->error_func(options, oid, object_type, - msg_type, sb.buf); + msg_type, msg_id, sb.buf); strbuf_release(&sb); va_end(ap); @@ -1198,7 +1198,9 @@ int fsck_object(struct object *obj, void *data, unsigned long size, int fsck_error_function(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - enum fsck_msg_type msg_type, const char *message) + enum fsck_msg_type msg_type, + enum fsck_msg_id msg_id, + const char *message) { if (msg_type == FSCK_WARN) { warning("object %s: %s", fsck_describe_object(o, oid), message); diff --git a/fsck.h b/fsck.h index c3d3b47b88..33ecf3f3f1 100644 --- a/fsck.h +++ b/fsck.h @@ -101,11 +101,13 @@ typedef int (*fsck_walk_func)(struct object *obj, enum object_type object_type, /* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */ typedef int (*fsck_error)(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - enum fsck_msg_type msg_type, const char *message); + enum fsck_msg_type msg_type, enum fsck_msg_id msg_id, + const char *message); int fsck_error_function(struct fsck_options *o, const struct object_id *oid, enum object_type object_type, - enum fsck_msg_type msg_type, const char *message); + enum fsck_msg_type msg_type, enum fsck_msg_id msg_id, + const char *message); struct fsck_options { fsck_walk_func walk; From patchwork Tue Mar 16 16:17:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B3B3C43332 for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D1716511D for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238674AbhCPQS6 (ORCPT ); Tue, 16 Mar 2021 12:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238607AbhCPQSL (ORCPT ); Tue, 16 Mar 2021 12:18:11 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E158C061765 for ; Tue, 16 Mar 2021 09:18:11 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id b2-20020a7bc2420000b029010be1081172so1803894wmj.1 for ; Tue, 16 Mar 2021 09:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LLLS+orsKOB3Y7zGkEJaBeqB437/baKQ+ohkELuntd8=; b=Zk60pncaxzq2IxJF0yYUMyE0MsfMo4cj5dunB1d+VWLiG9WzevCs7Dbp+xby0CryFy qXY27jv860JE6imoFmrvFIE2/+UiTOs6XlVmOCJJ9CkJwaoPn1xR5D07xW1Uhhv9QKtT VMITr1kDQsvqKikTDAhwJfyj9HnCFJU6W3BjArY8mdtU9ybStGl0GtAs2Gyguua+96Md M1IUNPgrBPGEdqhqTupdbgjBFq8cr+tfX7YpmxsEvFrnxXi+L45vhTW0RETzKn9Y90Lc kdzkhLiCYkrbk6ZgAnVH8Y594Ix08zCqDMeldMJlTm3OPV9STJBDlg4sOy5SNiZUuCyt cL4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LLLS+orsKOB3Y7zGkEJaBeqB437/baKQ+ohkELuntd8=; b=EvVWfU7EtU3vFRgpKKcoB8Cx3THyNu2CAljxrOp7D1pKDQnN+zLFUHpx/rESBL0Vu+ bBCGbNK4PbOaw8+JBXVl424SXa+2P1AjbJ7RqG/A2Eai9d/sGa8qnG7tQ4xV4qP2P9sn au+mgx3RHB0r0BySrUuJ1rdDCQllyI7mla/w/9QB76a4yn+DP9rH9L8qU5ccBcbL17Gq vnsLgf2lRUYXLExegRDxZPfud4GdfnegD4puKyDjFocpULa5aGFnwHgM2Wg/MdDnGfM1 KbmeYh7Yv8mF6tUHvvIXKq3F/i2lKPOje7GutDVBSm3bMOvyMi3W/nwA/x0Mooo1pVsZ R52A== X-Gm-Message-State: AOAM530UY6G/spT01ZwvNUiy2ZiDVVbJevYfttvTxg10qSYK3qiJobRE zvFN6HsVYc3X33yZ0z/HSVWOBqL3lhn5nQ== X-Google-Smtp-Source: ABdhPJxHSf9yq300XaptPz9FanHT9MeCdEagAqcjHFllUVgrzKhsI2JVuMFho8dbzUX/ET5V9b+0Uw== X-Received: by 2002:a7b:c346:: with SMTP id l6mr34191wmj.34.1615911489513; Tue, 16 Mar 2021 09:18:09 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:08 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 18/22] fsck.c: add an fsck_set_msg_type() API that takes enums Date: Tue, 16 Mar 2021 17:17:34 +0100 Message-Id: <20210316161738.30254-19-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change code I added in acf9de4c94e (mktag: use fsck instead of custom verify_tag(), 2021-01-05) to make use of a new API function that takes the fsck_msg_{id,type} types, instead of arbitrary strings that we'll (hopefully) parse into those types. At the time that the fsck_set_msg_type() API was introduced in 0282f4dced0 (fsck: offer a function to demote fsck errors to warnings, 2015-06-22) it was only intended to be used to parse user-supplied data. For things that are purely internal to the C code it makes sense to have the compiler check these arguments, and to skip the sanity checking of the data in fsck_set_msg_type() which is redundant to checks we get from the compiler. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/mktag.c | 3 ++- fsck.c | 27 +++++++++++++++++---------- fsck.h | 3 +++ 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/builtin/mktag.c b/builtin/mktag.c index dc989c356f..de67a94f24 100644 --- a/builtin/mktag.c +++ b/builtin/mktag.c @@ -93,7 +93,8 @@ int cmd_mktag(int argc, const char **argv, const char *prefix) die_errno(_("could not read from stdin")); fsck_options.error_func = mktag_fsck_error_func; - fsck_set_msg_type(&fsck_options, "extraheaderentry", "warn"); + fsck_set_msg_type_from_ids(&fsck_options, FSCK_MSG_EXTRA_HEADER_ENTRY, + FSCK_WARN); /* config might set fsck.extraHeaderEntry=* again */ git_config(mktag_config, NULL); if (fsck_tag_standalone(NULL, buf.buf, buf.len, &fsck_options, diff --git a/fsck.c b/fsck.c index 5a040eb4fd..f26f47b2a1 100644 --- a/fsck.c +++ b/fsck.c @@ -132,6 +132,22 @@ int is_valid_msg_type(const char *msg_id, const char *msg_type) return 1; } +void fsck_set_msg_type_from_ids(struct fsck_options *options, + enum fsck_msg_id msg_id, + enum fsck_msg_type msg_type) +{ + if (!options->msg_type) { + int i; + enum fsck_msg_type *severity; + ALLOC_ARRAY(severity, FSCK_MSG_MAX); + for (i = 0; i < FSCK_MSG_MAX; i++) + severity[i] = fsck_msg_type(i, options); + options->msg_type = severity; + } + + options->msg_type[msg_id] = msg_type; +} + void fsck_set_msg_type(struct fsck_options *options, const char *msg_id_str, const char *msg_type_str) { @@ -144,16 +160,7 @@ void fsck_set_msg_type(struct fsck_options *options, if (msg_type != FSCK_ERROR && msg_id_info[msg_id].msg_type == FSCK_FATAL) die("Cannot demote %s to %s", msg_id_str, msg_type_str); - if (!options->msg_type) { - int i; - enum fsck_msg_type *severity; - ALLOC_ARRAY(severity, FSCK_MSG_MAX); - for (i = 0; i < FSCK_MSG_MAX; i++) - severity[i] = fsck_msg_type(i, options); - options->msg_type = severity; - } - - options->msg_type[msg_id] = msg_type; + fsck_set_msg_type_from_ids(options, msg_id, msg_type); } void fsck_set_msg_types(struct fsck_options *options, const char *values) diff --git a/fsck.h b/fsck.h index 33ecf3f3f1..6c2fd9c5cc 100644 --- a/fsck.h +++ b/fsck.h @@ -82,6 +82,9 @@ enum fsck_msg_id { struct fsck_options; struct object; +void fsck_set_msg_type_from_ids(struct fsck_options *options, + enum fsck_msg_id msg_id, + enum fsck_msg_type msg_type); void fsck_set_msg_type(struct fsck_options *options, const char *msg_id, const char *msg_type); void fsck_set_msg_types(struct fsck_options *options, const char *values); From patchwork Tue Mar 16 16:17:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142831 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 246E7C4332E for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E57CF6511B for ; Tue, 16 Mar 2021 16:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238664AbhCPQSz (ORCPT ); Tue, 16 Mar 2021 12:18:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238608AbhCPQSM (ORCPT ); Tue, 16 Mar 2021 12:18:12 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF433C06175F for ; Tue, 16 Mar 2021 09:18:11 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id m20-20020a7bcb940000b029010cab7e5a9fso1781827wmi.3 for ; Tue, 16 Mar 2021 09:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MWprKFlNUI27M0pkOkKU3pJzus6HWEumeKCB0WZfN9s=; b=sK5loQs58joHPuQ251iZGqOFuYJRkWy9f0DdkwERncet7xgsKIhT9/PjeApHkbQOic FU94sOgZxGw36S4YRL83L4TEZ7fPbIE/4JaXH9hVQ74EGUTi4QGCrpMpzi7fH1/ATp0d QyKuJ/N/mU6WFA6b3ZvEmafNuRqjN+nvAj2iz+fnFY6rPyKNfZJzR9GPz2K1fPMzgQCr 3t8Qcv9k17jc7GErW+K7eNAFIlDKeGp5DAHip+SuLH8+V+VQC+Q5OoOKvyj2XtBAEojk TRUAOrDrIlFfbCBeZU6AFzW/T1G3hwK4MLd/guxonKopnPbYtQ9iA1GQ7IEWxgzuW3Vp F9pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MWprKFlNUI27M0pkOkKU3pJzus6HWEumeKCB0WZfN9s=; b=s4xJNTpTny5iVvvWdntGcShchA82mRSpR29wzRLD6OC+HYu0q1wau8p5bzoGYlhioI WJp5E8wwElEk1HO0pqPAP2G662J4c7mvGpKLzWLYtCibWE9HanYyn1qEkKicopD73gac vPBHWIInDdXCFBaYT+1FXGDYz0+VIgJRjvnvMNoo99LgTW9dAOEJ1bdpqlPp2Va5Nz9J MD3E7Llqhk7zaRQr1duYTDN1fcwDpkMAkDtZ9XCUEiB860lJfGfiW6oH3TW4/GS/Q6kl CQqH4Zj4qvPkmlCz0DlvE1RmG7QE8tsJiTlfxRfBoMDxV4uQ6fjL7M4/185cK5YQB95o 9Bxg== X-Gm-Message-State: AOAM533Gz0OCzcsRNSENPJ7gHjeWcL1Q/+QElE3trMwJmzBeW+OPZ7uJ S7ZHSjGY5Ybc/44QgkprREtgSN+c33p0tA== X-Google-Smtp-Source: ABdhPJy5u/rwfjxP8M/3zx+XE6MWX6n1As0j/Yc+jmL1by3ffav1+sQpLBcwGvIVMtRiTOkhyzJyCg== X-Received: by 2002:a05:600c:4a06:: with SMTP id c6mr382796wmp.35.1615911490414; Tue, 16 Mar 2021 09:18:10 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:09 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 19/22] fsck.c: move gitmodules_{found,done} into fsck_options Date: Tue, 16 Mar 2021 17:17:35 +0100 Message-Id: <20210316161738.30254-20-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Move the gitmodules_{found,done} static variables added in 159e7b080bf (fsck: detect gitmodules files, 2018-05-02) into the fsck_options struct. It makes sense to keep all the context in the same place. This requires changing the recently added register_found_gitmodules() function added in 5476e1efde (fetch-pack: print and use dangling .gitmodules, 2021-02-22) to take fsck_options. That function will be removed in a subsequent commit, but as it'll require the new gitmodules_found attribute of "fsck_options" we need this intermediate step first. Signed-off-by: Ævar Arnfjörð Bjarmason --- fetch-pack.c | 2 +- fsck.c | 23 ++++++++++------------- fsck.h | 7 ++++++- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 6a61a46428..82c3c2c043 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -998,7 +998,7 @@ static void fsck_gitmodules_oids(struct oidset *gitmodules_oids) oidset_iter_init(gitmodules_oids, &iter); while ((oid = oidset_iter_next(&iter))) - register_found_gitmodules(oid); + register_found_gitmodules(&fo, oid); if (fsck_finish(&fo)) die("fsck failed"); } diff --git a/fsck.c b/fsck.c index f26f47b2a1..565274a946 100644 --- a/fsck.c +++ b/fsck.c @@ -19,9 +19,6 @@ #include "credential.h" #include "help.h" -static struct oidset gitmodules_found = OIDSET_INIT; -static struct oidset gitmodules_done = OIDSET_INIT; - #define STR(x) #x #define MSG_ID(id, msg_type) { STR(id), NULL, NULL, FSCK_##msg_type }, static struct { @@ -624,7 +621,7 @@ static int fsck_tree(const struct object_id *oid, if (is_hfs_dotgitmodules(name) || is_ntfs_dotgitmodules(name)) { if (!S_ISLNK(mode)) - oidset_insert(&gitmodules_found, oid); + oidset_insert(&options->gitmodules_found, oid); else retval += report(options, oid, OBJ_TREE, @@ -638,7 +635,7 @@ static int fsck_tree(const struct object_id *oid, has_dotgit |= is_ntfs_dotgit(backslash); if (is_ntfs_dotgitmodules(backslash)) { if (!S_ISLNK(mode)) - oidset_insert(&gitmodules_found, oid); + oidset_insert(&options->gitmodules_found, oid); else retval += report(options, oid, OBJ_TREE, FSCK_MSG_GITMODULES_SYMLINK, @@ -1150,9 +1147,9 @@ static int fsck_blob(const struct object_id *oid, const char *buf, struct fsck_gitmodules_data data; struct config_options config_opts = { 0 }; - if (!oidset_contains(&gitmodules_found, oid)) + if (!oidset_contains(&options->gitmodules_found, oid)) return 0; - oidset_insert(&gitmodules_done, oid); + oidset_insert(&options->gitmodules_done, oid); if (object_on_skiplist(options, oid)) return 0; @@ -1217,9 +1214,9 @@ int fsck_error_function(struct fsck_options *o, return 1; } -void register_found_gitmodules(const struct object_id *oid) +void register_found_gitmodules(struct fsck_options *options, const struct object_id *oid) { - oidset_insert(&gitmodules_found, oid); + oidset_insert(&options->gitmodules_found, oid); } int fsck_finish(struct fsck_options *options) @@ -1228,13 +1225,13 @@ int fsck_finish(struct fsck_options *options) struct oidset_iter iter; const struct object_id *oid; - oidset_iter_init(&gitmodules_found, &iter); + oidset_iter_init(&options->gitmodules_found, &iter); while ((oid = oidset_iter_next(&iter))) { enum object_type type; unsigned long size; char *buf; - if (oidset_contains(&gitmodules_done, oid)) + if (oidset_contains(&options->gitmodules_done, oid)) continue; buf = read_object_file(oid, &type, &size); @@ -1259,8 +1256,8 @@ int fsck_finish(struct fsck_options *options) } - oidset_clear(&gitmodules_found); - oidset_clear(&gitmodules_done); + oidset_clear(&options->gitmodules_found); + oidset_clear(&options->gitmodules_done); return ret; } diff --git a/fsck.h b/fsck.h index 6c2fd9c5cc..bb59ef05b6 100644 --- a/fsck.h +++ b/fsck.h @@ -118,6 +118,8 @@ struct fsck_options { unsigned strict:1; enum fsck_msg_type *msg_type; struct oidset skiplist; + struct oidset gitmodules_found; + struct oidset gitmodules_done; kh_oid_map_t *object_names; }; @@ -125,6 +127,8 @@ struct fsck_options { .walk = NULL, \ .msg_type = NULL, \ .skiplist = OIDSET_INIT, \ + .gitmodules_found = OIDSET_INIT, \ + .gitmodules_done = OIDSET_INIT, \ .object_names = NULL, #define FSCK_OPTIONS_COMMON_ERROR_FUNC \ FSCK_OPTIONS_COMMON \ @@ -149,7 +153,8 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options); int fsck_object(struct object *obj, void *data, unsigned long size, struct fsck_options *options); -void register_found_gitmodules(const struct object_id *oid); +void register_found_gitmodules(struct fsck_options *options, + const struct object_id *oid); /* * fsck a tag, and pass info about it back to the caller. This is From patchwork Tue Mar 16 16:17:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE11BC4332D for ; Tue, 16 Mar 2021 16:19:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B317A65101 for ; Tue, 16 Mar 2021 16:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238659AbhCPQSy (ORCPT ); Tue, 16 Mar 2021 12:18:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238609AbhCPQSN (ORCPT ); Tue, 16 Mar 2021 12:18:13 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2C51C061756 for ; Tue, 16 Mar 2021 09:18:12 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id o14so6976301wrm.11 for ; Tue, 16 Mar 2021 09:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TTEfu+yAtM4EH9C+MXnOphrNzv2WHfSFRJGRl2nPKgQ=; b=aE75Q52FmaMBFbBmSVJKiNUUNvVCkabWXgDzaPAZW3gNtxHZJEP7N6JB0TnLm6n/vb o9EEVwNFm6NgSlC456w/RJ3+mfm84kvHMlfP+gN8KABOKsvB7ffw+/cNyly56KTlLo/A jM2Y0GyFZ90YFIqVGTwVUhDgIXpF33gjJp7NHaLNyigc+zTNFuoNsP10IXsLw2nL7rTO CcJFYTdcBJ6AabUcYd2K1hN9Jt3z5V2C0ONKVmBXtYOK4TiFQWg1vD/+HcAuC9ZhmzUf 2FdrIYi0RchYxgjJZbJ/Aoma/zviFIQErVhceHL1FLyladlOaKhlS6sm5ONTJlhrq9wP zeCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TTEfu+yAtM4EH9C+MXnOphrNzv2WHfSFRJGRl2nPKgQ=; b=Wztao2bbKolcIBemZvjhkiGHDHnTxnJYDpsHLZK9FWem6PC5+FICagEgrlPb3JHLaE y7bOpa7X+WfTThlWi1LyiTkdKfBHQdRGqRGR360TXdDMMDMdglhxFKxwwnw181G5wqp2 a3dnNI+EkVrfknujEFnhEzFWTmIhgWlPsmiMu41/jIKIbbMg+Gqa9LesR1guPjodWOM4 EdRrstjBr/HZ467JTvD2q04qWdNJDK2Swy5bklQn9pAOfJynnmUI9dcW3NsiEE5vBSeq DE55SZKR1i1AJqQgxMEO7tuOAdWtlZ7YAckXQbCfFJv5wxIUigbhCXrZ7y+rcEyFbqdn KYBg== X-Gm-Message-State: AOAM530Z0JrLNzyJz3XmoZQwCp4urL4auu89wLTuBbTWGMS5bPdWgVfi T17ub8FZ9sol2BUfBtREpQ3z4QNrn71hsg== X-Google-Smtp-Source: ABdhPJzVVOk6JEigOqjqLw5VonpdZItinSIx+1W14J4pior0UDPkdFcdKLBXbq9cAlqREBXrI+4Wnw== X-Received: by 2002:adf:828e:: with SMTP id 14mr5809190wrc.123.1615911491264; Tue, 16 Mar 2021 09:18:11 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:10 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 20/22] fetch-pack: don't needlessly copy fsck_options Date: Tue, 16 Mar 2021 17:17:36 +0100 Message-Id: <20210316161738.30254-21-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change the behavior of the .gitmodules validation added in 5476e1efde (fetch-pack: print and use dangling .gitmodules, 2021-02-22) so we're using one "fsck_options". I found that code confusing to read. One might think that not setting up the error_func earlier means that we're relying on the "error_func" not being set in some code in between the two hunks being modified here. But we're not, all we're doing in the rest of "cmd_index_pack()" is further setup by calling fsck_set_msg_types(), and assigning to do_fsck_object. So there was no reason in 5476e1efde to make a shallow copy of the fsck_options struct before setting error_func. Let's just do this setup at the top of the function, along with the "walk" assignment. Signed-off-by: Ævar Arnfjörð Bjarmason --- builtin/index-pack.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 2b2266a4b7..5ad80b85b4 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1761,6 +1761,7 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) read_replace_refs = 0; fsck_options.walk = mark_link; + fsck_options.error_func = print_dangling_gitmodules; reset_pack_idx_option(&opts); git_config(git_index_pack_config, &opts); @@ -1951,13 +1952,8 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) else close(input_fd); - if (do_fsck_object) { - struct fsck_options fo = fsck_options; - - fo.error_func = print_dangling_gitmodules; - if (fsck_finish(&fo)) - die(_("fsck error in pack objects")); - } + if (do_fsck_object && fsck_finish(&fsck_options)) + die(_("fsck error in pack objects")); free(objects); strbuf_release(&index_name_buf); From patchwork Tue Mar 16 16:17:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A071C4321A for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A81665092 for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238697AbhCPQTI (ORCPT ); Tue, 16 Mar 2021 12:19:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238562AbhCPQSO (ORCPT ); Tue, 16 Mar 2021 12:18:14 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A934C061762 for ; Tue, 16 Mar 2021 09:18:13 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id w203-20020a1c49d40000b029010c706d0642so4102346wma.0 for ; Tue, 16 Mar 2021 09:18:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P3vXHWJ2/Ynpr02hktr7aopm6VP3FNrN5iPVrzOnnFE=; b=RQ0Cbi0ybGl0DpC0YZEBY4XGwOLmBw7qx9sqPn/Ay4arPVjjJ2tccfC2/csD2ahc/p kiqWZPbNRWCSt//thZWOTbYb0fv1tI3XDcREbitZ6gkQ/Vs9R9t+iISy/EyP9LnLbGGu e02TlSL9Rt3yhdilO3Yye4njVw7BZSUt1exwMSo1mtIxErdHYMXtgTQnNoCitL0vARpE 1BdlLWbBxvxdYHIHk7qp1Tb5azhHguDRduakamysVj1lfTVtKmUlgGouvDcAIMesZt3y co6GmoenOsCsLMK4amOwl0h7+XDqlUbUeYEuLdt4cwbSf/Dsn8sFL3zaw59toEjV4ish TgPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P3vXHWJ2/Ynpr02hktr7aopm6VP3FNrN5iPVrzOnnFE=; b=jZ0D5V5u3GquOY3jOX+b9R8ZGphv7obgx/zbFg3i+K/J4kO5lfy6j+36ziR/ho6t03 kQTrh4SQMDXzKVf93nz0dpIbF54V3m/Nc+U59mNPvt7xGKcZcXDBr/sPNPrAJfDqTnNe DI4vyOfXyfUhStRc/zYl961I2cWpo/2qrPBSVjBNIBORJciPprlKf6XIY/aU8mrjAIqm cAHdRxfMhNrlDMjXpt+7k7ST0UeDXyJAlUl+bTpSXQ3R185kpJj7QGOyClpeEVfMWxJd bxBL3UaIbn8eQUZJXUZn6m9SY20radQBdzVMsCYWeRFTf5+snCnHuIG/y2Ld0qa8pcm0 OJyQ== X-Gm-Message-State: AOAM532X33cb7RXtAm8JfUlH4YZFpSFaBA/hUPLJYCvkYvGJA7eOeyMq 9pfm+CwxNyyn4ISCv+OSUttEYDE49I+BUw== X-Google-Smtp-Source: ABdhPJz1OrObnH6fONaoyrEyTwyP8kD9iMegzc8VeHw4JdD0bQwJan6s/F01LRDoegd3/XB6gXpS3Q== X-Received: by 2002:a1c:e4d4:: with SMTP id b203mr358562wmh.105.1615911491962; Tue, 16 Mar 2021 09:18:11 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:11 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 21/22] fetch-pack: use file-scope static struct for fsck_options Date: Tue, 16 Mar 2021 17:17:37 +0100 Message-Id: <20210316161738.30254-22-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change code added in 5476e1efde (fetch-pack: print and use dangling .gitmodules, 2021-02-22) so that we use a file-scoped "static struct fsck_options" instead of defining one in the "fsck_gitmodules_oids()" function. We use this pattern in all of builtin/{fsck,index-pack,mktag,unpack-objects}.c. It's odd to see fetch-pack be the odd one out. One might think that we're using other fsck_options structs in fetch-pack, or doing on fsck twice there, but we're not. Signed-off-by: Ævar Arnfjörð Bjarmason --- fetch-pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 82c3c2c043..229fd8e2c2 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -38,6 +38,7 @@ static int server_supports_filtering; static int advertise_sid; static struct shallow_lock shallow_lock; static const char *alternate_shallow_file; +static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT; static struct strbuf fsck_msg_types = STRBUF_INIT; static struct string_list uri_protocols = STRING_LIST_INIT_DUP; @@ -991,15 +992,14 @@ static void fsck_gitmodules_oids(struct oidset *gitmodules_oids) { struct oidset_iter iter; const struct object_id *oid; - struct fsck_options fo = FSCK_OPTIONS_STRICT; if (!oidset_size(gitmodules_oids)) return; oidset_iter_init(gitmodules_oids, &iter); while ((oid = oidset_iter_next(&iter))) - register_found_gitmodules(&fo, oid); - if (fsck_finish(&fo)) + register_found_gitmodules(&fsck_options, oid); + if (fsck_finish(&fsck_options)) die("fsck failed"); } From patchwork Tue Mar 16 16:17:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12142837 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E254C43333 for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 43A666511D for ; Tue, 16 Mar 2021 16:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238688AbhCPQTG (ORCPT ); Tue, 16 Mar 2021 12:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238563AbhCPQSP (ORCPT ); Tue, 16 Mar 2021 12:18:15 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AF3DC0613D7 for ; Tue, 16 Mar 2021 09:18:14 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id j2so10755757wrx.9 for ; Tue, 16 Mar 2021 09:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c1C4KLosOvfPC9ghnuM63DVZODr7o1/aob0+caMMMEY=; b=BTc0P2oYY2jrNoq2bpTcI648myYc+U4LKEopaBBukxh1u2qu1NgQf4AiHX5OIgczPC b8z+nB6ZSbJ68rQxzugrlwZu0w43BZ5fCs0Evpgq0gfDZc5h2sUEa8DPxl7f8v6OGiBc HW4/sPqaxQTJp7N3cFIEJMvftmty3FT+Dkk4MqzNstY7oRNjZgze21ue2bLO86+Khd2b fnFVcgAnCm8UIBPT3tPJTP5MTNV+n+tkNb0Aa2bIGUZBpAYfweRi8dmmTbWcVjNLzDLY f33C6Hn3T84JBXnxK27zIPWm13M3qM8mVHBwatlxg6J+cpod1wM+P884+evUpfLcrmpG OEhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c1C4KLosOvfPC9ghnuM63DVZODr7o1/aob0+caMMMEY=; b=PCD5FHykb5FHjApgPJNLhGg0IJQTcLvwmzmoikBIb+f1TgRfs3Y6OYqVmihNo985Bn s2liO1RHVHANwILtHIX2FENgdFNMyDCgjICv21ajjJ5a9gvKK4oYJqN4POfGQmbOlZVn /DiK3ok5fcLK6OQ6ClbJR96q4v/QdQJLD2vela1SGvOB3KSBXy4tZm4FeklnwBhnPnu8 IVKKxP66D+xy7dVU5P5uGFHdhOIU0zCJPfwNt1iRXimu4CDY5c0mOmsV2aIxsj759GrQ 5QRMgO1XvrFbMZl6nBUJQYYbZzI6ZFT7OD4pK6dkVbUuVTAc2koKwhRxFG9FMOKefumG tOyA== X-Gm-Message-State: AOAM532marrX0xr7xoiTg/kjSqbEM2/9SVI2n2KBqJzHEovEv8jyIvjK SnggNS7bNlwI5RDERbSPDS1olaI6xJVbyw== X-Google-Smtp-Source: ABdhPJw18OCH9WbMhfHjEB/8IsEuIgquNHOSxekLN0t5QyUMWHKva32kOL3ENmScBo4F9VXKiWySwQ== X-Received: by 2002:adf:fbc8:: with SMTP id d8mr5890168wrs.94.1615911492778; Tue, 16 Mar 2021 09:18:12 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id r11sm22369206wrx.37.2021.03.16.09.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 09:18:12 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Johannes Schindelin , Jonathan Tan , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= Subject: [PATCH v4 22/22] fetch-pack: use new fsck API to printing dangling submodules Date: Tue, 16 Mar 2021 17:17:38 +0100 Message-Id: <20210316161738.30254-23-avarab@gmail.com> X-Mailer: git-send-email 2.31.0.260.g719c683c1d In-Reply-To: <20210306110439.27694-1-avarab@gmail.com> References: <20210306110439.27694-1-avarab@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Refactor the check added in 5476e1efde (fetch-pack: print and use dangling .gitmodules, 2021-02-22) to make use of us now passing the "msg_id" to the user defined "error_func". We can now compare against the FSCK_MSG_GITMODULES_MISSING instead of parsing the generated message. Let's also replace register_found_gitmodules() with directly manipulating the "gitmodules_found" member. A recent commit moved it into "fsck_options" so we could do this here. Add a fsck-cb.c file similar to parse-options-cb.c, the alternative would be to either define this directly in fsck.c as a public API, or to create some library shared by fetch-pack.c ad builtin/index-pack. I expect that there won't be many of these fsck utility functions in the future, so just having a single fsck-cb.c makes sense. Signed-off-by: Ævar Arnfjörð Bjarmason --- Makefile | 1 + builtin/index-pack.c | 21 +-------------------- fetch-pack.c | 4 ++-- fsck-cb.c | 16 ++++++++++++++++ fsck.c | 5 ----- fsck.h | 22 +++++++++++++++++++--- 6 files changed, 39 insertions(+), 30 deletions(-) create mode 100644 fsck-cb.c diff --git a/Makefile b/Makefile index dfb0f1000f..3faa8bd0d3 100644 --- a/Makefile +++ b/Makefile @@ -882,6 +882,7 @@ LIB_OBJS += fetch-negotiator.o LIB_OBJS += fetch-pack.o LIB_OBJS += fmt-merge-msg.o LIB_OBJS += fsck.o +LIB_OBJS += fsck-cb.o LIB_OBJS += fsmonitor.o LIB_OBJS += gettext.o LIB_OBJS += gpg-interface.o diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 5ad80b85b4..11f0fafd33 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -120,7 +120,7 @@ static int nr_threads; static int from_stdin; static int strict; static int do_fsck_object; -static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT; +static struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES; static int verbose; static int show_resolving_progress; static int show_stat; @@ -1713,24 +1713,6 @@ static void show_pack_info(int stat_only) } } -static int print_dangling_gitmodules(struct fsck_options *o, - const struct object_id *oid, - enum object_type object_type, - enum fsck_msg_type msg_type, - enum fsck_msg_id msg_id, - const char *message) -{ - /* - * NEEDSWORK: Plumb the MSG_ID (from fsck.c) here and use it - * instead of relying on this string check. - */ - if (starts_with(message, "gitmodulesMissing")) { - printf("%s\n", oid_to_hex(oid)); - return 0; - } - return fsck_error_function(o, oid, object_type, msg_type, msg_id, message); -} - int cmd_index_pack(int argc, const char **argv, const char *prefix) { int i, fix_thin_pack = 0, verify = 0, stat_only = 0, rev_index; @@ -1761,7 +1743,6 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) read_replace_refs = 0; fsck_options.walk = mark_link; - fsck_options.error_func = print_dangling_gitmodules; reset_pack_idx_option(&opts); git_config(git_index_pack_config, &opts); diff --git a/fetch-pack.c b/fetch-pack.c index 229fd8e2c2..008a3facd4 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -38,7 +38,7 @@ static int server_supports_filtering; static int advertise_sid; static struct shallow_lock shallow_lock; static const char *alternate_shallow_file; -static struct fsck_options fsck_options = FSCK_OPTIONS_STRICT; +static struct fsck_options fsck_options = FSCK_OPTIONS_MISSING_GITMODULES; static struct strbuf fsck_msg_types = STRBUF_INIT; static struct string_list uri_protocols = STRING_LIST_INIT_DUP; @@ -998,7 +998,7 @@ static void fsck_gitmodules_oids(struct oidset *gitmodules_oids) oidset_iter_init(gitmodules_oids, &iter); while ((oid = oidset_iter_next(&iter))) - register_found_gitmodules(&fsck_options, oid); + oidset_insert(&fsck_options.gitmodules_found, oid); if (fsck_finish(&fsck_options)) die("fsck failed"); } diff --git a/fsck-cb.c b/fsck-cb.c new file mode 100644 index 0000000000..465a49235a --- /dev/null +++ b/fsck-cb.c @@ -0,0 +1,16 @@ +#include "git-compat-util.h" +#include "fsck.h" + +int fsck_error_cb_print_missing_gitmodules(struct fsck_options *o, + const struct object_id *oid, + enum object_type object_type, + enum fsck_msg_type msg_type, + enum fsck_msg_id msg_id, + const char *message) +{ + if (msg_id == FSCK_MSG_GITMODULES_MISSING) { + puts(oid_to_hex(oid)); + return 0; + } + return fsck_error_function(o, oid, object_type, msg_type, msg_id, message); +} diff --git a/fsck.c b/fsck.c index 565274a946..b0089844db 100644 --- a/fsck.c +++ b/fsck.c @@ -1214,11 +1214,6 @@ int fsck_error_function(struct fsck_options *o, return 1; } -void register_found_gitmodules(struct fsck_options *options, const struct object_id *oid) -{ - oidset_insert(&options->gitmodules_found, oid); -} - int fsck_finish(struct fsck_options *options) { int ret = 0; diff --git a/fsck.h b/fsck.h index bb59ef05b6..ae3107638a 100644 --- a/fsck.h +++ b/fsck.h @@ -153,9 +153,6 @@ int fsck_walk(struct object *obj, void *data, struct fsck_options *options); int fsck_object(struct object *obj, void *data, unsigned long size, struct fsck_options *options); -void register_found_gitmodules(struct fsck_options *options, - const struct object_id *oid); - /* * fsck a tag, and pass info about it back to the caller. This is * exposed fsck_object() internals for git-mktag(1). @@ -204,4 +201,23 @@ const char *fsck_describe_object(struct fsck_options *options, int fsck_config_internal(const char *var, const char *value, void *cb, struct fsck_options *options); +/* + * Initializations for callbacks in fsck-cb.c + */ +#define FSCK_OPTIONS_MISSING_GITMODULES { \ + .strict = 1, \ + .error_func = fsck_error_cb_print_missing_gitmodules, \ + FSCK_OPTIONS_COMMON \ +} + +/* + * Error callbacks in fsck-cb.c + */ +int fsck_error_cb_print_missing_gitmodules(struct fsck_options *o, + const struct object_id *oid, + enum object_type object_type, + enum fsck_msg_type msg_type, + enum fsck_msg_id msg_id, + const char *message); + #endif