diff options
| author | Ben Pfaff <blp@nicira.com> | 2010-11-15 10:18:10 -0800 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2010-11-15 10:18:10 -0800 |
| commit | bf9712678fc9ec85bf2ac54407e16d76aa22e7b6 (patch) | |
| tree | 2052e512f4606aad7ec50bea03ccf33118e0b44a /lib/nx-match.c | |
| parent | 96fc46e8fdafd6467906e11e0fb493e2b78f2fb5 (diff) | |
| download | openvswitch-bf9712678fc9ec85bf2ac54407e16d76aa22e7b6.tar.gz | |
util: Add function hexits_value() for parsing multiple hex digits.
Suggested-by: Justin Pettit <jpettit@nicira.com>
Diffstat (limited to 'lib/nx-match.c')
| -rw-r--r-- | lib/nx-match.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/nx-match.c b/lib/nx-match.c index 12ea4fb8c..9f869a765 100644 --- a/lib/nx-match.c +++ b/lib/nx-match.c @@ -747,17 +747,15 @@ static const char * parse_hex_bytes(struct ofpbuf *b, const char *s, unsigned int n) { while (n--) { - int low, high; uint8_t byte; + bool ok; s += strspn(s, " "); - low = hexit_value(*s); - high = low < 0 ? low : hexit_value(s[1]); - if (low < 0 || high < 0) { + byte = hexits_value(s, 2, &ok); + if (!ok) { ovs_fatal(0, "%.2s: hex digits expected", s); } - byte = 16 * low + high; ofpbuf_put(b, &byte, 1); s += 2; } |
