Skip to content
Commit b34349ee authored by Pisit Sawangvonganan's avatar Pisit Sawangvonganan Committed by Anas Nashif
Browse files

net: utils: improve hex digit character checking in `net_bytes_from_str`



Several refactors and improvements for `net_bytes_from_str` as follows:
- Replaced manual hex digit checks with `isxdigit()`.
- Changed variable `i` from unsigned int to size_t for consistency with
  the `strlen()` return type.
- Added `src_len` to store the result of `strlen(src)` to avoid
  multiple calls to `strlen` in the `for-loop`.
- Ensured casting to `unsigned char` before passing to `isxdigit()` to
  prevent undefined behavior.
- Explicitly cast the result of `strtol()` to `uint8_t` to match
  the buffer type.

Signed-off-by: default avatarPisit Sawangvonganan <pisit@ndrsolution.com>
parent 7b18cc11
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment