Closed pablomh closed 3 years ago
Are you sure that isn't intended to check the null terminator, and trinket should be 8 instead?
(Not that it really matters, we don't expect any trailing characters)
EDIT: To be extra safe you might want to change these to sizeof("trinket")
and sizeof("sm6125")
(hint, they return 8 and 7 respectively) :wink:
I'd rather leave the diff as is because:
a) It's the idiom used along the tree.
b) I'm not sure that property_get
does NULL
-terminate the result, so I'd be more inclined to use strlen
than sizeof
.
I'd rather leave the diff as is because:
a) It's the idiom used along the tree.
Fine I guess; you introduced the piece of code so it's not unnecessarily introducing a diff on top of upstream code.
b) I'm not sure that
property_get
doesNULL
-terminate the result
It sure does, that's the "contract" of C strings! Otherwise functions like strlen
or printf
with %s
will read out of bounds because it looks for the NULL
character.
so I'd be more inclined to use
strlen
thansizeof
.
So 6 it is.
@jerpelea, any opinion?
Obviously the length of "sm6125" is "6" and not "7". Fix the copy/paste error.
Signed-off-by: Pablo Mendez Hernandez pablomh@gmail.com