fs/fuse kio: fix gcc warning maybe-uninitialized

Submitted by Pavel Butsykin on May 30, 2019, 8:35 a.m.

Details

Message ID 20190530083556.30109-1-pbutsykin@virtuozzo.com
State New
Series "fs/fuse kio: fix gcc warning maybe-uninitialized"
Headers show

Commit Message

Pavel Butsykin May 30, 2019, 8:35 a.m.
The compiler doesn't understand that pcs_perf_rate_cnt and fuse_lat_stat
structures may not be initialized only if the number of possible cpu is zero,
and this is impossible.

gcc log:
fs/fuse/kio/pcs/fuse_stat.c: In function 'do_show_cs_stats':
fs/fuse/kio/pcs/fuse_stat.c:354:12: error: 'sync_ops_rate.rate' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  seq_printf(m, "%-10llu %d=%-8s %-10llu %-10llu %-11llu",
            ^
fs/fuse/kio/pcs/fuse_stat.c:354:12: error: 'write_ops_rate.rate' may be used uninitialized in this function [-Werror=maybe-uninitialized]
fs/fuse/kio/pcs/fuse_stat.c:354:12: error: 'read_ops_rate.rate' may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1: all warnings being treated as errors

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
---
 fs/fuse/kio/pcs/fuse_stat.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/fuse_stat.c b/fs/fuse/kio/pcs/fuse_stat.c
index 1b44793d25f8..06be3c75240c 100644
--- a/fs/fuse/kio/pcs/fuse_stat.c
+++ b/fs/fuse/kio/pcs/fuse_stat.c
@@ -313,13 +313,13 @@  static int do_show_cs_stats(struct pcs_cs *cs, void *ctx)
 	struct seq_file *m = ctx;
 	int rpc_state = cs->rpc ? cs->rpc->state : PCS_RPC_UNCONN;
 	unsigned int in_flight_avg = cs->in_flight_avg;
-	struct fuse_lat_stat iolat, netlat;
-	struct pcs_perf_rate_cnt read_ops_rate, write_ops_rate, sync_ops_rate;
+	struct fuse_lat_stat iolat = {}, netlat = {};
+	struct pcs_perf_rate_cnt read_ops_rate = {}, write_ops_rate = {},
+				 sync_ops_rate = {};
 	unsigned seq;
 
 	do {
 		int cpu;
-		bool inited = false;
 
 		seq = read_seqbegin(&cs->stat.seqlock);
 		for_each_possible_cpu(cpu) {
@@ -334,15 +334,6 @@  static int do_show_cs_stats(struct pcs_cs *cs, void *ctx)
 			pcpu_write_rate = per_cpu_ptr(cs->stat.write_ops_rate, cpu);
 			pcpu_sync_rate = per_cpu_ptr(cs->stat.sync_ops_rate, cpu);
 
-			if (!inited) {
-				iolat = *pcpu_iolat;
-				netlat = *pcpu_netlat;
-				read_ops_rate = *pcpu_read_rate;
-				write_ops_rate = *pcpu_write_rate;
-				sync_ops_rate = *pcpu_sync_rate;
-				inited = true;
-				continue;
-			}
 			fuse_iolat_sum(&iolat, pcpu_iolat);
 			fuse_iolat_sum(&netlat, pcpu_netlat);
 			pcs_cs_stat_rate_sum(&read_ops_rate, pcpu_read_rate);