Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress error: cast from pointer to integer of different size #448

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions core/utils/pqueue_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

#include <stdlib.h>
#include <stdint.h>

#include "pqueue_tag.h"
#include "util.h" // For lf_print
Expand All @@ -23,7 +24,10 @@
* element is also the priority. This function is of type pqueue_get_pri_f.
* @param element A pointer to a pqueue_tag_element_t, cast to void*.
*/
static pqueue_pri_t pqueue_tag_get_priority(void* element) { return (pqueue_pri_t)element; }
static pqueue_pri_t pqueue_tag_get_priority(void* element) {
// Suppress "error: cast from pointer to integer of different size" by casting to uintptr_t first.
return (pqueue_pri_t)(uintptr_t)element;
}

/**
* @brief Callback function to determine whether two elements are equivalent.
Expand Down Expand Up @@ -65,7 +69,9 @@ static void pqueue_tag_print_element(void* element) {
// Functions defined in pqueue_tag.h.

int pqueue_tag_compare(pqueue_pri_t priority1, pqueue_pri_t priority2) {
return (lf_tag_compare(((pqueue_tag_element_t*)priority1)->tag, ((pqueue_tag_element_t*)priority2)->tag));
// Suppress "error: cast from pointer to integer of different size" by casting to uintptr_t first.
return (lf_tag_compare(((pqueue_tag_element_t*)(uintptr_t)priority1)->tag,
((pqueue_tag_element_t*)(uintptr_t)priority2)->tag));
}

pqueue_tag_t* pqueue_tag_init(size_t initial_size) {
Expand Down
8 changes: 0 additions & 8 deletions include/core/utils/pqueue_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@ size_t pqueue_size(pqueue_t* q);
*/
int pqueue_insert(pqueue_t* q, void* d);

/**
* Move an existing entry to a different priority.
* @param q the queue
* @param new_pri the new priority
* @param d the entry
*/
void pqueue_change_priority(pqueue_t* q, pqueue_pri_t new_pri, void* d);

/**
* Pop the highest-ranking item from the queue.
* @param q the queue
Expand Down
Loading