[Bugs] [Bug 1193929] GlusterFS can be improved

bugzilla at redhat.com bugzilla at redhat.com
Fri Aug 31 01:28:51 UTC 2018


https://bugzilla.redhat.com/show_bug.cgi?id=1193929



--- Comment #308 from Worker Ant <bugzilla-bot at gluster.org> ---
COMMIT: https://review.gluster.org/20924 committed in master by "Amar Tumballi"
<amarts at redhat.com> with a commit message- bit-rot xlator:
strncpy()->sprintf(), reduce strlen()'s

xlators/features/bit-rot/src/bitd/bit-rot-scrub-status.c
xlators/features/bit-rot/src/stub/bit-rot-stub-helpers.c
xlators/features/bit-rot/src/stub/bit-rot-stub.c
xlators/features/bit-rot/src/stub/bit-rot-stub.h

strncpy may not be very efficient for short strings copied into
a large buffer: If the length of src is less than n,
strncpy() writes additional null bytes to dest to ensure
that a total of n bytes are written.

Instead, use snprintf(). Ensure sprintf() results do not
truncate.

Also:
- save the result of strlen() and re-use it when possible.
- move from strlen to SLEN or sizeof() for const strings.
- move ret from int32 to int.

Compile-tested only!

Change-Id: Ib9b923c45d2d59ac15a105410e8160b252061018
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul at redhat.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.
You are the assignee for the bug.


More information about the Bugs mailing list