Skip to contentSkip to conversation

block/qapi: Fix Sparse warning

PATCH Applied Stefan Weil 2 participants 2 messages Mar 7, 2015 – Mar 10, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/qapi: Fix Sparse warning

Sparse reports this warning:

block/qapi.c:417:47: warning:
too long initializer-string for array of char(no space for nul char)

Replacing the string by an array of characters fixes this warning.

---
 block/qapi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/qapi.c +1 -1
index 1808e67..8a19aed 100644
@@ -414,7 +414,7 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
 
 static char *get_human_readable_size(char *buf, int buf_size, int64_t size)
 {
-    static const char suffixes[NB_SUFFIXES] = "KMGT";
+    static const char suffixes[NB_SUFFIXES] = {'K', 'M', 'G', 'T'};
     int64_t base;
     int i;
 
Signature · 1 line
2.1.4
#1 lore raw

block/qapi.c BlockStatsList *qmp_query_blockstats(bool has_query_nodes, · line 417

Quoted 9 lines · Stefan Weil

Sparse reports this warning:

block/qapi.c:417:47: warning:
too long initializer-string for array of char(no space for nul char)

Replacing the string by an array of characters fixes this warning.

block/qapi.c +1 -1
-    static const char suffixes[NB_SUFFIXES] = "KMGT";
+    static const char suffixes[NB_SUFFIXES] = {'K', 'M', 'G', 'T'};

The latter is a bit uglier to my taste but oh well, damn warnings! :)

Applied to -trivial, thanks!

/mjt