subsys/debug/gdb_server.c
/*
 * Similar to hex_str_to_longlong, but outputs an int and handles negative
 * numbers.
 */
Similar to hex_str_to_longlong, but outputs an int and handles negative
numbers.
Similar to hex_str_to_longlong but outputs an int and handles negative numbers .
static int hex_str_to_int(unsigned char **ptr, int *value)
{
	int num_chars_consumed = 0;
	int hex_value;
	int neg = 0;
	*value = 0;
	if (**ptr == '-') {
		neg = 1;
		(*ptr)++;
		num_chars_consumed++;
	}
	while (**ptr) {
		hex_value = get_hex_char_value(**ptr);
		if (hex_value < 0) {
			break;
		}
		*value = (*value << 4) | hex_value;
		num_chars_consumed++;
		(*ptr)++;
	}
	if (neg) {
		if (num_chars_consumed == 1) {
			(*ptr)--;
			num_chars_consumed = 0;
		} else {
			*value = -(*value);
		}
	}
	return num_chars_consumed;
}
static int hex_str_to_int ( unsigned char * * ptr , int * value ) { int num_chars_consumed = 0 ; int hex_value ; int neg = 0 ; * value = 0 ; if ( * * ptr == ' ' ) { neg = 1 ; ( * ptr ) ++ ; num_chars_consumed ++ ; } while ( * * ptr ) { hex_value = get_hex_char_value ( * * ptr ) ; if ( hex_value < 0 ) { break ; } * value = ( * value << 4 ) | hex_value ; num_chars_consumed ++ ; ( * ptr ) ++ ; } if ( neg ) { if ( num_chars_consumed == 1 ) { ( * ptr ) -- ; num_chars_consumed = 0 ; } else { * value = - ( * value ) ; } } return num_chars_consumed ; }
Similar to hex_str_to_longlong, but outputs an int and handles negative
 numbers.
Similar to hex_str_to_longlong but outputs an int and handles negative numbers .