Whamcloud - gitweb
LU-6142 lustre: convert snprintf to scnprintf as appropriate 44/39744/2
authorMr NeilBrown <neilb@suse.de>
Thu, 27 Aug 2020 06:52:13 +0000 (16:52 +1000)
committerOleg Drokin <green@whamcloud.com>
Fri, 26 Feb 2021 21:43:23 +0000 (21:43 +0000)
The return value of snprintf() is the number of bytes that would have
been copies into the buffer if it was large enough.
Many places in the code use it as though it were the number of bytes
actually copied.  In practice this (almost?) never makes a difference.
However it is poor style to use the wrong interfaces as it might one
day be copied to somewhere that it does make a difference.

So change these instances of snprintf to scnprintf which DOES return
the number of bytes actually copied.
This is all places where the return value is simply returned to the
call, and a couple of others.

Also change the declared buffer size in a couple of places to the
actual buffer size (PAGE_SIZE in these cases).

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I5428760689eaca98e6bf2bceae119f1b7acf35ac
Reviewed-on: https://review.whamcloud.com/39744
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
15 files changed:
libcfs/libcfs/util/nidstrings.c
lustre/ldlm/ldlm_resource.c
lustre/lfsck/lfsck_striped_dir.c
lustre/llite/lproc_llite.c
lustre/llite/pcc.c
lustre/lod/lproc_lod.c
lustre/mdd/mdd_lproc.c
lustre/obdclass/obd_sysfs.c
lustre/ofd/lproc_ofd.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_oi.c
lustre/ptlrpc/gss/gss_krb5_mech.c
lustre/ptlrpc/gss/gss_null_mech.c
lustre/ptlrpc/gss/gss_sk_mech.c
lustre/utils/lhsmtool_posix.c

index 7d13e47..67693e6 100644 (file)
@@ -1306,10 +1306,10 @@ cfs_print_network(char *buffer, int count, struct nidrange *nr)
        struct netstrfns *nf = nr->nr_netstrfns;
 
        if (nr->nr_netnum == 0)
-               return snprintf(buffer, count, "@%s", nf->nf_name);
+               return scnprintf(buffer, count, "@%s", nf->nf_name);
        else
-               return snprintf(buffer, count, "@%s%u",
-                                   nf->nf_name, nr->nr_netnum);
+               return scnprintf(buffer, count, "@%s%u",
+                                nf->nf_name, nr->nr_netnum);
 }
 
 
index ea6e751..21cc6c4 100644 (file)
@@ -504,8 +504,8 @@ static ssize_t dirty_age_limit_show(struct kobject *kobj,
        struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
                                                 ns_kobj);
 
