diff --git a/firmware/Makefile b/firmware/Makefile index 714a823d0..124f6556b 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -75,9 +75,10 @@ OBJS += ../vendor/trezor-crypto/nem.o OBJS += ../vendor/trezor-qrenc/qr_encode.o -# OBJS += protob/pb_common.o -OBJS += protob/pb_decode.o -OBJS += protob/pb_encode.o +OBJS += ../vendor/nanopb/pb_common.o +OBJS += ../vendor/nanopb/pb_decode.o +OBJS += ../vendor/nanopb/pb_encode.o + OBJS += protob/messages.pb.o OBJS += protob/types.pb.o @@ -93,7 +94,7 @@ DEBUG_LINK ?= 0 DEBUG_LOG ?= 0 CFLAGS += -Wno-sequence-point -CFLAGS += -Iprotob -DPB_FIELD_16BIT=1 +CFLAGS += -I../vendor/nanopb -Iprotob -DPB_FIELD_16BIT=1 CFLAGS += -DQR_MAX_VERSION=0 CFLAGS += -DDEBUG_LINK=$(DEBUG_LINK) CFLAGS += -DDEBUG_LOG=$(DEBUG_LOG) diff --git a/firmware/protob/pb.h b/firmware/protob/pb.h deleted file mode 120000 index 835188c42..000000000 --- a/firmware/protob/pb.h +++ /dev/null @@ -1 +0,0 @@ -../../vendor/nanopb/pb.h \ No newline at end of file diff --git a/firmware/protob/pb_decode.c b/firmware/protob/pb_decode.c deleted file mode 120000 index 1114e7da0..000000000 --- a/firmware/protob/pb_decode.c +++ /dev/null @@ -1 +0,0 @@ -../../vendor/nanopb/pb_decode.c \ No newline at end of file diff --git a/firmware/protob/pb_decode.h b/firmware/protob/pb_decode.h deleted file mode 120000 index d25f0ac14..000000000 --- a/firmware/protob/pb_decode.h +++ /dev/null @@ -1 +0,0 @@ -../../vendor/nanopb/pb_decode.h \ No newline at end of file diff --git a/firmware/protob/pb_encode.c b/firmware/protob/pb_encode.c deleted file mode 120000 index aebfbfda3..000000000 --- a/firmware/protob/pb_encode.c +++ /dev/null @@ -1 +0,0 @@ -../../vendor/nanopb/pb_encode.c \ No newline at end of file diff --git a/firmware/protob/pb_encode.h b/firmware/protob/pb_encode.h deleted file mode 120000 index 04b7546e4..000000000 --- a/firmware/protob/pb_encode.h +++ /dev/null @@ -1 +0,0 @@ -../../vendor/nanopb/pb_encode.h \ No newline at end of file diff --git a/firmware/transaction.c b/firmware/transaction.c index 2e8f24664..2e7bbbbaf 100644 --- a/firmware/transaction.c +++ b/firmware/transaction.c @@ -56,8 +56,18 @@ static const uint8_t segwit_header[2] = {0,1}; -#define op_push_size(len) ((len) < 0x4c ? 1 : (len) < 0x100 ? 2 : \ - (len) < 0x10000 ? 3 : 5) +static inline uint32_t op_push_size(uint32_t i) { + if (i < 0x4C) { + return 1; + } + if (i < 0x100) { + return 2; + } + if (i < 0x10000) { + return 3; + } + return 5; +} uint32_t op_push(uint32_t i, uint8_t *out) { if (i < 0x4C) { diff --git a/vendor/nanopb b/vendor/nanopb index 54c34a9fd..71ba4e68d 160000 --- a/vendor/nanopb +++ b/vendor/nanopb @@ -1 +1 @@ -Subproject commit 54c34a9fda152937d4cd0c7fd85c067fca23af75 +Subproject commit 71ba4e68da4b3c986d454e34c4666a82fbdf4176