fix 1wire bugginess with addressing

remotes/github/bad-doublebuf
Ondřej Hruška 7 years ago
parent 887887b675
commit 0b14e5dda4
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 30
      utils/payload_parser.c

@ -1,3 +1,4 @@
#include <debug.h>
#include "payload_parser.h" #include "payload_parser.h"
#define pp_check_capacity(pp, needed) \ #define pp_check_capacity(pp, needed) \
@ -58,32 +59,21 @@ uint32_t pp_u32(PayloadParser *pp)
uint64_t pp_u64(PayloadParser *pp) uint64_t pp_u64(PayloadParser *pp)
{ {
pp_check_capacity(pp, 4); pp_check_capacity(pp, 8);
if (!pp->ok) return 0; if (!pp->ok) return 0;
uint64_t x = 0; uint32_t x0, x1;
uint64_t x;
if (pp->bigendian) { if (pp->bigendian) {
x |= (uint64_t) ((uint64_t) *pp->current++ << 56); x1 = pp_u32(pp);
x |= (uint64_t) ((uint64_t) *pp->current++ << 48); x0 = pp_u32(pp);
x |= (uint64_t) ((uint64_t) *pp->current++ << 40);
x |= (uint64_t) ((uint64_t) *pp->current++ << 32);
x |= (uint64_t) (*pp->current++ << 24);
x |= (uint64_t) (*pp->current++ << 16);
x |= (uint64_t) (*pp->current++ << 8);
x |= *pp->current++;
} else { } else {
x |= *pp->current++; x0 = pp_u32(pp);
x |= (uint64_t) (*pp->current++ << 8); x1 = pp_u32(pp);
x |= (uint64_t) (*pp->current++ << 16);
x |= (uint64_t) (*pp->current++ << 24);
x |= (uint64_t) ((uint64_t) *pp->current++ << 32);
x |= (uint64_t) ((uint64_t) *pp->current++ << 40);
x |= (uint64_t) ((uint64_t) *pp->current++ << 48);
x |= (uint64_t) ((uint64_t) *pp->current++ << 56);
} }
x = ((uint64_t)x1)<<32 | x0;
return x; return x;
} }

Loading…
Cancel
Save