staging: lustre: remove initialization of static ints
[firefly-linux-kernel-4.4.55.git] / drivers / staging / lustre / lustre / obdclass / lprocfs_status.c
index 3b7dfc367722f2b569d7706bb4b73343cc8a5f51..c171c6c6c457cda82fedc82c29880ae3e0618dcd 100644 (file)
@@ -45,6 +45,7 @@
 #include "../include/lprocfs_status.h"
 #include "../include/lustre/lustre_idl.h"
 #include <linux/seq_file.h>
+#include <linux/ctype.h>
 
 static const char * const obd_connect_names[] = {
        "read_only",
@@ -222,7 +223,7 @@ EXPORT_SYMBOL(lprocfs_write_frac_helper);
 
 #if defined (CONFIG_PROC_FS)
 
-static int lprocfs_no_percpu_stats = 0;
+static int lprocfs_no_percpu_stats;
 module_param(lprocfs_no_percpu_stats, int, 0644);
 MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats");
 
@@ -376,7 +377,8 @@ EXPORT_SYMBOL(lprocfs_register);
 /* Generic callbacks */
 int lprocfs_rd_uint(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%u\n", *(unsigned int *)data);
+       seq_printf(m, "%u\n", *(unsigned int *)data);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_uint);
 
@@ -402,7 +404,8 @@ EXPORT_SYMBOL(lprocfs_wr_uint);
 
 int lprocfs_rd_u64(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%llu\n", *(__u64 *)data);
+       seq_printf(m, "%llu\n", *(__u64 *)data);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_u64);
 
@@ -410,7 +413,8 @@ int lprocfs_rd_atomic(struct seq_file *m, void *data)
 {
        atomic_t *atom = data;
        LASSERT(atom != NULL);
-       return seq_printf(m, "%d\n", atomic_read(atom));
+       seq_printf(m, "%d\n", atomic_read(atom));
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_atomic);
 
@@ -438,7 +442,8 @@ int lprocfs_rd_uuid(struct seq_file *m, void *data)
        struct obd_device *obd = data;
 
        LASSERT(obd != NULL);
-       return seq_printf(m, "%s\n", obd->obd_uuid.uuid);
+       seq_printf(m, "%s\n", obd->obd_uuid.uuid);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_uuid);
 
@@ -447,7 +452,8 @@ int lprocfs_rd_name(struct seq_file *m, void *data)
        struct obd_device *dev = data;
 
        LASSERT(dev != NULL);
-       return seq_printf(m, "%s\n", dev->obd_name);
+       seq_printf(m, "%s\n", dev->obd_name);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_name);
 
@@ -459,7 +465,8 @@ int lprocfs_rd_blksize(struct seq_file *m, void *data)
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                            OBD_STATFS_NODELAY);
        if (!rc)
-               rc = seq_printf(m, "%u\n", osfs.os_bsize);
+               seq_printf(m, "%u\n", osfs.os_bsize);
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_blksize);
@@ -478,8 +485,9 @@ int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               rc = seq_printf(m, "%llu\n", result);
+               seq_printf(m, "%llu\n", result);
        }
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_kbytestotal);
@@ -498,8 +506,9 @@ int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               rc = seq_printf(m, "%llu\n", result);
+               seq_printf(m, "%llu\n", result);
        }
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_kbytesfree);
@@ -518,8 +527,9 @@ int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
                while (blk_size >>= 1)
                        result <<= 1;
 
-               rc = seq_printf(m, "%llu\n", result);
+               seq_printf(m, "%llu\n", result);
        }
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_kbytesavail);
@@ -532,7 +542,7 @@ int lprocfs_rd_filestotal(struct seq_file *m, void *data)
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                            OBD_STATFS_NODELAY);
        if (!rc)
-               rc = seq_printf(m, "%llu\n", osfs.os_files);
+               seq_printf(m, "%llu\n", osfs.os_files);
 
        return rc;
 }
@@ -546,7 +556,8 @@ int lprocfs_rd_filesfree(struct seq_file *m, void *data)
                            cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
                            OBD_STATFS_NODELAY);
        if (!rc)
