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)
commita03765b2da70fb9242a622aba3ca4363a63fa656
treed1420e26523f40de583cd4f2ff788dfb8df7bd8e
parent734d6eb11b572a9a2001419a16ae7b0f9ed9643c
LU-6142 lustre: convert snprintf to scnprintf as appropriate

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