forked from auracaster/openocd
binarybuffer: simplify the prototype of str_to_buf()
With 'radix' always zero and '_detected_radix' always NULL, drop the two parameters and simplify str_to_buf(). While there: - drop some redundant assert(), - drop the re-check for the base prefix, - simplify str_strip_number_prefix_if_present() and rename it, as the prefix MUST be present, - fix a minor typo, - update the doxygen description of str_to_buf(). Change-Id: I1abdc8ec0587b23881953d3094101c04d5bb1c58 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/8394 Tested-by: jenkins Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
This commit is contained in:
@@ -194,15 +194,14 @@ void *buf_set_buf(const void *src, unsigned src_start,
|
||||
|
||||
/**
|
||||
* Parse an unsigned number (provided as a zero-terminated string)
|
||||
* into a bit buffer whose size is buf_len bits.
|
||||
* into a bit buffer whose size is buf_len bits. The base of the
|
||||
* number is detected between decimal, hexadecimal and octal.
|
||||
* @param str Input number, zero-terminated string
|
||||
* @param _buf Output buffer, allocated by the caller
|
||||
* @param buf_len Output buffer size in bits
|
||||
* @param radix Base of the input number - 16, 10, 8 or 0.
|
||||
* 0 means auto-detect the radix.
|
||||
* @returns Error on invalid or overflowing number
|
||||
*/
|
||||
int str_to_buf(const char *str, void *_buf, unsigned int buf_len,
|
||||
unsigned int radix, unsigned int *_detected_radix);
|
||||
int str_to_buf(const char *str, void *_buf, unsigned int buf_len);
|
||||
|
||||
char *buf_to_hex_str(const void *buf, unsigned size);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user