From: Tyler Retzlaff <roretzla@linux.microsoft.com>
To: dev@dpdk.org
Cc: anatoly.burakov@intel.com, david.hunt@intel.com,
mb@smartsharesystems.com
Subject: [dpdk-dev] [PATCH v2] eal, power: use UINT64_MAX instead of -1ULL
Date: Mon, 15 Mar 2021 08:36:13 -0700 [thread overview]
Message-ID: <1615822573-12630-1-git-send-email-roretzla@linux.microsoft.com> (raw)
In-Reply-To: <1615333490-15243-1-git-send-email-roretzla@linux.microsoft.com>
use UINT64_MAX instead of -1ULL when manipulating uint64_t masks and
initializing sentinel values.
some compilers generate a warning when applying a '-' to an unsigned
literal so avoid this by initializing with unsigned preprocessor
definitions where appropriate.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
lib/librte_eal/common/eal_common_fbarray.c | 12 ++++++------
lib/librte_power/rte_power_pmd_mgmt.c | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/librte_eal/common/eal_common_fbarray.c b/lib/librte_eal/common/eal_common_fbarray.c
index 592ec5859..3a28a5324 100644
--- a/lib/librte_eal/common/eal_common_fbarray.c
+++ b/lib/librte_eal/common/eal_common_fbarray.c
@@ -138,7 +138,7 @@ find_next_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
*/
last = MASK_LEN_TO_IDX(arr->len);
last_mod = MASK_LEN_TO_MOD(arr->len);
- last_msk = ~(-1ULL << last_mod);
+ last_msk = ~(UINT64_MAX << last_mod);
for (msk_idx = first; msk_idx < msk->n_masks; msk_idx++) {
uint64_t cur_msk, lookahead_msk;
@@ -398,8 +398,8 @@ find_prev_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
first_mod = MASK_LEN_TO_MOD(start);
/* we're going backwards, so mask must start from the top */
ignore_msk = first_mod == MASK_ALIGN - 1 ?
- -1ULL : /* prevent overflow */
- ~(-1ULL << (first_mod + 1));
+ UINT64_MAX : /* prevent overflow */
+ ~(UINT64_MAX << (first_mod + 1));
/* go backwards, include zero */
msk_idx = first;
@@ -513,7 +513,7 @@ find_prev_n(const struct rte_fbarray *arr, unsigned int start, unsigned int n,
* no runs in the space we've lookbehind-scanned
* as well, so skip that on next iteration.
*/
- ignore_msk = -1ULL << need;
+ ignore_msk = UINT64_MAX << need;
msk_idx = lookbehind_idx;
break;
}
@@ -560,8 +560,8 @@ find_prev(const struct rte_fbarray *arr, unsigned int start, bool used)
first_mod = MASK_LEN_TO_MOD(start);
/* we're going backwards, so mask must start from the top */
ignore_msk = first_mod == MASK_ALIGN - 1 ?
- -1ULL : /* prevent overflow */
- ~(-1ULL << (first_mod + 1));
+ UINT64_MAX : /* prevent overflow */
+ ~(UINT64_MAX << (first_mod + 1));
/* go backwards, include zero */
idx = first;
diff --git a/lib/librte_power/rte_power_pmd_mgmt.c b/lib/librte_power/rte_power_pmd_mgmt.c
index 454ef7091..db03cbf42 100644
--- a/lib/librte_power/rte_power_pmd_mgmt.c
+++ b/lib/librte_power/rte_power_pmd_mgmt.c
@@ -111,7 +111,7 @@ clb_umwait(uint16_t port_id, uint16_t qidx, struct rte_mbuf **pkts __rte_unused,
ret = rte_eth_get_monitor_addr(port_id, qidx,
&pmc);
if (ret == 0)
- rte_power_monitor(&pmc, -1ULL);
+ rte_power_monitor(&pmc, UINT64_MAX);
}
q_conf->umwait_in_progress = false;
--
2.30.0.vfs.0.2
next prev parent reply other threads:[~2021-03-15 15:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-09 23:44 [dpdk-dev] [PATCH] eal, power: don't use '-' sign with unsigned literals Tyler Retzlaff
2021-03-12 12:51 ` Burakov, Anatoly
2021-03-12 17:05 ` Tyler Retzlaff
2021-03-12 17:37 ` Bruce Richardson
2021-03-12 18:36 ` Tyler Retzlaff
2021-03-12 18:40 ` Tyler Retzlaff
2021-03-13 9:05 ` Morten Brørup
2021-03-15 15:36 ` Tyler Retzlaff [this message]
2021-03-16 0:13 ` [dpdk-dev] [PATCH v3] eal, power: use UINT64_MAX and UINT32_MAX Tyler Retzlaff
2021-03-16 11:06 ` Morten Brørup
2021-04-01 11:22 ` Burakov, Anatoly
2021-04-19 9:43 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1615822573-12630-1-git-send-email-roretzla@linux.microsoft.com \
--to=roretzla@linux.microsoft.com \
--cc=anatoly.burakov@intel.com \
--cc=david.hunt@intel.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).