summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2f935c1)
Since sig_tbl_bucket_size and key_tbl_key_size are explicitly aligned
at initialization, offset dereferences in the hash table code cannot
possibly be unaligned. However, the compiler is unaware of this fact
and complains on -Wcast-align. This patch modifies the code to use
RTE_PTR_ADD(), thereby silencing the compiler by casting through (void
*).
Signed-off-by: Cyril Chemparathy <cchemparathy@ezchip.com>
Acked-by: Olivier Matz <olivier.matz@6wind.com>
static inline hash_sig_t *
get_sig_tbl_bucket(const struct rte_hash *h, uint32_t bucket_index)
{
static inline hash_sig_t *
get_sig_tbl_bucket(const struct rte_hash *h, uint32_t bucket_index)
{
- return (hash_sig_t *)
- &(h->sig_tbl[bucket_index * h->sig_tbl_bucket_size]);
+ return RTE_PTR_ADD(h->sig_tbl, (bucket_index *
+ h->sig_tbl_bucket_size));
}
/* Returns a pointer to the first key in specified bucket. */
static inline uint8_t *
get_key_tbl_bucket(const struct rte_hash *h, uint32_t bucket_index)
{
}
/* Returns a pointer to the first key in specified bucket. */
static inline uint8_t *
get_key_tbl_bucket(const struct rte_hash *h, uint32_t bucket_index)
{
- return (uint8_t *) &(h->key_tbl[bucket_index * h->bucket_entries *
- h->key_tbl_key_size]);
+ return RTE_PTR_ADD(h->key_tbl, (bucket_index * h->bucket_entries *
+ h->key_tbl_key_size));
}
/* Returns a pointer to a key at a specific position in a specified bucket. */
static inline void *
get_key_from_bucket(const struct rte_hash *h, uint8_t *bkt, uint32_t pos)
{
}
/* Returns a pointer to a key at a specific position in a specified bucket. */
static inline void *
get_key_from_bucket(const struct rte_hash *h, uint8_t *bkt, uint32_t pos)
{
- return (void *) &bkt[pos * h->key_tbl_key_size];
+ return RTE_PTR_ADD(bkt, pos * h->key_tbl_key_size);
}
/* Does integer division with rounding-up of result. */
}
/* Does integer division with rounding-up of result. */