-               rc = seq_printf(m, "%llu\n", osfs.os_ffree);
+               seq_printf(m, "%llu\n", osfs.os_ffree);
+
        return rc;
 }
 EXPORT_SYMBOL(lprocfs_rd_filesfree);
@@ -556,17 +567,18 @@ int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
        struct obd_device *obd = data;
        struct obd_import *imp;
        char *imp_state_name = NULL;
-       int rc = 0;
 
        LASSERT(obd != NULL);
        LPROCFS_CLIMP_CHECK(obd);
        imp = obd->u.cli.cl_import;
        imp_state_name = ptlrpc_import_state_name(imp->imp_state);
-       rc = seq_printf(m, "%s\t%s%s\n", obd2cli_tgt(obd), imp_state_name,
-                       imp->imp_deactive ? "\tDEACTIVATED" : "");
+       seq_printf(m, "%s\t%s%s\n",
+                  obd2cli_tgt(obd), imp_state_name,
+                  imp->imp_deactive ? "\tDEACTIVATED" : "");
 
        LPROCFS_CLIMP_EXIT(obd);
-       return rc;
+
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_server_uuid);
 
@@ -574,19 +586,19 @@ int lprocfs_rd_conn_uuid(struct seq_file *m, void *data)
 {
        struct obd_device *obd = data;
        struct ptlrpc_connection *conn;
-       int rc = 0;
 
        LASSERT(obd != NULL);
 
        LPROCFS_CLIMP_CHECK(obd);
        conn = obd->u.cli.cl_import->imp_connection;
        if (conn && obd->u.cli.cl_import)
-               rc = seq_printf(m, "%s\n", conn->c_remote_uuid.uuid);
+               seq_printf(m, "%s\n", conn->c_remote_uuid.uuid);
        else
-               rc = seq_printf(m, "%s\n", "<none>");
+               seq_puts(m, "<none>\n");
 
        LPROCFS_CLIMP_EXIT(obd);
-       return rc;
+
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_conn_uuid);
 
@@ -923,7 +935,8 @@ int lprocfs_rd_num_exports(struct seq_file *m, void *data)
        struct obd_device *obd = data;
 
        LASSERT(obd != NULL);
-       return seq_printf(m, "%u\n", obd->obd_num_exports);
+       seq_printf(m, "%u\n", obd->obd_num_exports);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_num_exports);
 
@@ -932,7 +945,8 @@ int lprocfs_rd_numrefs(struct seq_file *m, void *data)
        struct obd_type *class = (struct obd_type *) data;
 
        LASSERT(class != NULL);
-       return seq_printf(m, "%d\n", class->typ_refcnt);
+       seq_printf(m, "%d\n", class->typ_refcnt);
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_rd_numrefs);
 
@@ -1199,41 +1213,33 @@ static int lprocfs_stats_seq_show(struct seq_file *p, void *v)
        struct lprocfs_counter_header   *hdr;
        struct lprocfs_counter           ctr;
        int                              idx    = *(loff_t *)v;
-       int                              rc     = 0;
 
        if (idx == 0) {
                struct timeval now;
                do_gettimeofday(&now);
-               rc = seq_printf(p, "%-25s %lu.%lu secs.usecs\n",
-                               "snapshot_time", now.tv_sec, (unsigned long)now.tv_usec);
-               if (rc < 0)
-                       return rc;
+               seq_printf(p, "%-25s %lu.%lu secs.usecs\n",
+                          "snapshot_time",
+                          now.tv_sec, (unsigned long)now.tv_usec);
        }
+
        hdr = &stats->ls_cnt_header[idx];
        lprocfs_stats_collect(stats, idx, &ctr);
 
