MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_hex2dec

Function db_hex2dec

freebsd/ddb/db_command.c:903–920  ·  view source on GitHub ↗

* Take the parsed expression value from the command line that was parsed * as a hexadecimal value and convert it as if the expression was parsed * as a decimal value. Returns -1 if the expression was not a valid * decimal value. */

Source from the content-addressed store, hash-verified

901 * decimal value.
902 */
903db_expr_t
904db_hex2dec(db_expr_t expr)
905{
906 uintptr_t x, y;
907 db_expr_t val;
908
909 y = 1;
910 val = 0;
911 x = expr;
912 while (x != 0) {
913 if (x % 16 > 9)
914 return (-1);
915 val += (x % 16) * (y);
916 x >>= 4;
917 y *= 10;
918 }
919 return (val);
920}

Callers 3

db_lookup_threadFunction · 0.85
db_lookup_procFunction · 0.85
db_resetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected