* [PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings
@ 2013-12-20 15:45 Samuel Bronson
2013-12-21 9:42 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: Samuel Bronson @ 2013-12-20 15:45 UTC (permalink / raw)
To: git; +Cc: Samuel Bronson
These warnings don't really seem to make much sense for this file.
Signed-off-by: Samuel Bronson <naesten@gmail.com>
---
wt-status.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/wt-status.c b/wt-status.c
index 4e55810..542cc65 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -17,6 +17,11 @@
#include "strbuf.h"
#include "utf8.h"
+/* We have good reasons for using zero-length format strings, and
+ * there's unfortunately no way to turn this off on a per-function
+ * basis ... */
+#pragma GCC diagnostic ignored "-Wformat-zero-length"
+
static char cut_line[] =
"------------------------ >8 ------------------------\n";
--
1.8.4.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings
2013-12-20 15:45 [PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings Samuel Bronson
@ 2013-12-21 9:42 ` Jeff King
2013-12-21 20:09 ` Samuel Bronson
0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2013-12-21 9:42 UTC (permalink / raw)
To: Samuel Bronson; +Cc: git
On Fri, Dec 20, 2013 at 10:45:01AM -0500, Samuel Bronson wrote:
> These warnings don't really seem to make much sense for this file.
Agreed, though the advice so far has been to put -Wno-format-zero-length
in your CFLAGS.
> +/* We have good reasons for using zero-length format strings, and
> + * there's unfortunately no way to turn this off on a per-function
> + * basis ... */
> +#pragma GCC diagnostic ignored "-Wformat-zero-length"
Are other compilers happy to ignore this pragma? I guess we could wrap
it in an #ifdef, if so.
It's also really not about this file in particular. The whole concept of
format-zero-length is questionable, as it ignores the concept that a
format function might actually do something useful with an empty format
(e.g., by adding boilerplate, or having a side-effect). It's just that
this file is the only one that happens to do so.
Annotating the _function_ to say "it's useful to pass an empty format
into this function" would make sense, but as you note, there is no way
to do that.
So I dunno. This seems like it does not quite specify what we want to
say as well as just "-Wno-format-zero-length", but it is more convenient
in practice (because we take care of it in the source code, rather than
relying on the user's build settings).
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings
2013-12-21 9:42 ` Jeff King
@ 2013-12-21 20:09 ` Samuel Bronson
0 siblings, 0 replies; 3+ messages in thread
From: Samuel Bronson @ 2013-12-21 20:09 UTC (permalink / raw)
To: Jeff King; +Cc: git
On Sat, Dec 21, 2013 at 4:42 AM, Jeff King <peff@peff.net> wrote:
> On Fri, Dec 20, 2013 at 10:45:01AM -0500, Samuel Bronson wrote:
>
>> These warnings don't really seem to make much sense for this file.
>
> Agreed, though the advice so far has been to put -Wno-format-zero-length
> in your CFLAGS.
Yes, auto-detecting acceptance of this flag and using it automatically
might be a reasonable approach as well, but I thought this warning
might potentially be useful WRT other printf-like functions.
>> +/* We have good reasons for using zero-length format strings, and
>> + * there's unfortunately no way to turn this off on a per-function
>> + * basis ... */
>> +#pragma GCC diagnostic ignored "-Wformat-zero-length"
>
> Are other compilers happy to ignore this pragma? I guess we could wrap
> it in an #ifdef, if so.
I assume you meant we could use an #ifdef if *not*?
> It's also really not about this file in particular. The whole concept of
> format-zero-length is questionable, as it ignores the concept that a
> format function might actually do something useful with an empty format
> (e.g., by adding boilerplate, or having a side-effect). It's just that
> this file is the only one that happens to do so.
Hmm, I think I saw one other instance of this warning, actually, but
it didn't seem worth adding the pragma to a file for just one warning.
> Annotating the _function_ to say "it's useful to pass an empty format
> into this function" would make sense, but as you note, there is no way
> to do that.
I made a note about this at
<http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47901#c9> (comment #9 on
"-Wall should not imply -Wformat-zero-length by default")
> So I dunno. This seems like it does not quite specify what we want to
> say as well as just "-Wno-format-zero-length", but it is more convenient
> in practice (because we take care of it in the source code, rather than
> relying on the user's build settings).
Yeah.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-21 20:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-20 15:45 [PATCH] wt-status.c: disable those distracting -Wformat-zero-length warnings Samuel Bronson
2013-12-21 9:42 ` Jeff King
2013-12-21 20:09 ` Samuel Bronson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).