[Bugs] [Bug 1193929] GlusterFS can be improved

bugzilla at redhat.com bugzilla at redhat.com
Mon Aug 20 03:12:47 UTC 2018


--- Comment #197 from Worker Ant <bugzilla-bot at gluster.org> ---
COMMIT: https://review.gluster.org/20849 committed in master by "Amar Tumballi"
<amarts at redhat.com> with a commit message- libglusterfs/src/common-utils.c:
strncpy -> sprintf, remove dead code.

strncpy may not be very efficient for sort 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, do a quick calc to see how much we really need and use
snprintf() to copy as much.

Also, move from CALLOC to MALLOC, as we are writing to this newly
allocated memory right away and add terminating null.

Lastly, removed some dead code. I did the same optimization as above
to it, only to find out no one is using it.

Compile-tested only!

Change-Id: Ib91b9a73c3d74c511fd067446b1bf6c2e1802687
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