Many const fixes throughout the stack (although these are not all, yet)

This commit is contained in:
goldsimon
2015-04-22 10:29:43 +02:00
parent 0142f113a3
commit 902d190a11
15 changed files with 134 additions and 111 deletions

View File

@@ -70,7 +70,7 @@
extern "C" {
#endif
u16_t inet_chksum(void *dataptr, u16_t len);
u16_t inet_chksum(const void *dataptr, u16_t len);
u16_t inet_chksum_pbuf(struct pbuf *p);
#if LWIP_CHKSUM_COPY_ALGORITHM
u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len);

View File

@@ -212,10 +212,10 @@ u8_t ip4_addr_netmask_valid(u32_t netmask);
ipaddr != NULL ? ip4_addr4_16(ipaddr) : 0))
/* Get one byte from the 4-byte address */
#define ip4_addr1(ipaddr) (((u8_t*)(ipaddr))[0])
#define ip4_addr2(ipaddr) (((u8_t*)(ipaddr))[1])
#define ip4_addr3(ipaddr) (((u8_t*)(ipaddr))[2])
#define ip4_addr4(ipaddr) (((u8_t*)(ipaddr))[3])
#define ip4_addr1(ipaddr) (((const u8_t*)(ipaddr))[0])
#define ip4_addr2(ipaddr) (((const u8_t*)(ipaddr))[1])
#define ip4_addr3(ipaddr) (((const u8_t*)(ipaddr))[2])
#define ip4_addr4(ipaddr) (((const u8_t*)(ipaddr))[3])
/* These are cast to u16_t, with the intent that they are often arguments
* to printf using the U16_F format from cc.h. */
#define ip4_addr1_16(ipaddr) ((u16_t)ip4_addr1(ipaddr))

View File

@@ -119,6 +119,19 @@ struct pbuf {
u16_t ref;
};
/** Helper struct for const-correctness only.
* The only meaning of this one is to provide a const payload pointer
* for PBUF_ROM type.
*/
struct pbuf_rom {
/** next pbuf in singly linked pbuf chain */
struct pbuf *next;
/** pointer to the actual data in the buffer */
const void *payload;
};
#if LWIP_SUPPORT_CUSTOM_PBUF
/** Prototype for a function to free a custom pbuf */
typedef void (*pbuf_free_custom_fn)(struct pbuf *p);

View File

@@ -90,7 +90,7 @@ err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length);
err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value);
err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value);
err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, const s32_t *ident);
err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw);
err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, const u8_t *raw);
#ifdef __cplusplus
}

View File

@@ -138,7 +138,7 @@ struct mib_array_node
/* additional struct members */
const s32_t *objid;
struct mib_node* const *nptr;
const struct mib_node* const *nptr;
};
/** derived node, points to a fixed size mem_malloced array
@@ -254,8 +254,8 @@ s8_t snmp_mib_node_insert(struct mib_list_rootnode *rn, s32_t objid, struct mib_
s8_t snmp_mib_node_find(struct mib_list_rootnode *rn, s32_t objid, struct mib_list_node **fn);
struct mib_list_rootnode *snmp_mib_node_delete(struct mib_list_rootnode *rn, struct mib_list_node *n);
struct mib_node* snmp_search_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np);
struct mib_node* snmp_expand_tree(struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
struct mib_node* snmp_search_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_name_ptr *np);
struct mib_node* snmp_expand_tree(const struct mib_node *node, u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);
u8_t snmp_iso_prefix_tst(u8_t ident_len, s32_t *ident);
u8_t snmp_iso_prefix_expand(u8_t ident_len, s32_t *ident, struct snmp_obj_id *oidret);

View File

@@ -125,7 +125,10 @@ struct lwip_setgetsockopt_data {
#if LWIP_MPU_COMPATIBLE
u8_t optval[LWIP_SETGETSOCKOPT_MAXOPTLEN];
#else
void* optval;
union {
void *p;
const void *pc;
} optval;
#endif
/** size of *optval */
socklen_t optlen;