{"thread":{"id":"35558","subject":"[PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings","startedAt":"2013-12-20T15:45:01Z","lastAt":"2013-12-21T20:09:22Z","messageCount":3,"participants":["Samuel Bronson","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"232286","messageId":"1387554301-23901-1-git-send-email-naesten@gmail.com","threadId":"35558","inReplyTo":null,"subject":"[PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings","fromName":"Samuel Bronson","fromEmail":"naesten@gmail.com","sentAt":"2013-12-20T15:45:01Z","receivedAt":"2013-12-20T15:45:01Z","isPatch":true,"sender":{"key":"naesten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13903?v=4"},"body":"These warnings don't really seem to make much sense for this file.\n\nSigned-off-by: Samuel Bronson <naesten@gmail.com>\n---\n wt-status.c | 5 +++++\n 1 file changed, 5 insertions(+)\n\ndiff --git a/wt-status.c b/wt-status.c\nindex 4e55810..542cc65 100644\n--- a/wt-status.c\n+++ b/wt-status.c\n@@ -17,6 +17,11 @@\n #include \"strbuf.h\"\n #include \"utf8.h\"\n \n+/* We have good reasons for using zero-length format strings, and\n+ * there's unfortunately no way to turn this off on a per-function\n+ * basis ... */\n+#pragma GCC diagnostic ignored \"-Wformat-zero-length\"\n+\n static char cut_line[] =\n \"------------------------ >8 ------------------------\\n\";\n \n-- \n1.8.4.3\n"},{"id":"232299","messageId":"20131221094202.GA32622@sigill.intra.peff.net","threadId":"35558","inReplyTo":"1387554301-23901-1-git-send-email-naesten@gmail.com","subject":"Re: [PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2013-12-21T09:42:02Z","receivedAt":"2013-12-21T09:42:02Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Dec 20, 2013 at 10:45:01AM -0500, Samuel Bronson wrote:\n\n> These warnings don't really seem to make much sense for this file.\n\nAgreed, though the advice so far has been to put -Wno-format-zero-length\nin your CFLAGS.\n\n> +/* We have good reasons for using zero-length format strings, and\n> + * there's unfortunately no way to turn this off on a per-function\n> + * basis ... */\n> +#pragma GCC diagnostic ignored \"-Wformat-zero-length\"\n\nAre other compilers happy to ignore this pragma? I guess we could wrap\nit in an #ifdef, if so.\n\nIt's also really not about this file in particular. The whole concept of\nformat-zero-length is questionable, as it ignores the concept that a\nformat function might actually do something useful with an empty format\n(e.g., by adding boilerplate, or having a side-effect). It's just that\nthis file is the only one that happens to do so.\n\nAnnotating the _function_ to say \"it's useful to pass an empty format\ninto this function\" would make sense, but as you note, there is no way\nto do that.\n\nSo I dunno. This seems like it does not quite specify what we want to\nsay as well as just \"-Wno-format-zero-length\", but it is more convenient\nin practice (because we take care of it in the source code, rather than\nrelying on the user's build settings).\n\n-Peff\n"},{"id":"232338","messageId":"CAJYzjmc2Mvr=d9CtR_KCPF3Msy6vJWVO7_pE7FGNL5p=2Bn6cA@mail.gmail.com","threadId":"35558","inReplyTo":"20131221094202.GA32622@sigill.intra.peff.net","subject":"Re: [PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings","fromName":"Samuel Bronson","fromEmail":"naesten@gmail.com","sentAt":"2013-12-21T20:09:22Z","receivedAt":"2013-12-21T20:09:22Z","isPatch":true,"sender":{"key":"naesten@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13903?v=4"},"body":"On Sat, Dec 21, 2013 at 4:42 AM, Jeff King <peff@peff.net> wrote:\n> On Fri, Dec 20, 2013 at 10:45:01AM -0500, Samuel Bronson wrote:\n>\n>> These warnings don't really seem to make much sense for this file.\n>\n> Agreed, though the advice so far has been to put -Wno-format-zero-length\n> in your CFLAGS.\n\nYes, auto-detecting acceptance of this flag and using it automatically\nmight be a reasonable approach as well, but I thought this warning\nmight potentially be useful WRT other printf-like functions.\n\n>> +/* We have good reasons for using zero-length format strings, and\n>> + * there's unfortunately no way to turn this off on a per-function\n>> + * basis ... */\n>> +#pragma GCC diagnostic ignored \"-Wformat-zero-length\"\n>\n> Are other compilers happy to ignore this pragma? I guess we could wrap\n> it in an #ifdef, if so.\n\nI assume you meant we could use an #ifdef if *not*?\n\n> It's also really not about this file in particular. The whole concept of\n> format-zero-length is questionable, as it ignores the concept that a\n> format function might actually do something useful with an empty format\n> (e.g., by adding boilerplate, or having a side-effect). It's just that\n> this file is the only one that happens to do so.\n\nHmm, I think I saw one other instance of this warning, actually, but\nit didn't seem worth adding the pragma to a file for just one warning.\n\n> Annotating the _function_ to say \"it's useful to pass an empty format\n> into this function\" would make sense, but as you note, there is no way\n> to do that.\n\nI made a note about this at\n<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47901#c9> (comment #9 on\n\"-Wall should not imply -Wformat-zero-length by default\")\n\n> So I dunno. This seems like it does not quite specify what we want to\n> say as well as just \"-Wno-format-zero-length\", but it is more convenient\n> in practice (because we take care of it in the source code, rather than\n> relying on the user's build settings).\n\nYeah.\n"}]}