Commit 15e6d57
authored
Fix unsigned type "size_t" (#4470)
This commit address the wrong use of "size_t" instead of "ssize_t".
The functions that run xattr, like sys_lgetxattr(), sys_lgetxattr()
return negative values on error, that is, they return -1. But some of its users
were found capture this return in an unsigned "size_t" (implict type conversion).
This commit touches the posix xlator files posix-helpers.c and
posix-metadata.c, but also the tests get-mdata-xattr.c
In posix-helpers.c were found posix_cs_set_state, posix_cs_heal_state
and posix_cs_check_status the offending "size_t" in place of "ssize_t" for
the variable "xattrsize".
In posix-metadata.c was found posix_fetch_mdata_xattr and the
variable "size" using an unsigned "size_t" in the exact same way..
In get-mdata-xattr.c, the posix_fetch_mdata_xattr incurs in the
exact same offense with the variable "size".
This commit changes these cases to the signed "ssize_t".
Examples:
always true case
if (fd) {
xattrsize = sys_fgetxattr(*fd, GF_CS_OBJECT_REMOTE, NULL, 0);
if (xattrsize != -1) {
always false case
xattrsize = sys_fgetxattr(*fd, GF_CS_OBJECT_REMOTE, value,
xattrsize + 1);
if (xattrsize == -1) {
if (value)
GF_FREE(value);
Signed-off-by: Thales Antunes de Oliveira Barretto <[email protected]>1 parent 7663679 commit 15e6d57
File tree
3 files changed
+5
-5
lines changed- tests/utils
- xlators/storage/posix/src
3 files changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3002 | 3002 | | |
3003 | 3003 | | |
3004 | 3004 | | |
3005 | | - | |
| 3005 | + | |
3006 | 3006 | | |
3007 | 3007 | | |
3008 | 3008 | | |
| |||
3152 | 3152 | | |
3153 | 3153 | | |
3154 | 3154 | | |
3155 | | - | |
| 3155 | + | |
3156 | 3156 | | |
3157 | 3157 | | |
3158 | 3158 | | |
| |||
3253 | 3253 | | |
3254 | 3254 | | |
3255 | 3255 | | |
3256 | | - | |
| 3256 | + | |
3257 | 3257 | | |
3258 | 3258 | | |
3259 | 3259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
0 commit comments