diff mbox

include/trace/events/wbt.h: Suppress a compiler warning

Message ID 20180627202234.17670-1-bart.vanassche@wdc.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bart Van Assche June 27, 2018, 8:22 p.m. UTC
This patch avoids that the following warning appears when building
with gcc 8 and W=1:

./include/trace/events/wbt.h:36:3: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
---
 include/trace/events/wbt.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Christoph Hellwig June 29, 2018, 8:34 a.m. UTC | #1
On Wed, Jun 27, 2018 at 01:22:34PM -0700, Bart Van Assche wrote:
> This patch avoids that the following warning appears when building
> with gcc 8 and W=1:
> 
> ./include/trace/events/wbt.h:36:3: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]

I really don't think this is the right fix.  Note that the trace
code allows for dynamic arrays using __dynamic_array(), so the best idea
might be to switch to that.
diff mbox

Patch

diff --git a/include/trace/events/wbt.h b/include/trace/events/wbt.h
index b048694070e2..29ec58adfddd 100644
--- a/include/trace/events/wbt.h
+++ b/include/trace/events/wbt.h
@@ -8,6 +8,9 @@ 
 #include <linux/tracepoint.h>
 #include "../../../block/blk-wbt.h"
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wstringop-truncation"
+
 /**
  * wbt_stat - trace stats for blk_wb
  * @stat: array of read/write stats
@@ -148,6 +151,8 @@  TRACE_EVENT(wbt_timer,
 		  __entry->status, __entry->step, __entry->inflight)
 );
 
+#pragma GCC diagnostic pop
+
 #endif /* _TRACE_WBT_H */
 
 /* This part must be outside protection */