diff options
author | Yaniv Kaul <ykaul@redhat.com> | 2018-08-21 20:42:53 +0300 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-08-31 06:15:46 +0000 |
commit | 7772315bd7d82d5f06f008dfe767f1e597a41b23 (patch) | |
tree | aa766b174482be034228698a994c8bbf9ac32b84 /xlators/storage/posix/src/posix.h | |
parent | dc6e6b71f87f6f89bb0b69816e92779595d716bd (diff) |
multiple xlators (storage/posix): strncpy()->sprintf(), reduce strlen()'s
xlators/storage/posix/src/posix-gfid-path.c
xlators/storage/posix/src/posix-handle.c
xlators/storage/posix/src/posix-helpers.c
xlators/storage/posix/src/posix-inode-fd-ops.c
xlators/storage/posix/src/posix.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().
Also:
- save the result of strlen() and re-use it when possible.
- move from strlen to SLEN (sizeof() ) for const strings.
Compile-tested only!
Change-Id: I056939f111a4ec6bc8ebd539ebcaf9eb67da6c95
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix.h')
-rw-r--r-- | xlators/storage/posix/src/posix.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h index b53afdf4b59..5b013b4b516 100644 --- a/xlators/storage/posix/src/posix.h +++ b/xlators/storage/posix/src/posix.h @@ -300,7 +300,7 @@ typedef struct { char gfid_str[64] = {0}; \ uuid_utoa_r (gfid, gfid_str); \ path_len = strlen (base_path) + 1 + \ - strlen (GF_UNLINK_PATH) + 1 + \ + SLEN (GF_UNLINK_PATH) + 1 + \ strlen (gfid_str) + 1; \ unlink_path = alloca (path_len); \ if (!unlink_path) { \ |