mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-23 06:48:16 +00:00
add const where possible (for message parsing)
This commit is contained in:
parent
aaf2631dd6
commit
d7c0fbc379
@ -308,7 +308,7 @@ void msg_process(char type, uint16_t msg_id, const pb_field_t *fields, uint8_t *
|
||||
}
|
||||
}
|
||||
|
||||
void msg_read_common(char type, uint8_t *buf, int len)
|
||||
void msg_read_common(char type, const uint8_t *buf, int len)
|
||||
{
|
||||
static char read_state = READSTATE_IDLE;
|
||||
static uint8_t msg_in[MSG_IN_SIZE];
|
||||
@ -357,7 +357,7 @@ void msg_read_common(char type, uint8_t *buf, int len)
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *msg_out_data(void)
|
||||
const uint8_t *msg_out_data(void)
|
||||
{
|
||||
if (msg_out_start == msg_out_end) return 0;
|
||||
uint8_t *data = msg_out + (msg_out_start * 64);
|
||||
@ -368,7 +368,7 @@ uint8_t *msg_out_data(void)
|
||||
|
||||
#if DEBUG_LINK
|
||||
|
||||
uint8_t *msg_debug_out_data(void)
|
||||
const uint8_t *msg_debug_out_data(void)
|
||||
{
|
||||
if (msg_debug_out_start == msg_debug_out_end) return 0;
|
||||
uint8_t *data = msg_debug_out + (msg_debug_out_start * 64);
|
||||
@ -382,7 +382,7 @@ uint8_t *msg_debug_out_data(void)
|
||||
uint8_t msg_tiny[64];
|
||||
uint16_t msg_tiny_id = 0xFFFF;
|
||||
|
||||
void msg_read_tiny(uint8_t *buf, int len)
|
||||
void msg_read_tiny(const uint8_t *buf, int len)
|
||||
{
|
||||
if (len != 64) return;
|
||||
if (buf[0] != '?' || buf[1] != '#' || buf[2] != '#') {
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#define msg_read(buf, len) msg_read_common('n', (buf), (len))
|
||||
#define msg_write(id, ptr) msg_write_common('n', (id), (ptr))
|
||||
uint8_t *msg_out_data(void);
|
||||
const uint8_t *msg_out_data(void);
|
||||
|
||||
#if DEBUG_LINK
|
||||
|
||||
@ -38,15 +38,15 @@ uint8_t *msg_out_data(void);
|
||||
|
||||
#define msg_debug_read(buf, len) msg_read_common('d', (buf), (len))
|
||||
#define msg_debug_write(id, ptr) msg_write_common('d', (id), (ptr))
|
||||
uint8_t *msg_debug_out_data(void);
|
||||
const uint8_t *msg_debug_out_data(void);
|
||||
|
||||
#endif
|
||||
|
||||
void msg_read_common(char type, uint8_t *buf, int len);
|
||||
void msg_read_common(char type, const uint8_t *buf, int len);
|
||||
bool msg_write_common(char type, uint16_t msg_id, const void *msg_ptr);
|
||||
|
||||
void msg_read_tiny(uint8_t *buf, int len);
|
||||
void msg_debug_read_tiny(uint8_t *buf, int len);
|
||||
void msg_read_tiny(const uint8_t *buf, int len);
|
||||
void msg_debug_read_tiny(const uint8_t *buf, int len);
|
||||
extern uint8_t msg_tiny[64];
|
||||
extern uint16_t msg_tiny_id;
|
||||
|
||||
|
@ -151,7 +151,7 @@ static bool checkreturn pb_readbyte(pb_istream_t *stream, uint8_t *buf)
|
||||
return true;
|
||||
}
|
||||
|
||||
pb_istream_t pb_istream_from_buffer(uint8_t *buf, size_t bufsize)
|
||||
pb_istream_t pb_istream_from_buffer(const uint8_t *buf, size_t bufsize)
|
||||
{
|
||||
pb_istream_t stream;
|
||||
#ifdef PB_BUFFER_ONLY
|
||||
|
@ -37,7 +37,7 @@ struct _pb_istream_t
|
||||
bool (*callback)(pb_istream_t *stream, uint8_t *buf, size_t count);
|
||||
#endif
|
||||
|
||||
void *state; /* Free field for use by callback implementation */
|
||||
const void *state; /* Free field for use by callback implementation */
|
||||
size_t bytes_left;
|
||||
|
||||
#ifndef PB_NO_ERRMSG
|
||||
@ -103,7 +103,7 @@ void pb_release(const pb_field_t fields[], void *dest_struct);
|
||||
* Alternatively, you can use a custom stream that reads directly from e.g.
|
||||
* a file or a network socket.
|
||||
*/
|
||||
pb_istream_t pb_istream_from_buffer(uint8_t *buf, size_t bufsize);
|
||||
pb_istream_t pb_istream_from_buffer(const uint8_t *buf, size_t bufsize);
|
||||
|
||||
/* Function to read from a pb_istream_t. You can use this if you need to
|
||||
* read some custom header data, or to read data in field callbacks.
|
||||
|
@ -391,7 +391,7 @@ void usbInit(void)
|
||||
|
||||
void usbPoll(void)
|
||||
{
|
||||
static uint8_t *data;
|
||||
static const uint8_t *data;
|
||||
// poll read buffer
|
||||
usbd_poll(usbd_dev);
|
||||
// write pending data
|
||||
|
Loading…
Reference in New Issue
Block a user