-       return snprintf(buf, PAGE_SIZE, "%llu\n",
-                       ktime_divns(ns->ns_dirty_age_limit, NSEC_PER_SEC));
+       return scnprintf(buf, PAGE_SIZE, "%llu\n",
+                        ktime_divns(ns->ns_dirty_age_limit, NSEC_PER_SEC));
 }
 
 static ssize_t dirty_age_limit_store(struct kobject *kobj,
@@ -532,7 +532,7 @@ static ssize_t ctime_age_limit_show(struct kobject *kobj,
        struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
                                                 ns_kobj);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n", ns->ns_ctime_age_limit);
+       return scnprintf(buf, PAGE_SIZE, "%u\n", ns->ns_ctime_age_limit);
 }
 
 static ssize_t ctime_age_limit_store(struct kobject *kobj,
index 854504d..5d73261 100644 (file)
@@ -1998,9 +1998,9 @@ int lfsck_namespace_striped_dir_rescan(const struct lu_env *env,
                        continue;
 
                lnr->lnr_fid = *cfid;
-               lnr->lnr_namelen = snprintf(lnr->lnr_name,
-                                           lnr->lnr_size - sizeof(*lnr),
-                                           DFID":%u", PFID(cfid), i);
+               lnr->lnr_namelen = scnprintf(lnr->lnr_name,
+                                            lnr->lnr_size - sizeof(*lnr),
+                                            DFID":%u", PFID(cfid), i);
                cname = lfsck_name_get_const(env, lnr->lnr_name,
                                             lnr->lnr_namelen);
                obj = lfsck_object_find_bottom(env, lfsck, cfid);
index 110ca6a..73f5e1a 100644 (file)
@@ -723,7 +723,7 @@ static ssize_t statahead_running_max_show(struct kobject *kobj,
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
 
-       return snprintf(buf, 16, "%u\n", sbi->ll_sa_running_max);
+       return scnprintf(buf, PAGE_SIZE, "%u\n", sbi->ll_sa_running_max);
 }
 
 static ssize_t statahead_running_max_store(struct kobject *kobj,
@@ -874,7 +874,7 @@ static ssize_t statfs_max_age_show(struct kobject *kobj, struct attribute *attr,
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n", sbi->ll_statfs_max_age);
+       return scnprintf(buf, PAGE_SIZE, "%u\n", sbi->ll_statfs_max_age);
 }
 
 static ssize_t statfs_max_age_store(struct kobject *kobj,
@@ -912,8 +912,8 @@ static ssize_t max_easize_show(struct kobject *kobj,
                return rc;
 
        /* Limit xattr size returned to userspace based on kernel maximum */
-       return snprintf(buf, PAGE_SIZE, "%u\n",
-                       ealen > XATTR_SIZE_MAX ? XATTR_SIZE_MAX : ealen);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        ealen > XATTR_SIZE_MAX ? XATTR_SIZE_MAX : ealen);
 }
 LUSTRE_RO_ATTR(max_easize);
 
@@ -942,8 +942,8 @@ static ssize_t default_easize_show(struct kobject *kobj,
                return rc;
 
        /* Limit xattr size returned to userspace based on kernel maximum */
-       return snprintf(buf, PAGE_SIZE, "%u\n",
-                       ealen > XATTR_SIZE_MAX ? XATTR_SIZE_MAX : ealen);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        ealen > XATTR_SIZE_MAX ? XATTR_SIZE_MAX : ealen);
 }
 
 /**
@@ -1088,8 +1088,8 @@ static ssize_t max_read_ahead_async_active_show(struct kobject *kobj,
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n",
-                       sbi->ll_ra_info.ra_async_max_active);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        sbi->ll_ra_info.ra_async_max_active);
 }
 
 static ssize_t max_read_ahead_async_active_store(struct kobject *kobj,
@@ -1133,8 +1133,8 @@ static ssize_t read_ahead_async_file_threshold_mb_show(struct kobject *kobj,
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
 
-       return snprintf(buf, PAGE_SIZE, "%lu\n",
-            PAGES_TO_MiB(sbi->ll_ra_info.ra_async_pages_per_file_threshold));
+       return scnprintf(buf, PAGE_SIZE, "%lu\n", PAGES_TO_MiB(
+                        sbi->ll_ra_info.ra_async_pages_per_file_threshold));
 }
 
 static ssize_t
@@ -1254,8 +1254,8 @@ static ssize_t file_heat_show(struct kobject *kobj,
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n",
-                       !!(sbi->ll_flags & LL_SBI_FILE_HEAT));
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        !!(sbi->ll_flags & LL_SBI_FILE_HEAT));
 }
 
 static ssize_t file_heat_store(struct kobject *kobj,
@@ -1290,8 +1290,8 @@ static ssize_t heat_decay_percentage_show(struct kobject *kobj,
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n",
-                      (sbi->ll_heat_decay_weight * 100 + 128) / 256);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        (sbi->ll_heat_decay_weight * 100 + 128) / 256);
 }
 
 static ssize_t heat_decay_percentage_store(struct kobject *kobj,
@@ -1324,7 +1324,7 @@ static ssize_t heat_period_second_show(struct kobject *kobj,
        struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
                                              ll_kset.kobj);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n", sbi->ll_heat_period_second);
+       return scnprintf(buf, PAGE_SIZE, "%u\n", sbi->ll_heat_period_second);
 }
 
 static ssize_t heat_period_second_store(struct kobject *kobj,
index 35d3962..3bfc05b 100644 (file)
@@ -1060,15 +1060,15 @@ void pcc_inode_free(struct inode *inode)
 #define MAX_PCC_DATABASE_PATH (6 * 5 + FID_NOBRACE_LEN + 1)
 static int pcc_fid2dataset_path(char *buf, int sz, struct lu_fid *fid)
 {
-       return snprintf(buf, sz, "%04x/%04x/%04x/%04x/%04x/%04x/"
-                       DFID_NOBRACE,
-                       (fid)->f_oid       & 0xFFFF,
-                       (fid)->f_oid >> 16 & 0xFFFF,
-                       (unsigned int)((fid)->f_seq       & 0xFFFF),
-                       (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
-                       (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
-                       (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
-                       PFID(fid));
+       return scnprintf(buf, sz, "%04x/%04x/%04x/%04x/%04x/%04x/"
+                        DFID_NOBRACE,
+                        (fid)->f_oid       & 0xFFFF,
+                        (fid)->f_oid >> 16 & 0xFFFF,
+                        (unsigned int)((fid)->f_seq       & 0xFFFF),
+                        (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
+                        (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
+                        (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
+                        PFID(fid));
 }
 
 static inline const struct cred *pcc_super_cred(struct super_block *sb)
@@ -1140,16 +1140,16 @@ static int pcc_get_layout_info(struct inode *inode, struct cl_layout *clt)
 static int pcc_fid2dataset_fullpath(char *buf, int sz, struct lu_fid *fid,
                                    struct pcc_dataset *dataset)
 {
-       return snprintf(buf, sz, "%s/%04x/%04x/%04x/%04x/%04x/%04x/"
-                       DFID_NOBRACE,
-                       dataset->pccd_pathname,
-                       (fid)->f_oid       & 0xFFFF,
-                       (fid)->f_oid >> 16 & 0xFFFF,
-                       (unsigned int)((fid)->f_seq       & 0xFFFF),
-                       (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
-                       (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
-                       (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
-                       PFID(fid));
+       return scnprintf(buf, sz, "%s/%04x/%04x/%04x/%04x/%04x/%04x/"
+                        DFID_NOBRACE,
+                        dataset->pccd_pathname,
+                        (fid)->f_oid       & 0xFFFF,
+                        (fid)->f_oid >> 16 & 0xFFFF,
+                        (unsigned int)((fid)->f_seq       & 0xFFFF),
+                        (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
+                        (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
+                        (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
+                        PFID(fid));
 }
 
 /* Must be called with pcci->pcci_lock held */
index 4b9a591..34c664e 100644 (file)
@@ -52,8 +52,8 @@ static ssize_t dom_stripesize_show(struct kobject *kobj,
        struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
        struct lod_device *lod = dt2lod_dev(dt);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n",
-                       lod->lod_dom_stripesize_max_kb << 10);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        lod->lod_dom_stripesize_max_kb << 10);
 }
 
 static inline int dom_stripesize_max_kb_update(struct lod_device *lod,
@@ -113,8 +113,8 @@ static ssize_t dom_stripesize_max_kb_show(struct kobject *kobj,
        struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
        struct lod_device *lod = dt2lod_dev(dt);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n",
-                       lod->lod_dom_stripesize_max_kb);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        lod->lod_dom_stripesize_max_kb);
 }
 
 /**
@@ -150,7 +150,8 @@ static ssize_t dom_stripesize_cur_kb_show(struct kobject *kobj,
        struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
        struct lod_device *lod = dt2lod_dev(dt);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n", lod->lod_dom_stripesize_cur_kb);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        lod->lod_dom_stripesize_cur_kb);
 }
 
 LUSTRE_RO_ATTR(dom_stripesize_cur_kb);
@@ -164,8 +165,8 @@ static ssize_t dom_threshold_free_mb_show(struct kobject *kobj,
        struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
        struct lod_device *lod = dt2lod_dev(dt);
 
-       return snprintf(buf, PAGE_SIZE, "%llu\n",
-                       lod->lod_dom_threshold_free_mb);
+       return scnprintf(buf, PAGE_SIZE, "%llu\n",
+                        lod->lod_dom_threshold_free_mb);
 }
 
 /**
@@ -212,8 +213,8 @@ static ssize_t stripesize_show(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct lod_device *lod = dt2lod_dev(dt);
 
-       return snprintf(buf, PAGE_SIZE, "%llu\n",
-                       lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_size);
+       return scnprintf(buf, PAGE_SIZE, "%llu\n",
+                        lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_size);
 }
 
 static ssize_t stripesize_store(struct kobject *kobj, struct attribute *attr,
@@ -247,7 +248,7 @@ static ssize_t stripeoffset_show(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct lod_device *lod = dt2lod_dev(dt);
 
-       return snprintf(buf, PAGE_SIZE, "%lld\n",
+       return scnprintf(buf, PAGE_SIZE, "%lld\n",
                lod->lod_ost_descs.ltd_lov_desc.ld_default_stripe_offset);
 }
 
@@ -293,7 +294,7 @@ static ssize_t __stripetype_show(struct kobject *kobj, struct attribute *attr,
        struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
                                            &lod->lod_ost_descs;
 
-       return snprintf(buf, PAGE_SIZE, "%u\n", ltd->ltd_lov_desc.ld_pattern);
+       return scnprintf(buf, PAGE_SIZE, "%u\n", ltd->ltd_lov_desc.ld_pattern);
 }
 
 static ssize_t mdt_stripetype_show(struct kobject *kobj, struct attribute *attr,
@@ -365,8 +366,8 @@ static ssize_t __stripecount_show(struct kobject *kobj, struct attribute *attr,
        struct lov_desc *desc = is_mdt ? &lod->lod_mdt_descs.ltd_lov_desc :
                                         &lod->lod_ost_descs.ltd_lov_desc;
 
-       return snprintf(buf, PAGE_SIZE, "%d\n",
-                     (s16)(desc->ld_default_stripe_count + 1) - 1);
+       return scnprintf(buf, PAGE_SIZE, "%d\n",
+                        (s16)(desc->ld_default_stripe_count + 1) - 1);
 }
 
 static ssize_t mdt_stripecount_show(struct kobject *kobj,
@@ -438,7 +439,8 @@ static ssize_t __numobd_show(struct kobject *kobj, struct attribute *attr,
        struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
                                            &lod->lod_ost_descs;
 
-       return snprintf(buf, PAGE_SIZE, "%u\n", ltd->ltd_lov_desc.ld_tgt_count);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        ltd->ltd_lov_desc.ld_tgt_count);
 }
 
 static ssize_t mdt_numobd_show(struct kobject *kobj, struct attribute *attr,
@@ -468,8 +470,8 @@ static ssize_t __activeobd_show(struct kobject *kobj, struct attribute *attr,
        struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
                                            &lod->lod_ost_descs;
 
-       return snprintf(buf, PAGE_SIZE, "%u\n",
-                       ltd->ltd_lov_desc.ld_active_tgt_count);
+       return scnprintf(buf, PAGE_SIZE, "%u\n",
+                        ltd->ltd_lov_desc.ld_active_tgt_count);
 }
 
 static ssize_t mdt_activeobd_show(struct kobject *kobj, struct attribute *attr,
@@ -497,8 +499,8 @@ static ssize_t desc_uuid_show(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct lod_device *lod = dt2lod_dev(dt);
 
-       return snprintf(buf, PAGE_SIZE, "%s\n",
-                      lod->lod_ost_descs.ltd_lov_desc.ld_uuid.uuid);
+       return scnprintf(buf, PAGE_SIZE, "%s\n",
+                        lod->lod_ost_descs.ltd_lov_desc.ld_uuid.uuid);
 }
 LUSTRE_RO_ATTR(desc_uuid);
 
@@ -520,8 +522,8 @@ static ssize_t __qos_prio_free_show(struct kobject *kobj,
        struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
                                            &lod->lod_ost_descs;
 
-       return snprintf(buf, PAGE_SIZE, "%d%%\n",
-                      (ltd->ltd_qos.lq_prio_free * 100 + 255) >> 8);
+       return scnprintf(buf, PAGE_SIZE, "%d%%\n",
+                        (ltd->ltd_qos.lq_prio_free * 100 + 255) >> 8);
 }
 
 static ssize_t mdt_qos_prio_free_show(struct kobject *kobj,
@@ -599,8 +601,8 @@ static ssize_t __qos_threshold_rr_show(struct kobject *kobj,
        struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
                                            &lod->lod_ost_descs;
 
-       return snprintf(buf, PAGE_SIZE, "%d%%\n",
-                      (ltd->ltd_qos.lq_threshold_rr * 100 + 255) >> 8);
+       return scnprintf(buf, PAGE_SIZE, "%d%%\n",
+                        (ltd->ltd_qos.lq_threshold_rr * 100 + 255) >> 8);
 }
 
 static ssize_t mdt_qos_threshold_rr_show(struct kobject *kobj,
@@ -690,8 +692,8 @@ static ssize_t __qos_maxage_show(struct kobject *kobj, struct attribute *attr,
        struct lu_tgt_descs *ltd = is_mdt ? &lod->lod_mdt_descs :
                                            &lod->lod_ost_descs;
 
-       return snprintf(buf, PAGE_SIZE, "%u Sec\n",
-                      ltd->ltd_lov_desc.ld_qos_maxage);
+       return scnprintf(buf, PAGE_SIZE, "%u Sec\n",
+                        ltd->ltd_lov_desc.ld_qos_maxage);
 }
 
 static ssize_t mdt_qos_maxage_show(struct kobject *kobj, struct attribute *attr,
@@ -946,7 +948,7 @@ static ssize_t lmv_failout_show(struct kobject *kobj, struct attribute *attr,
                                            dd_kobj);
        struct lod_device *lod = dt2lod_dev(dt);
 
-       return snprintf(buf, PAGE_SIZE, "%d\n", lod->lod_lmv_failout ? 1 : 0);
+       return scnprintf(buf, PAGE_SIZE, "%d\n", lod->lod_lmv_failout ? 1 : 0);
 }
 
 /**
@@ -987,7 +989,7 @@ static ssize_t mdt_hash_show(struct kobject *kobj, struct attribute *attr,
        struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
        struct lod_device *lod = dt2lod_dev(dt);
 
-       return snprintf(buf, PAGE_SIZE, "%s\n",
+       return scnprintf(buf, PAGE_SIZE, "%s\n",
                mdt_hash_name[lod->lod_mdt_descs.ltd_lmv_desc.ld_pattern]);
 }
 
index 56a3b68..e80a90c 100644 (file)
@@ -548,7 +548,7 @@ static ssize_t append_stripe_count_show(struct kobject *kobj,
        struct mdd_device *mdd = container_of(kobj, struct mdd_device,
                                              mdd_kobj);
 
-       return snprintf(buf, PAGE_SIZE, "%d\n", mdd->mdd_append_stripe_count);
+       return scnprintf(buf, PAGE_SIZE, "%d\n", mdd->mdd_append_stripe_count);
 }
 
 /**
@@ -601,7 +601,7 @@ static ssize_t append_pool_show(struct kobject *kobj,
        struct mdd_device *mdd = container_of(kobj, struct mdd_device,
                                              mdd_kobj);
 
-       return snprintf(buf, LOV_MAXPOOLNAME + 1, "%s\n", mdd->mdd_append_pool);
+       return scnprintf(buf, PAGE_SIZE, "%s\n", mdd->mdd_append_pool);
 }
 
 /**
index 8e4cae2..a468fab 100644 (file)
@@ -280,7 +280,7 @@ static ssize_t jobid_var_show(struct kobject *kobj, struct attribute *attr,
        int rc = 0;
 
        if (strlen(obd_jobid_var))
-               rc = snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_var);
+               rc = scnprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_var);
        return rc;
 }
 
@@ -307,7 +307,7 @@ static ssize_t jobid_name_show(struct kobject *kobj, struct attribute *attr,
        int rc = 0;
 
        if (strlen(obd_jobid_name))
-               rc = snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_name);
+               rc = scnprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_name);
        return rc;
 }
 
@@ -349,7 +349,7 @@ static ssize_t jobid_this_session_show(struct kobject *kobj,
        rcu_read_lock();
        jid = jobid_current();
        if (jid)
-               ret = snprintf(buf, PAGE_SIZE, "%s\n", jid);
+               ret = scnprintf(buf, PAGE_SIZE, "%s\n", jid);
        rcu_read_unlock();
        return ret;
 }
index 5c27fa3..e517a2e 100644 (file)
@@ -163,7 +163,7 @@ static ssize_t atime_diff_show(struct kobject *kobj, struct attribute *attr,
                                              obd_kset.kobj);
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
 
-       return snprintf(buf, PAGE_SIZE, "%lld\n", ofd->ofd_atime_diff);
+       return scnprintf(buf, PAGE_SIZE, "%lld\n", ofd->ofd_atime_diff);
 }
 
 /**
@@ -304,7 +304,7 @@ static ssize_t no_precreate_show(struct kobject *kobj, struct attribute *attr,
                                              obd_kset.kobj);
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n", ofd->ofd_no_precreate);
+       return scnprintf(buf, PAGE_SIZE, "%u\n", ofd->ofd_no_precreate);
 }
 
 /**
@@ -695,7 +695,7 @@ static ssize_t access_log_mask_show(struct kobject *kobj,
                                              obd_kset.kobj);
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
 
-       return snprintf(buf, PAGE_SIZE, "%s%s%s\n",
+       return scnprintf(buf, PAGE_SIZE, "%s%s%s\n",
                (ofd->ofd_access_log_mask == 0) ? "0" : "",
                (ofd->ofd_access_log_mask & OFD_ACCESS_READ) ? "r" : "",
                (ofd->ofd_access_log_mask & OFD_ACCESS_WRITE) ? "w" : "");
@@ -739,7 +739,7 @@ static ssize_t access_log_size_show(struct kobject *kobj,
                                              obd_kset.kobj);
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
 
-       return snprintf(buf, PAGE_SIZE, "%u\n", ofd->ofd_access_log_size);
+       return scnprintf(buf, PAGE_SIZE, "%u\n", ofd->ofd_access_log_size);
 }
 
 static ssize_t access_log_size_store(struct kobject *kobj,
index 8a910e7..9d22233 100644 (file)
@@ -3974,8 +3974,8 @@ static struct inode *osd_create_local_agent_inode(const struct lu_env *env,
         */
        if (S_ISLNK(type)) {
                BUILD_BUG_ON(LDISKFS_N_BLOCKS * 4 < FID_LEN + 1);
-               rc = snprintf((char *)LDISKFS_I(local)->i_data,
-                             LDISKFS_N_BLOCKS * 4, DFID, PFID(fid));
+               rc = scnprintf((char *)LDISKFS_I(local)->i_data,
+                              LDISKFS_N_BLOCKS * 4, DFID, PFID(fid));
 
                i_size_write(local, rc);
                LDISKFS_I(local)->i_disksize = rc;
index fa65f2b..bc4882a 100644 (file)
@@ -368,8 +368,8 @@ static int osd_remove_ois(struct osd_thread_info *info, struct osd_device *osd)
                RETURN(-EROFS);
 
        for (i = 0; i < OSD_OI_FID_NR_MAX; i++) {
-               namelen = snprintf(name, sizeof(name), "%s.%d",
-                                  OSD_OI_NAME_BASE, i);
+               namelen = scnprintf(name, sizeof(name), "%s.%d",
+                                   OSD_OI_NAME_BASE, i);
                rc = osd_remove_oi_one(osd, osd_sb(osd)->s_root, name, namelen);
                if (rc != 0) {
                        CERROR(
@@ -379,7 +379,7 @@ static int osd_remove_ois(struct osd_thread_info *info, struct osd_device *osd)
                }
        }
 
-       namelen = snprintf(name, sizeof(name), "%s", OSD_OI_NAME_BASE);
+       namelen = scnprintf(name, sizeof(name), "%s", OSD_OI_NAME_BASE);
        rc = osd_remove_oi_one(osd, osd_sb(osd)->s_root, name, namelen);
        if (rc != 0)
                CERROR("%s: fail to remove the stale OI file %s: rc = %d\n",
index e0ddff9..a544e8b 100644 (file)
@@ -1525,15 +1525,15 @@ __u32 gss_unwrap_bulk_kerberos(struct gss_ctx *gctx,
 }
 
 int gss_display_kerberos(struct gss_ctx        *ctx,
-                         char                  *buf,
-                         int                    bufsize)
+                        char                  *buf,
+                        int                    bufsize)
 {
-        struct krb5_ctx    *kctx = ctx->internal_ctx_id;
-        int                 written;
+       struct krb5_ctx    *kctx = ctx->internal_ctx_id;
+       int                 written;
 
-        written = snprintf(buf, bufsize, "krb5 (%s)",
-                           enctype2str(kctx->kc_enctype));
-        return written;
+       written = scnprintf(buf, bufsize, "krb5 (%s)",
+                           enctype2str(kctx->kc_enctype));
+       return written;
 }
 
 static struct gss_api_ops gss_kerberos_ops = {
index 142438a..6362673 100644 (file)
@@ -147,7 +147,7 @@ void gss_delete_sec_context_null(void *internal_context)
 
 int gss_display_null(struct gss_ctx *gss_context, char *buf, int bufsize)
 {
-       return snprintf(buf, bufsize, "null");
+       return scnprintf(buf, bufsize, "null");
 }
 
 static
index 9406370..1059df7 100644 (file)
@@ -886,7 +886,7 @@ void gss_delete_sec_context_sk(void *internal_context)
 
 int gss_display_sk(struct gss_ctx *gss_context, char *buf, int bufsize)
 {
-       return snprintf(buf, bufsize, "sk");
+       return scnprintf(buf, bufsize, "sk");
 }
 
 static struct gss_api_ops gss_sk_ops = {
index 01e0fa0..67f0579 100644 (file)
@@ -851,22 +851,22 @@ static int ct_copy_xattr(const char *src, const char *dst, int src_fd,
 static int ct_path_lustre(char *buf, int sz, const char *mnt,
                          const struct lu_fid *fid)
 {
-       return snprintf(buf, sz, "%s/%s/fid/"DFID_NOBRACE, mnt,
-                       dot_lustre_name, PFID(fid));
+       return scnprintf(buf, sz, "%s/%s/fid/"DFID_NOBRACE, mnt,
+                        dot_lustre_name, PFID(fid));
 }
 
 static int ct_path_archive(char *buf, int sz, const char *archive_dir,
                           const struct lu_fid *fid)
 {
-       return snprintf(buf, sz, "%s/%04x/%04x/%04x/%04x/%04x/%04x/"
-                       DFID_NOBRACE, archive_dir,
-                       (fid)->f_oid       & 0xFFFF,
-                       (fid)->f_oid >> 16 & 0xFFFF,
-                       (unsigned int)((fid)->f_seq       & 0xFFFF),
-                       (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
-                       (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
-                       (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
-                       PFID(fid));
+       return scnprintf(buf, sz, "%s/%04x/%04x/%04x/%04x/%04x/%04x/"
+                        DFID_NOBRACE, archive_dir,
+                        (fid)->f_oid       & 0xFFFF,
+                        (fid)->f_oid >> 16 & 0xFFFF,
+                        (unsigned int)((fid)->f_seq       & 0xFFFF),
+                        (unsigned int)((fid)->f_seq >> 16 & 0xFFFF),
+                        (unsigned int)((fid)->f_seq >> 32 & 0xFFFF),
+                        (unsigned int)((fid)->f_seq >> 48 & 0xFFFF),
+                        PFID(fid));
 }
 
 static bool ct_is_retryable(int err)