diff options
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index fa43c886..3c8eeed4 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -422,16 +422,17 @@ set_mac_nib(int mac_pos, int nib) static uint8_t hextonum(char ch) { - if (ch >= '0' && ch <= '9') + if ((unsigned)(ch - '0') <= 9) return ch - '0'; - else if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 10; - else if (ch >= 'a' && ch <= 'f') + + ch |= 0x20; + + if ((unsigned)(ch - 'a') <= 5) return ch - 'a' + 10; - else if (ch == '?' || ch == 'x' || ch == 'X') - return rhex(); /* random hex value */ + else if (ch == '?' || ch == 'x') + return rhex(); /* random character */ else - return 16; /* error: invalid character */ + return 16; /* invalid character */ } static uint8_t |
