{"thread":{"id":"58551","subject":"[PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","startedAt":"2022-10-03T21:30:40Z","lastAt":"2022-10-11T00:22:58Z","messageCount":9,"participants":["Aleajndro R Sedeño","brian m. carlson","Alejandro R. Sedeño","Jeff King","Ævar Arnfjörð Bjarmason"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"464097","messageId":"20221003212318.3092010-1-asedeno@google.com","threadId":"58551","inReplyTo":null,"subject":"[PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","fromName":"Aleajndro R Sedeño","fromEmail":"asedeno@google.com","sentAt":"2022-10-03T21:23:18Z","receivedAt":"2022-10-03T21:30:40Z","isPatch":true,"sender":{"key":"asedeno@google.com","avatar":"https://gravatar.com/avatar/5589bf0d288cb128a897149ca48feac7ae29cfa16b4d1452b37db5909405b6c6?d=mp&s=160"},"body":"From: Alejandro R. Sedeño <asedeno@mit.edu>\n\nSigned-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\nSigned-off-by: Alejandro R Sedeño <asedeno@google.com>\n---\n git-compat-util.h | 5 ++++-\n 1 file changed, 4 insertions(+), 1 deletion(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex b90b64718e..045b47f83a 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -189,9 +189,12 @@ struct strbuf;\n #define _NETBSD_SOURCE 1\n #define _SGI_SOURCE 1\n \n-#if defined(__GNUC__)\n+#if GIT_GNUC_PREREQ(4, 5)\n #define UNUSED __attribute__((unused)) \\\n \t__attribute__((deprecated (\"parameter declared as UNUSED\")))\n+#elif defined(__GNUC__)\n+#define UNUSED __attribute__((unused)) \\\n+\t__attribute__((deprecated))\n #else\n #define UNUSED\n #endif\n-- \n2.38.0.rc1.362.ged0d419d3c-goog\n\n"},{"id":"464102","messageId":"YzthTugwy+eaIUxr@tapette.crustytoothpaste.net","threadId":"58551","inReplyTo":"20221003212318.3092010-1-asedeno@google.com","subject":"Re: [PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2022-10-03T22:25:18Z","receivedAt":"2022-10-03T22:28:45Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2022-10-03 at 21:23:18, Aleajndro R Sedeño wrote:\n> From: Alejandro R. Sedeño <asedeno@mit.edu>\n> \n> Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n> Signed-off-by: Alejandro R Sedeño <asedeno@google.com>\n\nIt might be helpful to explain what system you're targeting when you see\nthis.  CentOS 7 has GCC 4.8, and I'm not aware of any systems with an\nolder compiler receiving publicly available updates still.  We've fairly\nrecently only been testing and targeting GCC 4.8 for that reason.\n-- \nbrian m. carlson (he/him or they/them)\nToronto, Ontario, CA\n"},{"id":"464105","messageId":"CAOO-Oz2WnodBnw86mi2GZ+jLGoGy_saX=kCpwPdm2xohDO1s_Q@mail.gmail.com","threadId":"58551","inReplyTo":"YzthTugwy+eaIUxr@tapette.crustytoothpaste.net","subject":"Re: [PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","fromName":"Alejandro R. Sedeño","fromEmail":"asedeno@mit.edu","sentAt":"2022-10-03T23:45:44Z","receivedAt":"2022-10-03T23:46:07Z","isPatch":true,"sender":{"key":"asedeno@mit.edu","avatar":"https://avatars.githubusercontent.com/u/28302?v=4"},"body":"I'm targeting an old SunOS 5.10 with a GCC 3.4.3, for reasons that can\nonly be described as self-loathing. :-)\nThe other users of GIT_GNUC_PREREQ are used for 2.8, and 3.1, so I\nfigure distinguishing between 4.5+ and <4.5 should be well supported.\n\nRegardless, there's no reason to break older compilers over something\nthat's this trivial to fix.\n\n-Alejandro\n\n\nOn Mon, Oct 3, 2022 at 6:26 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n>\n> On 2022-10-03 at 21:23:18, Aleajndro R Sedeño wrote:\n> > From: Alejandro R. Sedeño <asedeno@mit.edu>\n> >\n> > Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n> > Signed-off-by: Alejandro R Sedeño <asedeno@google.com>\n>\n> It might be helpful to explain what system you're targeting when you see\n> this.  CentOS 7 has GCC 4.8, and I'm not aware of any systems with an\n> older compiler receiving publicly available updates still.  We've fairly\n> recently only been testing and targeting GCC 4.8 for that reason.\n> --\n> brian m. carlson (he/him or they/them)\n> Toronto, Ontario, CA\n"},{"id":"464229","messageId":"Yz2afjRezq5oGN4g@coredump.intra.peff.net","threadId":"58551","inReplyTo":"CAOO-Oz2WnodBnw86mi2GZ+jLGoGy_saX=kCpwPdm2xohDO1s_Q@mail.gmail.com","subject":"Re: [PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-10-05T14:53:50Z","receivedAt":"2022-10-05T14:53:56Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 03, 2022 at 07:45:44PM -0400, Alejandro R. Sedeño wrote:\n\n> I'm targeting an old SunOS 5.10 with a GCC 3.4.3, for reasons that can\n> only be described as self-loathing. :-)\n> The other users of GIT_GNUC_PREREQ are used for 2.8, and 3.1, so I\n> figure distinguishing between 4.5+ and <4.5 should be well supported.\n> \n> Regardless, there's no reason to break older compilers over something\n> that's this trivial to fix.\n\nThis will cause some mild hardships, as later patches will need to\n#define UNUSED in other spots, as well, in order to get full coverage of\nthe code base (I have written those annotation patches, but they're not\napplied upstream yet).\n\nStill, I tend to agree with you that we should handle this case. It's\nnot too much work, and I should be able to work around the multiple\ndefinitions by pulling it out into an unused.h or similar.\n\n-Peff\n"},{"id":"464274","messageId":"221006.86lepts927.gmgdl@evledraar.gmail.com","threadId":"58551","inReplyTo":"Yz2afjRezq5oGN4g@coredump.intra.peff.net","subject":"Re: [PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-10-06T07:29:11Z","receivedAt":"2022-10-06T07:30:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Wed, Oct 05 2022, Jeff King wrote:\n\n> On Mon, Oct 03, 2022 at 07:45:44PM -0400, Alejandro R. Sedeño wrote:\n>\n>> I'm targeting an old SunOS 5.10 with a GCC 3.4.3, for reasons that can\n>> only be described as self-loathing. :-)\n>> The other users of GIT_GNUC_PREREQ are used for 2.8, and 3.1, so I\n>> figure distinguishing between 4.5+ and <4.5 should be well supported.\n>> \n>> Regardless, there's no reason to break older compilers over something\n>> that's this trivial to fix.\n>\n> This will cause some mild hardships, as later patches will need to\n> #define UNUSED in other spots, as well, in order to get full coverage of\n> the code base (I have written those annotation patches, but they're not\n> applied upstream yet).\n\nSorry about any trouble in having to rebase those on UNUSED.\n\nIf you're taking requests it would be really useful to prioritize\nchanges to shared headers and the like, e.g. DEVOPTS=extra-all on pretty\nmuch any file will start with:\n\t\n\tgit-compat-util.h: In function ‘precompose_argv_prefix’:\n\tgit-compat-util.h:313:54: error: unused parameter ‘argc’ [-Werror=unused-parameter]\n\t  313 | static inline const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix)\n\t      |                                                  ~~~~^~~~\n\tgit-compat-util.h:313:73: error: unused parameter ‘argv’ [-Werror=unused-parameter]\n\t  313 | static inline const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix)\n\t      |                                                            ~~~~~~~~~~~~~^~~~\n\tgit-compat-util.h: In function ‘git_has_dos_drive_prefix’:\n\tgit-compat-util.h:423:56: error: unused parameter ‘path’ [-Werror=unused-parameter]\n\t  423 | static inline int git_has_dos_drive_prefix(const char *path)\n\t      |                                            ~~~~~~~~~~~~^~~~\n\tgit-compat-util.h: In function ‘git_skip_dos_drive_prefix’:\n\tgit-compat-util.h:431:52: error: unused parameter ‘path’ [-Werror=unused-parameter]\n\t  431 | static inline int git_skip_dos_drive_prefix(char **path)\n"},{"id":"464277","messageId":"221006.86czb5s7lu.gmgdl@evledraar.gmail.com","threadId":"58551","inReplyTo":"YzthTugwy+eaIUxr@tapette.crustytoothpaste.net","subject":"Re: [PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-10-06T07:33:47Z","receivedAt":"2022-10-06T08:02:13Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, Oct 03 2022, brian m. carlson wrote:\n\n> [[PGP Signed Part:Undecided]]\n> On 2022-10-03 at 21:23:18, Aleajndro R Sedeño wrote:\n>> From: Alejandro R. Sedeño <asedeno@mit.edu>\n>> \n>> Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>\n>> Signed-off-by: Alejandro R Sedeño <asedeno@google.com>\n>\n> It might be helpful to explain what system you're targeting when you see\n> this.  CentOS 7 has GCC 4.8, and I'm not aware of any systems with an\n> older compiler receiving publicly available updates still.  We've fairly\n> recently only been testing and targeting GCC 4.8 for that reason.\n\nWe've had some friendly disagreements in the past about what our policy\nshould be for supporting such \"EOL\" software[1][2]. I'm not replying to\nrepeat any of that discussion, just noting it for context and that I'm\n*not* raising that point here :)\n\nWhat I do want to say to provide others context is that I think you're\nconflating your own views & project policy here, e.g. if you run:\n\n\tgit log --grep='gcc [0-9]' -i\n\nYou can see recent patches that have been accepted where we're adjusting\nthings for GCC's older than 4.8, so it's not the case that we're \"only\n[...] targeting GCC [versions >=]4.8\".\n\nI think you might be mixing up the oldest software we're taking patches\nfor with the oldest version we run in CI, although I didn't find if we\nactually run GCC 4.8 in CI anymore. It appears to have been used with\nubuntu-18.04, but as of ef465848312 (ci: update 'static-analysis' to\nUbuntu 22.04, 2022-08-23) I don't think we pin that version anywhere.\n\nAnyway, however us \"in the know\" work out what versions we support I\ndon't want someone to search the ML archive & come to the conclusion\nthat a patch for a compiler older than whetever IBM's bundling wouldn't\nbe welcome.\n\nI think it's fair to say that we've taken e.g. major IBM/RedHat releases\ninto account in the past, e.g. for what libcurl version(s) to support,\nper [2]. But we've never considered distro releases to be a hard cut-off\nfor support.\n\nThe actual \"policy\" has been some fuzzy combination of:\n\n * What OS's / distro's are used by anyone, for which e.g. RHEL releases\n   are a very useful heuristic, and on some platforms (e.g. Windows?)\n   vendor EOLs matter more than on others.\n\n * How much of a hassle older software or a platform is to support,\n   e.g. this project has usually happily taken trivial patches such as\n   this one, but in the case of PCRE we moved more aggressively from\n   PCRE v1 to v2, as supporting both required duplicate code (see\n   7599730b7e2 (Remove support for v1 of the PCRE library, 2021-01-24)).\n\n * That someone cares or sends in patches for. I know of various current\n   breakages with software that's \"supported\" (bits of Solaris, AIX and\n   HP/UX userland come to mind), but nobody's cared enough to fix it (in\n   those cases, many/all of the \"official packages\" simply use GNU\n   userland/libraries instead)\n\n1. https://lore.kernel.org/git/YPimBp+TkaJ9ycuM@camp.crustytoothpaste.net/\n2. https://lore.kernel.org/git/YPimBp+TkaJ9ycuM@camp.crustytoothpaste.net/\n"},{"id":"464283","messageId":"Yz7HGAThrOcPdmjm@coredump.intra.peff.net","threadId":"58551","inReplyTo":"221006.86lepts927.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-10-06T12:16:24Z","receivedAt":"2022-10-06T12:16:28Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 06, 2022 at 09:29:11AM +0200, Ævar Arnfjörð Bjarmason wrote:\n\n> > This will cause some mild hardships, as later patches will need to\n> > #define UNUSED in other spots, as well, in order to get full coverage of\n> > the code base (I have written those annotation patches, but they're not\n> > applied upstream yet).\n> \n> Sorry about any trouble in having to rebase those on UNUSED.\n\nThat part was not too bad, and is already done.\n\nThe trickiest part is that the headers get included in odd orders, and\nif the macros don't match, the compiler will complain (this has to do\nwith compat/ headers which don't necessarily start by including\ngit-compat-util.h).\n\nBut if the definition gets much more complicated, then it's probably\nworth pulling it out rather than repeating it.\n\n> If you're taking requests it would be really useful to prioritize\n> changes to shared headers and the like, e.g. DEVOPTS=extra-all on pretty\n> much any file will start with:\n> \t\n> \tgit-compat-util.h: In function ‘precompose_argv_prefix’:\n> \tgit-compat-util.h:313:54: error: unused parameter ‘argc’ [-Werror=unused-parameter]\n> \t  313 | static inline const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix)\n> \t      |                                                  ~~~~^~~~\n> \tgit-compat-util.h:313:73: error: unused parameter ‘argv’ [-Werror=unused-parameter]\n> \t  313 | static inline const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix)\n> \t      |                                                            ~~~~~~~~~~~~~^~~~\n> \tgit-compat-util.h: In function ‘git_has_dos_drive_prefix’:\n> \tgit-compat-util.h:423:56: error: unused parameter ‘path’ [-Werror=unused-parameter]\n> \t  423 | static inline int git_has_dos_drive_prefix(const char *path)\n> \t      |                                            ~~~~~~~~~~~~^~~~\n> \tgit-compat-util.h: In function ‘git_skip_dos_drive_prefix’:\n> \tgit-compat-util.h:431:52: error: unused parameter ‘path’ [-Werror=unused-parameter]\n> \t  431 | static inline int git_skip_dos_drive_prefix(char **path)\n\nYeah, those are near the top of my list. I have a group classified as\n\"trivial\": functions which are compat placeholders and have no body.\nI'll be mostly offline for about a week, but I hope to send another\nround of unused-mark patches when I get back. (Of course it is not\nreally useful until _all_ of the patches are there anyway).\n\n-Peff\n"},{"id":"464333","messageId":"221006.86edvkr6cc.gmgdl@evledraar.gmail.com","threadId":"58551","inReplyTo":"Yz7HGAThrOcPdmjm@coredump.intra.peff.net","subject":"Re: [PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-10-06T21:15:16Z","receivedAt":"2022-10-06T21:27:31Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Oct 06 2022, Jeff King wrote:\n\n> On Thu, Oct 06, 2022 at 09:29:11AM +0200, Ævar Arnfjörð Bjarmason wrote:\n>\n>> > This will cause some mild hardships, as later patches will need to\n>> > #define UNUSED in other spots, as well, in order to get full coverage of\n>> > the code base (I have written those annotation patches, but they're not\n>> > applied upstream yet).\n>> \n>> Sorry about any trouble in having to rebase those on UNUSED.\n>\n> That part was not too bad, and is already done.\n>\n> The trickiest part is that the headers get included in odd orders, and\n> if the macros don't match, the compiler will complain (this has to do\n> with compat/ headers which don't necessarily start by including\n> git-compat-util.h).\n>\n> But if the definition gets much more complicated, then it's probably\n> worth pulling it out rather than repeating it.\n\nYeah, I've dealt with that pain before in other contexts. It would be\ngreat to have a git-compiler-compat.h with just the various\n__attribute__ stuff split off from git-compat-util.h.\n\nMaybe (compiles, but otherwise untested):\n\n git-compat-util.h   | 52 +-------------------------------------------------\n git-compiler-util.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 56 insertions(+), 51 deletions(-)\n\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex b90b64718eb..bfa44921c03 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -1,18 +1,6 @@\n #ifndef GIT_COMPAT_UTIL_H\n #define GIT_COMPAT_UTIL_H\n-\n-#if __STDC_VERSION__ - 0 < 199901L\n-/*\n- * Git is in a testing period for mandatory C99 support in the compiler.  If\n- * your compiler is reasonably recent, you can try to enable C99 support (or,\n- * for MSVC, C11 support).  If you encounter a problem and can't enable C99\n- * support with your compiler (such as with \"-std=gnu99\") and don't have access\n- * to one with this support, such as GCC or Clang, you can remove this #if\n- * directive, but please report the details of your system to\n- * git@vger.kernel.org.\n- */\n-#error \"Required C99 support is in a test phase.  Please see git-compat-util.h for more details.\"\n-#endif\n+#include \"git-compiler-util.h\"\n \n #ifdef USE_MSVC_CRTDBG\n /*\n@@ -189,13 +177,6 @@ struct strbuf;\n #define _NETBSD_SOURCE 1\n #define _SGI_SOURCE 1\n \n-#if defined(__GNUC__)\n-#define UNUSED __attribute__((unused)) \\\n-\t__attribute__((deprecated (\"parameter declared as UNUSED\")))\n-#else\n-#define UNUSED\n-#endif\n-\n #if defined(WIN32) && !defined(__CYGWIN__) /* Both MinGW and MSVC */\n # if !defined(_WIN32_WINNT)\n #  define _WIN32_WINNT 0x0600\n@@ -557,37 +538,6 @@ static inline int git_has_dir_sep(const char *path)\n #endif\n #endif\n \n-#if defined(__HP_cc) && (__HP_cc >= 61000)\n-#define NORETURN __attribute__((noreturn))\n-#define NORETURN_PTR\n-#elif defined(__GNUC__) && !defined(NO_NORETURN)\n-#define NORETURN __attribute__((__noreturn__))\n-#define NORETURN_PTR __attribute__((__noreturn__))\n-#elif defined(_MSC_VER)\n-#define NORETURN __declspec(noreturn)\n-#define NORETURN_PTR\n-#else\n-#define NORETURN\n-#define NORETURN_PTR\n-#ifndef __GNUC__\n-#ifndef __attribute__\n-#define __attribute__(x)\n-#endif\n-#endif\n-#endif\n-\n-/* The sentinel attribute is valid from gcc version 4.0 */\n-#if defined(__GNUC__) && (__GNUC__ >= 4)\n-#define LAST_ARG_MUST_BE_NULL __attribute__((sentinel))\n-/* warn_unused_result exists as of gcc 3.4.0, but be lazy and check 4.0 */\n-#define RESULT_MUST_BE_USED __attribute__ ((warn_unused_result))\n-#else\n-#define LAST_ARG_MUST_BE_NULL\n-#define RESULT_MUST_BE_USED\n-#endif\n-\n-#define MAYBE_UNUSED __attribute__((__unused__))\n-\n #include \"compat/bswap.h\"\n \n #include \"wildmatch.h\"\ndiff --git a/git-compiler-util.h b/git-compiler-util.h\nnew file mode 100644\nindex 00000000000..25fa0bc65d7\n--- /dev/null\n+++ b/git-compiler-util.h\n@@ -0,0 +1,55 @@\n+#ifndef GIT_COMPILER_UTIL_H\n+#define GIT_COMPILER_UTIL_H\n+\n+#if __STDC_VERSION__ - 0 < 199901L\n+/*\n+ * Git is in a testing period for mandatory C99 support in the compiler.  If\n+ * your compiler is reasonably recent, you can try to enable C99 support (or,\n+ * for MSVC, C11 support).  If you encounter a problem and can't enable C99\n+ * support with your compiler (such as with \"-std=gnu99\") and don't have access\n+ * to one with this support, such as GCC or Clang, you can remove this #if\n+ * directive, but please report the details of your system to\n+ * git@vger.kernel.org.\n+ */\n+#error \"Required C99 support is in a test phase.  Please see git-compiler-util.h for more details.\"\n+#endif\n+\n+#if defined(__GNUC__)\n+#define UNUSED __attribute__((unused)) \\\n+\t__attribute__((deprecated (\"parameter declared as UNUSED\")))\n+#else\n+#define UNUSED\n+#endif\n+\n+#endif\n+\n+#if defined(__HP_cc) && (__HP_cc >= 61000)\n+#define NORETURN __attribute__((noreturn))\n+#define NORETURN_PTR\n+#elif defined(__GNUC__) && !defined(NO_NORETURN)\n+#define NORETURN __attribute__((__noreturn__))\n+#define NORETURN_PTR __attribute__((__noreturn__))\n+#elif defined(_MSC_VER)\n+#define NORETURN __declspec(noreturn)\n+#define NORETURN_PTR\n+#else\n+#define NORETURN\n+#define NORETURN_PTR\n+#ifndef __GNUC__\n+#ifndef __attribute__\n+#define __attribute__(x)\n+#endif\n+#endif\n+#endif\n+\n+/* The sentinel attribute is valid from gcc version 4.0 */\n+#if defined(__GNUC__) && (__GNUC__ >= 4)\n+#define LAST_ARG_MUST_BE_NULL __attribute__((sentinel))\n+/* warn_unused_result exists as of gcc 3.4.0, but be lazy and check 4.0 */\n+#define RESULT_MUST_BE_USED __attribute__ ((warn_unused_result))\n+#else\n+#define LAST_ARG_MUST_BE_NULL\n+#define RESULT_MUST_BE_USED\n+#endif\n+\n+#define MAYBE_UNUSED __attribute__((__unused__))\n\n>> If you're taking requests it would be really useful to prioritize\n>> changes to shared headers and the like, e.g. DEVOPTS=extra-all on pretty\n>> much any file will start with:\n>> \t\n>> \tgit-compat-util.h: In function ‘precompose_argv_prefix’:\n>> \tgit-compat-util.h:313:54: error: unused parameter ‘argc’ [-Werror=unused-parameter]\n>> \t  313 | static inline const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix)\n>> \t      |                                                  ~~~~^~~~\n>> \tgit-compat-util.h:313:73: error: unused parameter ‘argv’ [-Werror=unused-parameter]\n>> \t  313 | static inline const char *precompose_argv_prefix(int argc, const char **argv, const char *prefix)\n>> \t      |                                                            ~~~~~~~~~~~~~^~~~\n>> \tgit-compat-util.h: In function ‘git_has_dos_drive_prefix’:\n>> \tgit-compat-util.h:423:56: error: unused parameter ‘path’ [-Werror=unused-parameter]\n>> \t  423 | static inline int git_has_dos_drive_prefix(const char *path)\n>> \t      |                                            ~~~~~~~~~~~~^~~~\n>> \tgit-compat-util.h: In function ‘git_skip_dos_drive_prefix’:\n>> \tgit-compat-util.h:431:52: error: unused parameter ‘path’ [-Werror=unused-parameter]\n>> \t  431 | static inline int git_skip_dos_drive_prefix(char **path)\n>\n> Yeah, those are near the top of my list. I have a group classified as\n> \"trivial\": functions which are compat placeholders and have no body.\n> I'll be mostly offline for about a week, but I hope to send another\n> round of unused-mark patches when I get back. (Of course it is not\n> really useful until _all_ of the patches are there anyway).\n\nI was ad-hoc testing this earlier and just dug this back out of my\nstash, maybe going in something like this direction is useful:\n\t\n\tdiff --git a/config.mak.dev b/config.mak.dev\n\tindex 4fa19d361b7..60bc8c406cf 100644\n\t--- a/config.mak.dev\n\t+++ b/config.mak.dev\n\t@@ -54,6 +54,47 @@ DEVELOPER_CFLAGS += -Wno-empty-body\n\t DEVELOPER_CFLAGS += -Wno-missing-field-initializers\n\t DEVELOPER_CFLAGS += -Wno-sign-compare\n\t DEVELOPER_CFLAGS += -Wno-unused-parameter\n\t+\n\t+define use-unused-parameter\n\t+$(1): DEVELOPER_CFLAGS += -Wunused-parameter\n\t+\n\t+endef\n\t+\n\t+TEST_BUILTINS_NO_UNUSED =\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-ctype.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-date.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-drop-caches.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-dump-cache-tree.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-dump-fsmonitor.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-dump-split-index.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-dump-untracked-cache.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-example-decorate.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-fsmonitor-client.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-index-version.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-match-trees.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-mergesort.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-oid-array.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-oidmap.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-oidtree.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-oidtree.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-online-cpus.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-parse-options.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-path-utils.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-prio-queue.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-read-graph.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-ref-store.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-run-command.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-scrap-cache-tree.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-sigchain.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-simple-ipc.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-strcmp-offset.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-submodule-config.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-trace2.o\n\t+TEST_BUILTINS_OBJS_NO_UNUSED += test-xml-encode.o\n\t+\n\t+TEST_BUILTINS_OBJS_CHECK_UNUSED = $(filter-out $(TEST_BUILTINS_OBJS_NO_UNUSED),$(TEST_BUILTINS_OBJS))\n\t+\n\t+$(eval $(foreach obj,$(TEST_BUILTINS_OBJS_CHECK_UNUSED:%=t/helper/%), $(call use-unused-parameter,$(obj))))\n\t endif\n\t endif\n\t \nIt's probably too painful to maintain that on a per-file basis, but if\nyou can get to a point where e.g. t/helper/ is -Wunused-parameter clean\nwe can just append -Wunused-parameter to DEVELOPER_CFLAGS for those\npaths.\n\nThat'll ensure that we don't have \"regressions\" in newly added\nparameters for files we've already cleared.\n\nMaybe not worth it, I don't know if we'd be re-adding these at a\nsufficient rate to make it worth it, probably you'll send all these in\nand we'll find there's maybe 1-5 easily tackled regressions before we\nremove that \"DEVELOPER_CFLAGS += -Wno-unused-parameter\" line.\n"},{"id":"464553","messageId":"Y0S3XDToBqnMr4/m@coredump.intra.peff.net","threadId":"58551","inReplyTo":"221006.86edvkr6cc.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH] git-compat-util.h: GCC deprecated only takes a message in GCC 4.5+","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-10-11T00:22:52Z","receivedAt":"2022-10-11T00:22:58Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Oct 06, 2022 at 11:15:16PM +0200, Ævar Arnfjörð Bjarmason wrote:\n\n> > But if the definition gets much more complicated, then it's probably\n> > worth pulling it out rather than repeating it.\n> \n> Yeah, I've dealt with that pain before in other contexts. It would be\n> great to have a git-compiler-compat.h with just the various\n> __attribute__ stuff split off from git-compat-util.h.\n\nI was going to just have unused.h, since I'd worry that piling too much\nstuff into it will eventually hit a place where some compat/ code is\nunhappy. But I'd also be OK to _start_ with the UNUSED definition, but\ncall it git-compiler-compat or something, and then people can migrate\nthings as they choose to test them.\n\n> \t+TEST_BUILTINS_OBJS_NO_UNUSED += test-ctype.o\n\nI'd rather not go that route. I already have an UNUSED-clean code base,\nand once that is all merged we shouldn't need any of that complexity. In\nthe meantime, yes, people introduce new cases, but I am fixing those as\nthey do (and have been for a few years now).\n\n-Peff\n"}]}