From patchwork Fri Feb 10 17:13:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinayak Dev X-Patchwork-Id: 13136042 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DD11C05027 for ; Fri, 10 Feb 2023 17:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232676AbjBJROO (ORCPT ); Fri, 10 Feb 2023 12:14:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232576AbjBJRON (ORCPT ); Fri, 10 Feb 2023 12:14:13 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8DF638B6A for ; Fri, 10 Feb 2023 09:14:04 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id d13-20020a17090ad3cd00b0023127b2d602so6127976pjw.2 for ; Fri, 10 Feb 2023 09:14:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JUyMIHkZcQu3YYhZnObLcpbhO0J6Djjhf5TU70n8uVU=; b=aCxSZ+g2OPEgIAn1vjO37G9fklF/MIXfpPRL8HGQYpkfTeWxdc2wLWe4rXHTWsNYfF ETgzFc+qBMEJqa5Oe9xu3Pn6+6DBHm/j8s5r+wiPK9OGdUxuezfMusfoV0Wi2EhOQIWL 59wotzHXita0ahkEDrk0pn+dAvPejdGn+/TzWrhlWnWWxCxF0z188bAom+zsn9KhvLem UM/rESTZqSdTcama5VV6hX/Bni6/FlVUTf5EY0bkyxHBmkfatEutHH9Wkc8hCxfavh1G 579+KvDbQzhApxOrIrnTrtBnny3mQYjld1Vk8rZHlADhuAKkGWk3MzU7lHKVKE6HKwv4 3FKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JUyMIHkZcQu3YYhZnObLcpbhO0J6Djjhf5TU70n8uVU=; b=XesmVnxY5kU9nV+b32RygfRGooIoLwWrNimxah/9SYFbUBJYvfKP3RPm1X3Czyojm/ 1StFSkhewjEUGRxCAMo+76eFv+BkvAl8EVRhiTQ9kNs0itqMsC7sAzHqM+9UmSS4h6BU zxBp78APZVa65Nyos7l6Xzkj4quwx50KtlXHNNyiKbXD4obYanSpjwQxAE1Ubq/5HYTN /FhBpL2QLqwg5n6Z1wZL67lc9sbF+luZwGIYfUtoXj1D2b1B1Fd2JUzaDG7dNNbUrzAg dZOHckE9uiUHdsFs0mHs6ToPvRwNmbLXXa35U/kYGLPk4zkXTIDXjYrkNshSLYB5nRTd Jz9w== X-Gm-Message-State: AO0yUKVXlUdKvrvTauQWjD40jf8ZtlwzoWL9iopAl50/3V3Gexjg0P7P dGBUVFxPliQO0cyPHGrRLfw= X-Google-Smtp-Source: AK7set8H/Wd1rPAVKYPDTNgqUbuvVBsB8bi5qg7oDsTOp0iTcvtWVFgVrw8nfts50SRK+MfNVOrPkA== X-Received: by 2002:a17:902:c94e:b0:19a:7217:32be with SMTP id i14-20020a170902c94e00b0019a721732bemr3249931pla.1.1676049244050; Fri, 10 Feb 2023 09:14:04 -0800 (PST) Received: from localhost.localdomain ([2405:201:6805:20dd:94a9:fa14:fe37:b9ef]) by smtp.gmail.com with ESMTPSA id l10-20020a170902eb0a00b001928c204428sm3622401plb.142.2023.02.10.09.13.58 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 Feb 2023 09:14:03 -0800 (PST) From: Vinayak Dev To: sunshine@sunshineco.com Cc: git@vger.kernel.org, vinayakdsci Subject: [PATCH v2 1/3] {apply,alias}: convert pre-processor macros to enums Date: Fri, 10 Feb 2023 22:43:36 +0530 Message-Id: <20230210171338.81906-2-vinayakdev.sci@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210171338.81906-1-vinayakdev.sci@gmail.com> References: <20230210171338.81906-1-vinayakdev.sci@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: vinayakdsci Changes made to alias.c and apply.c in v1, requiring refactoring. Signed-off-by: Vinayak Dev --- alias.c | 12 +++++++++--- apply.c | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/alias.c b/alias.c index 00abde0817..61ef2c0c54 100644 --- a/alias.c +++ b/alias.c @@ -44,9 +44,15 @@ void list_aliases(struct string_list *list) read_early_config(config_alias_cb, &data); } -#define SPLIT_CMDLINE_BAD_ENDING 1 -#define SPLIT_CMDLINE_UNCLOSED_QUOTE 2 -#define SPLIT_CMDLINE_ARGC_OVERFLOW 3 +/* #define SPLIT_CMDLINE_BAD_ENDING 1 */ +/* #define SPLIT_CMDLINE_UNCLOSED_QUOTE 2 */ +/* #define SPLIT_CMDLINE_ARGC_OVERFLOW 3 */ +enum split_cmdline_error { + SPLIT_CMDLINE_BAD_ENDING = 1, + SPLIT_CMDLINE_UNCLOSED_QUOTE, + SPLIT_CMDLINE_ARGC_OVERFLOW +}; + static const char *split_cmdline_errors[] = { N_("cmdline ends with \\"), N_("unclosed quote"), diff --git a/apply.c b/apply.c index 5eec433583..1e9cf2f4f2 100644 --- a/apply.c +++ b/apply.c @@ -205,8 +205,13 @@ struct fragment { * or deflated "literal". */ #define binary_patch_method leading -#define BINARY_DELTA_DEFLATED 1 -#define BINARY_LITERAL_DEFLATED 2 +/* #define BINARY_DELTA_DEFLATED 1 */ +/* #define BINARY_LITERAL_DEFLATED 2 */ + +enum binary_type_deflated { + BINARY_DELTA_DEFLATED = 1, + BINARY_LITERAL_DEFLATED +}; static void free_fragment_list(struct fragment *list) { @@ -918,8 +923,14 @@ static int gitdiff_hdrend(struct gitdiff_data *state UNUSED, * their names against any previous information, just * to make sure.. */ -#define DIFF_OLD_NAME 0 -#define DIFF_NEW_NAME 1 + +/* #define DIFF_OLD_NAME 0 */ +/* #define DIFF_NEW_NAME 1 */ + +enum diff_name { + DIFF_OLD_NAME = 0, + DIFF_NEW_NAME +}; static int gitdiff_verify_name(struct gitdiff_data *state, const char *line, From patchwork Fri Feb 10 17:13:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinayak Dev X-Patchwork-Id: 13136043 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E404DC05027 for ; Fri, 10 Feb 2023 17:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233083AbjBJROZ (ORCPT ); Fri, 10 Feb 2023 12:14:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232696AbjBJROT (ORCPT ); Fri, 10 Feb 2023 12:14:19 -0500 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E2A78D59 for ; Fri, 10 Feb 2023 09:14:09 -0800 (PST) Received: by mail-pl1-x633.google.com with SMTP id b5so7136435plz.5 for ; Fri, 10 Feb 2023 09:14:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tA7KmM/UI/tV2TITQXVgFrhnvQ7IHMFvovtitN0A32Q=; b=g0aZe63FVZuW5cQWu57bPKDLJlCnAP0Hs3g7WvgHcYWz1lEmXRkUy4m12lTxSpw7Tc AU21oqrpmIOXSrdn6rICCBtVj5P2awDPI9YgyKMfdtLmo4zbZXw4COBLx576glH50rOD XZqLIJKG/lXxN+9Dacn6IHzureCIas+wFGM1juAkRe4OxxVATOeTHhjhxQfeEFRWfIzJ 2uOMTIVrmjcWoTe1hs0mqImZmgy/gIyU27ukuTy3cL7tRL4Zbr0bLxNph84butVZvxv2 3KLL0eI5+wE8BxZNbEXYlYTC5jqmTdr/omyyufFAaseI6DGfJVxC22LSp58PtbNZEZ9F jnzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tA7KmM/UI/tV2TITQXVgFrhnvQ7IHMFvovtitN0A32Q=; b=iXCXF4nOJdUl76CS4rIXE4OTQNJfc8qi1E1+hjaHbRfpRkFS4wvd3CN8s/NjRjyBnQ ywqcKS+UmcAhgs59ftc7rU2lI7pQhRX0sVLILjJ1AZ14HRyYJpc3tjekwzeG/2hyVprL +mlUpM5fieDbIXB0Xy59tJV+VnsfwqNt0ai9VeZ/zaB8Lvj94iE8M7U6fpBIcdOTEieT u+DMoiiRuxAf7zEmBfKBU3WfByu4MzrD0Rr8y71kiXqUjyBDyK3WvBW4ToQ8uBnxYpHv cdVI/h9iMlmYd9PN+za6KUluSLqQpAJZV53y1uAP2jz+MapqPCAaLD6HmonCIi3yuX6o 6a6w== X-Gm-Message-State: AO0yUKU7CV8q2eNpfMQjJNm1coAquHpTEp11gjAptInddznPRBTotQf4 10JolKAs1pjhlQxr8zvy0OY= X-Google-Smtp-Source: AK7set/mvIg7SP+jUTTtss4h28lC+Sf/Ka8YZV4lsckYjMmdFEQPmOOg3MilyAsw9rsg9RVUXyzBEw== X-Received: by 2002:a17:90a:7809:b0:233:bfa0:11d2 with SMTP id w9-20020a17090a780900b00233bfa011d2mr230745pjk.47.1676049249247; Fri, 10 Feb 2023 09:14:09 -0800 (PST) Received: from localhost.localdomain ([2405:201:6805:20dd:94a9:fa14:fe37:b9ef]) by smtp.gmail.com with ESMTPSA id l10-20020a170902eb0a00b001928c204428sm3622401plb.142.2023.02.10.09.14.05 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 Feb 2023 09:14:08 -0800 (PST) From: Vinayak Dev To: sunshine@sunshineco.com Cc: git@vger.kernel.org, Vinayak Dev Subject: [PATCH v2 2/3] {apply,alias}: convert pre-processor macros to enums Date: Fri, 10 Feb 2023 22:43:37 +0530 Message-Id: <20230210171338.81906-3-vinayakdev.sci@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210171338.81906-1-vinayakdev.sci@gmail.com> References: <20230210171338.81906-1-vinayakdev.sci@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Revert the changes made to alias.c in v1. Signed-off-by: Vinayak Dev --- alias.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/alias.c b/alias.c index 61ef2c0c54..deb871d59c 100644 --- a/alias.c +++ b/alias.c @@ -44,14 +44,9 @@ void list_aliases(struct string_list *list) read_early_config(config_alias_cb, &data); } -/* #define SPLIT_CMDLINE_BAD_ENDING 1 */ -/* #define SPLIT_CMDLINE_UNCLOSED_QUOTE 2 */ -/* #define SPLIT_CMDLINE_ARGC_OVERFLOW 3 */ -enum split_cmdline_error { - SPLIT_CMDLINE_BAD_ENDING = 1, - SPLIT_CMDLINE_UNCLOSED_QUOTE, - SPLIT_CMDLINE_ARGC_OVERFLOW -}; +#define SPLIT_CMDLINE_BAD_ENDING 1 +#define SPLIT_CMDLINE_UNCLOSED_QUOTE 2 +#define SPLIT_CMDLINE_ARGC_OVERFLOW 3 static const char *split_cmdline_errors[] = { N_("cmdline ends with \\"), From patchwork Fri Feb 10 17:13:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vinayak Dev X-Patchwork-Id: 13136044 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E2B5C05027 for ; Fri, 10 Feb 2023 17:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232821AbjBJROf (ORCPT ); Fri, 10 Feb 2023 12:14:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233060AbjBJROW (ORCPT ); Fri, 10 Feb 2023 12:14:22 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 122312E826 for ; Fri, 10 Feb 2023 09:14:19 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id bx22so5814770pjb.3 for ; Fri, 10 Feb 2023 09:14:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HktniWCcMzicNhMdR1SQk51bMxLx0kzQh49b+IAXh5A=; b=fM4LMd+6P1jjVX3ahoPjKGqyu+RKet77c8ihCwOXEbe+81q2fKwATnq10L48+hJtHw bo5r/ag0vy6TvK7SThtzT50CLIOVbgiOgQdAh7g/zzeRBoGq1Ayh0CQIVeQZuEu3yctb chyRmaFYHAigIhcUzzaJmBkitUmmvcRokmTv6INvPOM77dbtb6oanFKFtZW9Jb1GmvLb r1qyvhm9KPM8f4zf4syEIAvDHsHpILALDSCmuSRHkqLUJKo7zusEUXN+Qji6gUQ8JMjH Ofuc/d3q0boT4DBiCoXUQa/QYe5rNfMSrEozvasZIJzahS2kXEJHkl2BAi4B0Xa0tWa6 RzLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HktniWCcMzicNhMdR1SQk51bMxLx0kzQh49b+IAXh5A=; b=vua4+iMFkjYwXxlf8elENJYnLz1ILDAbOJUV7wMkqJuQ/uB6p6U1jSnL+gpbxLInK2 yQRABUehaY6LEXeRku3f8anxDUK5bPrfnAEUmu1Q0PfnP/knyyLxXp9JCTzD5IvPoFY8 xepliKAP/U++isif+9Z3Sy1ojczXKEW0+MeX09+fKM0NN0+iowtoCPOPYxP/1Ev23+cV AJNzABjvIYEfq7FYX3z+D1EtZInar1IsUVyQIDL6eC8P8L2pIPkn8BffJDZH76nTiprO kf+2H40d0lUuKbp9ocAp7igiO3y+97eoJXk/zI0EDcmh838Dexca/gVEb5/UhXLMUv8/ T+7w== X-Gm-Message-State: AO0yUKXKsrjdoFN+an8fgwDiQN+WhraG0H8/Du7Q5uiwrnsZ4Yi/ar07 mhfqUIb3oXQvneFcjSI2BWizj7OowX3vqQ== X-Google-Smtp-Source: AK7set8oqlARLkpDSl34SdmMIBN/TV3O/moc5QuKQ2r4Br4GCjJlTSuddVpoL2aP5byO+nCQvsexXQ== X-Received: by 2002:a17:902:c949:b0:196:5787:d73a with SMTP id i9-20020a170902c94900b001965787d73amr18836971pla.53.1676049258493; Fri, 10 Feb 2023 09:14:18 -0800 (PST) Received: from localhost.localdomain ([2405:201:6805:20dd:94a9:fa14:fe37:b9ef]) by smtp.gmail.com with ESMTPSA id l10-20020a170902eb0a00b001928c204428sm3622401plb.142.2023.02.10.09.14.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 10 Feb 2023 09:14:17 -0800 (PST) From: Vinayak Dev To: sunshine@sunshineco.com Cc: git@vger.kernel.org, Vinayak Dev Subject: [PATCH v2 3/3] {apply,alias}: convert pre-processor macros to enums Date: Fri, 10 Feb 2023 22:43:38 +0530 Message-Id: <20230210171338.81906-4-vinayakdev.sci@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230210171338.81906-1-vinayakdev.sci@gmail.com> References: <20230210171338.81906-1-vinayakdev.sci@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Change variables int side and int patch_method to enum in apply.c. This allows for proper listing of enum constants during debugging. Signed-off-by: Vinayak Dev --- apply.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/apply.c b/apply.c index 1e9cf2f4f2..8612bd44c8 100644 --- a/apply.c +++ b/apply.c @@ -205,9 +205,6 @@ struct fragment { * or deflated "literal". */ #define binary_patch_method leading -/* #define BINARY_DELTA_DEFLATED 1 */ -/* #define BINARY_LITERAL_DEFLATED 2 */ - enum binary_type_deflated { BINARY_DELTA_DEFLATED = 1, BINARY_LITERAL_DEFLATED @@ -924,9 +921,6 @@ static int gitdiff_hdrend(struct gitdiff_data *state UNUSED, * to make sure.. */ -/* #define DIFF_OLD_NAME 0 */ -/* #define DIFF_NEW_NAME 1 */ - enum diff_name { DIFF_OLD_NAME = 0, DIFF_NEW_NAME @@ -936,7 +930,7 @@ static int gitdiff_verify_name(struct gitdiff_data *state, const char *line, int isnull, char **name, - int side) + enum diff_name side) { if (!*name && !isnull) { *name = find_name(state->root, line, NULL, state->p_value, TERM_TAB); @@ -1921,7 +1915,7 @@ static struct fragment *parse_binary_hunk(struct apply_state *state, int llen, used; unsigned long size = *sz_p; char *buffer = *buf_p; - int patch_method; + enum binary_type_deflated patch_method; unsigned long origlen; char *data = NULL; int hunk_size = 0;