From 19e2b15c41d63f455f3230175b7bafa0f2279ed5 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Fri, 24 Jun 2016 21:21:38 +0200 Subject: [PATCH] Fix alignment warnings in snmp agent - we know these structs are aligned according to requirements when they are casted because they have been instantiated as the target type (clang) --- src/apps/snmp/snmp_core.c | 10 +++++----- src/apps/snmp/snmp_scalar.c | 12 ++++++------ src/apps/snmp/snmp_table.c | 8 ++++---- src/apps/snmp/snmp_threadsync.c | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/apps/snmp/snmp_core.c b/src/apps/snmp/snmp_core.c index 4ffad30f..021c820b 100644 --- a/src/apps/snmp/snmp_core.c +++ b/src/apps/snmp/snmp_core.c @@ -636,7 +636,7 @@ snmp_get_node_instance_from_oid(const u32_t *oid, u8_t oid_len, struct snmp_node mn = snmp_mib_tree_resolve_exact(mib, oid, oid_len, &oid_instance_len); if ((mn != NULL) && (mn->node_type != SNMP_NODE_TREE)) { /* get instance */ - const struct snmp_leaf_node* leaf_node = (const struct snmp_leaf_node*)mn; + const struct snmp_leaf_node* leaf_node = (const struct snmp_leaf_node*)(const void*)mn; node_instance->node = mn; snmp_oid_assign(&node_instance->instance_oid, oid + (oid_len - oid_instance_len), oid_instance_len); @@ -715,7 +715,7 @@ snmp_get_next_node_instance_from_oid(const u32_t *oid, u8_t oid_len, snmp_valida node_instance->reference.ptr = NULL; node_instance->reference_len = 0; - result = ((const struct snmp_leaf_node*)mn)->get_next_instance( + result = ((const struct snmp_leaf_node*)(const void*)mn)->get_next_instance( node_oid->id, node_oid->len, node_instance); @@ -883,7 +883,7 @@ snmp_mib_tree_resolve_next(const struct snmp_mib *mib, const u32_t *oid, u8_t oi } /* first build node stack related to passed oid (as far as possible), then go backwards to determine the next node */ - node_stack[nsi] = (const struct snmp_tree_node*)mib->root_node; + node_stack[nsi] = (const struct snmp_tree_node*)(const void*)mib->root_node; while (oid_offset < oid_len) { /* search for matching sub node */ u32_t i = node_stack[nsi]->subnode_count; @@ -901,7 +901,7 @@ snmp_mib_tree_resolve_next(const struct snmp_mib *mib, const u32_t *oid, u8_t oi break; } nsi++; - node_stack[nsi] = (const struct snmp_tree_node*)(*node); + node_stack[nsi] = (const struct snmp_tree_node*)(const void*)(*node); oid_offset++; } @@ -940,7 +940,7 @@ snmp_mib_tree_resolve_next(const struct snmp_mib *mib, const u32_t *oid, u8_t oi if (subnode->node_type == SNMP_NODE_TREE) { /* next is a tree node, go into it and start searching */ nsi++; - node_stack[nsi] = (const struct snmp_tree_node*)subnode; + node_stack[nsi] = (const struct snmp_tree_node*)(const void*)subnode; subnode_oid = 0; } else { /* we found a leaf node -> fill oidret and return it */ diff --git a/src/apps/snmp/snmp_scalar.c b/src/apps/snmp/snmp_scalar.c index e7399986..b566a435 100644 --- a/src/apps/snmp/snmp_scalar.c +++ b/src/apps/snmp/snmp_scalar.c @@ -49,7 +49,7 @@ static snmp_err_t snmp_scalar_array_set_value(struct snmp_node_instance* instan snmp_err_t snmp_scalar_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance) { - const struct snmp_scalar_node* scalar_node = (const struct snmp_scalar_node*)instance->node; + const struct snmp_scalar_node* scalar_node = (const struct snmp_scalar_node*)(const void*)instance->node; LWIP_UNUSED_ARG(root_oid); LWIP_UNUSED_ARG(root_oid_len); @@ -89,7 +89,7 @@ snmp_scalar_array_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct LWIP_UNUSED_ARG(root_oid_len); if ((instance->instance_oid.len == 2) && (instance->instance_oid.id[1] == 0)) { - const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)instance->node; + const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)(const void*)instance->node; const struct snmp_scalar_array_node_def* array_node_def = array_node->array_nodes; u32_t i = 0; @@ -120,7 +120,7 @@ snmp_scalar_array_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_err_t snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance) { - const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)instance->node; + const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)(const void*)instance->node; const struct snmp_scalar_array_node_def* array_node_def = array_node->array_nodes; const struct snmp_scalar_array_node_def* result = NULL; @@ -193,7 +193,7 @@ snmp_scalar_array_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, st static u16_t snmp_scalar_array_get_value(struct snmp_node_instance* instance, void* value) { - const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)instance->node; + const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)(const void*)instance->node; const struct snmp_scalar_array_node_def* array_node_def = (const struct snmp_scalar_array_node_def*)instance->reference.const_ptr; return array_node->get_value(array_node_def, value); @@ -202,7 +202,7 @@ snmp_scalar_array_get_value(struct snmp_node_instance* instance, void* value) static snmp_err_t snmp_scalar_array_set_test(struct snmp_node_instance* instance, u16_t value_len, void* value) { - const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)instance->node; + const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)(const void*)instance->node; const struct snmp_scalar_array_node_def* array_node_def = (const struct snmp_scalar_array_node_def*)instance->reference.const_ptr; return array_node->set_test(array_node_def, value_len, value); @@ -211,7 +211,7 @@ snmp_scalar_array_set_test(struct snmp_node_instance* instance, u16_t value_len, static snmp_err_t snmp_scalar_array_set_value(struct snmp_node_instance* instance, u16_t value_len, void* value) { - const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)instance->node; + const struct snmp_scalar_array_node* array_node = (const struct snmp_scalar_array_node*)(const void*)instance->node; const struct snmp_scalar_array_node_def* array_node_def = (const struct snmp_scalar_array_node_def*)instance->reference.const_ptr; return array_node->set_value(array_node_def, value_len, value); diff --git a/src/apps/snmp/snmp_table.c b/src/apps/snmp/snmp_table.c index fa14448d..e3cc71a4 100644 --- a/src/apps/snmp/snmp_table.c +++ b/src/apps/snmp/snmp_table.c @@ -46,7 +46,7 @@ snmp_err_t snmp_table_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance) { snmp_err_t ret = SNMP_ERR_NOSUCHINSTANCE; - const struct snmp_table_node* table_node = (const struct snmp_table_node*)instance->node; + const struct snmp_table_node* table_node = (const struct snmp_table_node*)(const void*)instance->node; LWIP_UNUSED_ARG(root_oid); LWIP_UNUSED_ARG(root_oid_len); @@ -87,7 +87,7 @@ snmp_err_t snmp_table_get_instance(const u32_t *root_oid, u8_t root_oid_len, str snmp_err_t snmp_table_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance) { - const struct snmp_table_node* table_node = (const struct snmp_table_node*)instance->node; + const struct snmp_table_node* table_node = (const struct snmp_table_node*)(const void*)instance->node; const struct snmp_table_col_def* col_def; struct snmp_obj_id row_oid; u32_t column = 0; @@ -164,7 +164,7 @@ snmp_err_t snmp_table_get_next_instance(const u32_t *root_oid, u8_t root_oid_len snmp_err_t snmp_table_simple_get_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance) { snmp_err_t ret = SNMP_ERR_NOSUCHINSTANCE; - const struct snmp_table_simple_node* table_node = (const struct snmp_table_simple_node*)instance->node; + const struct snmp_table_simple_node* table_node = (const struct snmp_table_simple_node*)(const void*)instance->node; LWIP_UNUSED_ARG(root_oid); LWIP_UNUSED_ARG(root_oid_len); @@ -226,7 +226,7 @@ snmp_err_t snmp_table_simple_get_instance(const u32_t *root_oid, u8_t root_oid_l snmp_err_t snmp_table_simple_get_next_instance(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance) { - const struct snmp_table_simple_node* table_node = (const struct snmp_table_simple_node*)instance->node; + const struct snmp_table_simple_node* table_node = (const struct snmp_table_simple_node*)(const void*)instance->node; const struct snmp_table_simple_col_def* col_def; struct snmp_obj_id row_oid; u32_t column = 0; diff --git a/src/apps/snmp/snmp_threadsync.c b/src/apps/snmp/snmp_threadsync.c index 00f4b472..cbe738f8 100644 --- a/src/apps/snmp/snmp_threadsync.c +++ b/src/apps/snmp/snmp_threadsync.c @@ -139,7 +139,7 @@ static void get_instance_synced(void* ctx) { struct threadsync_data *call_data = (struct threadsync_data*)ctx; - const struct snmp_leaf_node *leaf = (const struct snmp_leaf_node*)call_data->proxy_instance.node; + const struct snmp_leaf_node *leaf = (const struct snmp_leaf_node*)(const void*)call_data->proxy_instance.node; call_data->retval.u8 = leaf->get_instance(call_data->arg1.root_oid, call_data->arg2.root_oid_len, &call_data->proxy_instance); @@ -150,7 +150,7 @@ static void get_next_instance_synced(void* ctx) { struct threadsync_data *call_data = (struct threadsync_data*)ctx; - const struct snmp_leaf_node *leaf = (const struct snmp_leaf_node*)call_data->proxy_instance.node; + const struct snmp_leaf_node *leaf = (const struct snmp_leaf_node*)(const void*)call_data->proxy_instance.node; call_data->retval.u8 = leaf->get_next_instance(call_data->arg1.root_oid, call_data->arg2.root_oid_len, &call_data->proxy_instance); @@ -160,7 +160,7 @@ get_next_instance_synced(void* ctx) static snmp_err_t do_sync(const u32_t *root_oid, u8_t root_oid_len, struct snmp_node_instance* instance, snmp_threadsync_called_fn fn) { - const struct snmp_threadsync_node *threadsync_node = (const struct snmp_threadsync_node*)instance->node; + const struct snmp_threadsync_node *threadsync_node = (const struct snmp_threadsync_node*)(const void*)instance->node; struct threadsync_data *call_data = &threadsync_node->instance->data; if(threadsync_node->node.node.oid != threadsync_node->target->node.oid) {