-       if (ctr.lc_count == 0)
-               goto out;
+       if (ctr.lc_count != 0) {
+               seq_printf(p, "%-25s %lld samples [%s]",
+                          hdr->lc_name, ctr.lc_count, hdr->lc_units);
 
-       rc = seq_printf(p, "%-25s %lld samples [%s]", hdr->lc_name,
-                       ctr.lc_count, hdr->lc_units);
-
-       if (rc < 0)
-               goto out;
-
-       if ((hdr->lc_config & LPROCFS_CNTR_AVGMINMAX) && (ctr.lc_count > 0)) {
-               rc = seq_printf(p, " %lld %lld %lld",
-                               ctr.lc_min, ctr.lc_max, ctr.lc_sum);
-               if (rc < 0)
-                       goto out;
-               if (hdr->lc_config & LPROCFS_CNTR_STDDEV)
-                       rc = seq_printf(p, " %lld", ctr.lc_sumsquare);
-               if (rc < 0)
-                       goto out;
+               if ((hdr->lc_config & LPROCFS_CNTR_AVGMINMAX) &&
+                   (ctr.lc_count > 0)) {
+                       seq_printf(p, " %lld %lld %lld",
+                                  ctr.lc_min, ctr.lc_max, ctr.lc_sum);
+                       if (hdr->lc_config & LPROCFS_CNTR_STDDEV)
+                               seq_printf(p, " %lld", ctr.lc_sumsquare);
+               }
+               seq_putc(p, '\n');
        }
-       rc = seq_printf(p, "\n");
-out:
-       return (rc < 0) ? rc : 0;
+
+       return 0;
 }
 
 static const struct seq_operations lprocfs_stats_seq_sops = {
@@ -1605,8 +1611,9 @@ LPROC_SEQ_FOPS_RO(lproc_exp_hash);
 
 int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data)
 {
-       return seq_printf(m, "%s\n",
-                         "Write into this file to clear all nid stats and stale nid entries");
+       seq_printf(m, "%s\n",
+                  "Write into this file to clear all nid stats and stale nid entries");
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_nid_stats_clear_read);
 
@@ -1849,7 +1856,7 @@ int lprocfs_seq_read_frac_helper(struct seq_file *m, long val, int mult)
 }
 EXPORT_SYMBOL(lprocfs_seq_read_frac_helper);
 
-int lprocfs_write_u64_helper(const char *buffer, unsigned long count,
+int lprocfs_write_u64_helper(const char __user *buffer, unsigned long count,
                             __u64 *val)
 {
        return lprocfs_write_frac_u64_helper(buffer, count, val, 1);
@@ -1862,6 +1869,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
        char kernbuf[22], *end, *pbuf;
        __u64 whole, frac = 0, units;
        unsigned frac_d = 1;
+       int sign = 1;
 
        if (count > (sizeof(kernbuf) - 1))
                return -EINVAL;
@@ -1872,7 +1880,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
        kernbuf[count] = '\0';
        pbuf = kernbuf;
        if (*pbuf == '-') {
-               mult = -mult;
+               sign = -1;
                pbuf++;
        }
 
@@ -1880,7 +1888,7 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
        if (pbuf == end)
                return -EINVAL;
 
-       if (end != NULL && *end == '.') {
+       if (*end == '.') {
                int i;
                pbuf = end + 1;
 
@@ -1895,25 +1903,25 @@ int lprocfs_write_frac_u64_helper(const char *buffer, unsigned long count,
        }
 
        units = 1;
-       switch (*end) {
-       case 'p': case 'P':
+       switch (tolower(*end)) {
+       case 'p':
                units <<= 10;
-       case 't': case 'T':
+       case 't':
                units <<= 10;
-       case 'g': case 'G':
+       case 'g':
                units <<= 10;
-       case 'm': case 'M':
+       case 'm':
                units <<= 10;
-       case 'k': case 'K':
+       case 'k':
                units <<= 10;
        }
        /* Specified units override the multiplier */
-       if (units)
-               mult = mult < 0 ? -units : units;
+       if (units > 1)
+               mult = units;
 
        frac *= mult;
        do_div(frac, frac_d);
-       *val = whole * mult + frac;
+       *val = sign * (whole * mult + frac);
        return 0;
 }
 EXPORT_SYMBOL(lprocfs_write_frac_u64_helper);
@@ -2039,12 +2047,12 @@ int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data)
 {
        struct obd_device *dev = data;
        struct client_obd *cli = &dev->u.cli;
-       int rc;
 
        client_obd_list_lock(&cli->cl_loi_list_lock);
-       rc = seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
+       seq_printf(m, "%d\n", cli->cl_max_pages_per_rpc);
        client_obd_list_unlock(&cli->cl_loi_list_lock);
-       return rc;
+
+       return 0;
 }
 EXPORT_SYMBOL(lprocfs_obd_rd_max_pages_per_rpc);