Skip to content

Commit

Permalink
maint: replace 0xffffffff constants with UNIT32_MAX
Browse files Browse the repository at this point in the history
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
  • Loading branch information
jnpkrn committed Dec 20, 2017
1 parent 9812636 commit aed01bb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
22 changes: 11 additions & 11 deletions lib/hdb.c
Expand Up @@ -105,7 +105,7 @@ qb_hdb_handle_create(struct qb_hdb *hdb, int32_t instance_size,
for (i = 0; i < 200; i++) {
check = random();

if (check != 0 && check != 0xffffffff) {
if (check != 0 && check != UINT32_MAX) {
break;
}
}
Expand All @@ -126,7 +126,7 @@ int32_t
qb_hdb_handle_get(struct qb_hdb * hdb, qb_handle_t handle_in, void **instance)
{
uint32_t check = ((uint32_t) (((uint64_t) handle_in) >> 32));
uint32_t handle = handle_in & 0xffffffff;
uint32_t handle = handle_in & UINT32_MAX;
struct qb_hdb_handle *entry;
int32_t handle_count;

Expand All @@ -143,7 +143,7 @@ qb_hdb_handle_get(struct qb_hdb * hdb, qb_handle_t handle_in, void **instance)
return (-EBADF);
}

if (check != 0xffffffff && check != entry->check) {
if (check != UINT32_MAX && check != entry->check) {
return (-EBADF);
}
qb_atomic_int_inc(&entry->ref_count);
Expand All @@ -164,7 +164,7 @@ int32_t
qb_hdb_handle_put(struct qb_hdb * hdb, qb_handle_t handle_in)
{
uint32_t check = ((uint32_t) (((uint64_t) handle_in) >> 32));
uint32_t handle = handle_in & 0xffffffff;
uint32_t handle = handle_in & UINT32_MAX;
struct qb_hdb_handle *entry;
int32_t handle_count;

Expand All @@ -176,7 +176,7 @@ qb_hdb_handle_put(struct qb_hdb * hdb, qb_handle_t handle_in)
}

if (qb_array_index(hdb->handles, handle, (void **)&entry) != 0 ||
(check != 0xffffffff && check != entry->check)) {
(check != UINT32_MAX && check != entry->check)) {
return (-EBADF);
}

Expand All @@ -194,7 +194,7 @@ int32_t
qb_hdb_handle_destroy(struct qb_hdb * hdb, qb_handle_t handle_in)
{
uint32_t check = ((uint32_t) (((uint64_t) handle_in) >> 32));
uint32_t handle = handle_in & 0xffffffff;
uint32_t handle = handle_in & UINT32_MAX;
int32_t res;
struct qb_hdb_handle *entry;
int32_t handle_count;
Expand All @@ -207,7 +207,7 @@ qb_hdb_handle_destroy(struct qb_hdb * hdb, qb_handle_t handle_in)
}

if (qb_array_index(hdb->handles, handle, (void **)&entry) != 0 ||
(check != 0xffffffff && check != entry->check)) {
(check != UINT32_MAX && check != entry->check)) {
return (-EBADF);
}

Expand All @@ -220,7 +220,7 @@ int32_t
qb_hdb_handle_refcount_get(struct qb_hdb * hdb, qb_handle_t handle_in)
{
uint32_t check = ((uint32_t) (((uint64_t) handle_in) >> 32));
uint32_t handle = handle_in & 0xffffffff;
uint32_t handle = handle_in & UINT32_MAX;
struct qb_hdb_handle *entry;
int32_t handle_count;
int32_t refcount = 0;
Expand All @@ -233,7 +233,7 @@ qb_hdb_handle_refcount_get(struct qb_hdb * hdb, qb_handle_t handle_in)
}

if (qb_array_index(hdb->handles, handle, (void **)&entry) != 0 ||
(check != 0xffffffff && check != entry->check)) {
(check != UINT32_MAX && check != entry->check)) {
return (-EBADF);
}

Expand Down Expand Up @@ -279,13 +279,13 @@ qb_hdb_iterator_next(struct qb_hdb *hdb, void **instance, qb_handle_t * handle)
uint32_t
qb_hdb_base_convert(qb_handle_t handle)
{
return (handle & 0xffffffff);
return (handle & UINT32_MAX);
}

uint64_t
qb_hdb_nocheck_convert(uint32_t handle)
{
uint64_t retvalue = 0xffffffffULL << 32 | handle;
uint64_t retvalue = ((uint64_t) UINT32_MAX) << 32 | handle;

return (retvalue);
}
2 changes: 1 addition & 1 deletion lib/loop_poll.c
Expand Up @@ -68,7 +68,7 @@ _poll_entry_check_generate_(struct qb_poll_entry *pe)
for (i = 0; i < 200; i++) {
pe->check = random();

if (pe->check != 0 && pe->check != 0xffffffff) {
if (pe->check != 0 && pe->check != UINT32_MAX) {
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/loop_poll_epoll.c
Expand Up @@ -125,7 +125,7 @@ _poll_entry_from_handle_(struct qb_poll_source *s,
{
int32_t res = 0;
uint32_t check = ((uint32_t) (((uint64_t) handle_in) >> 32));
uint32_t handle = handle_in & 0xffffffff;
uint32_t handle = handle_in & UINT32_MAX;
struct qb_poll_entry *pe;

res = qb_array_index(s->poll_entries, handle, (void **)&pe);
Expand Down
4 changes: 2 additions & 2 deletions lib/loop_timerlist.c
Expand Up @@ -132,7 +132,7 @@ _timer_from_handle_(struct qb_timer_source *s,
}

check = ((uint32_t) (((uint64_t) handle_in) >> 32));
install_pos = handle_in & 0xffffffff;
install_pos = handle_in & UINT32_MAX;

rc = qb_array_index(s->timers, install_pos, (void **)&timer);
if (rc != 0) {
Expand Down Expand Up @@ -205,7 +205,7 @@ qb_loop_timer_add(struct qb_loop * lp,
for (i = 0; i < 200; i++) {
t->check = random();

if (t->check != 0 && t->check != 0xffffffff) {
if (t->check != 0 && t->check != UINT32_MAX) {
break;
}
}
Expand Down

0 comments on commit aed01bb

Please sign in to comment.