[Devel] [PATCH RHEL7 COMMIT] fs/fuse kio: fix gcc warning maybe-uninitialized in do_show_cs_stats()

Konstantin Khorenko khorenko at virtuozzo.com
Thu May 30 11:47:47 MSK 2019


The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.8
------>
commit 248ab0340df34c9b7d078e3feaf6ac806d349b0b
Author: Pavel Butsykin <pbutsykin at virtuozzo.com>
Date:   Thu May 30 11:47:45 2019 +0300

    fs/fuse kio: fix gcc warning maybe-uninitialized in do_show_cs_stats()
    
    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
    
    Fixes: 049aa5f3a22c fs/fuse kio: implement cs_stats statistics info
    
    Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
---
 fs/fuse/kio/pcs/fuse_stat.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

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);



More information about the Devel mailing list