summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
f00e4d0)
Change-Id: I1dc356839dd3af7141df7dc727d58aa782b69da0
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
scanner_hex(struct scanner *s, uint8_t *out)
{
int i;
scanner_hex(struct scanner *s, uint8_t *out)
{
int i;
- unsigned int result = 0;
for (i = 0, *out = 0; is_xdigit(scanner_peek(s)) && i < 2; i++) {
const char c = scanner_next(s);
const char offset = (c >= '0' && c <= '9' ? '0' :
c >= 'a' && c <= 'f' ? 'a' - 10 : 'A' - 10);
for (i = 0, *out = 0; is_xdigit(scanner_peek(s)) && i < 2; i++) {
const char c = scanner_next(s);
const char offset = (c >= '0' && c <= '9' ? '0' :
c >= 'a' && c <= 'f' ? 'a' - 10 : 'A' - 10);
- result = *out * 16 + c - offset;
- *out = (uint8_t)result;
+ if (*out * 16 + c >= offset)
+ *out = *out * 16 + c - offset;
remaining = info.st_size;
tmp = ret;
remaining = info.st_size;
tmp = ret;
- while ((count = read(fd, tmp, remaining))) {
+ while ((count = read(fd, tmp, remaining)) > 0) {
remaining -= count;
tmp += count;
}
remaining -= count;
tmp += count;
}