[hackers] [libgrapheme] Cast pedantically || Laslo Hunhold
commit da1aba6af03c664d5f66480b2252de857a61985b
Author: Laslo Hunhold <dev_AT_frign.de>
AuthorDate: Mon Dec 13 20:16:09 2021 +0100
Commit: Laslo Hunhold <dev_AT_frign.de>
CommitDate: Mon Dec 13 20:16:09 2021 +0100
Cast pedantically
This is mostly to really indicate that an implicit cast is wanted and
the context allows it or to preserve const-correctness.
Signed-off-by: Laslo Hunhold <dev_AT_frign.de>
diff --git a/src/grapheme.c b/src/grapheme.c
index 1cc5ab1..56993af 100644
--- a/src/grapheme.c
+++ b/src/grapheme.c
_AT_@ -17,7 +17,7 @@ bool
lg_grapheme_isbreak(uint_least32_t a, uint_least32_t b, LG_SEGMENTATION_STATE *state)
{
struct lg_internal_heisenstate *p[2] = { 0 };
- int flags = 0;
+ uint_least16_t flags = 0;
bool isbreak = true;
/* set state depending on state pointer */
diff --git a/src/utf8.c b/src/utf8.c
index 12e9a35..fe75eaa 100644
--- a/src/utf8.c
+++ b/src/utf8.c
_AT_@ -161,7 +161,7 @@ lg_utf8_encode(uint_least32_t cp, uint8_t *s, size_t n)
* We do not overwrite the mask because we guaranteed earlier
* that there are no bits higher than the mask allows.
*/
- s[0] = lut[off].lower | (cp >> (6 * off));
+ s[0] = lut[off].lower | (uint8_t)(cp >> (6 * off));
for (i = 1; i <= off; i++) {
/*
diff --git a/src/util.c b/src/util.c
index 16663f8..a46cece 100644
--- a/src/util.c
+++ b/src/util.c
_AT_@ -41,10 +41,10 @@ heisenstate_set(struct lg_internal_heisenstate *h, int slot, int state)
static int
cp_cmp(const void *a, const void *b)
{
- uint_least32_t cp = *(uint_least32_t *)a;
- uint_least32_t *range = (uint_least32_t *)b;
+ uint_least32_t cp = *(const uint_least32_t *)a;
+ const uint_least32_t *range = (const uint_least32_t *)b;
- return (cp >= range[0] && cp <= range[1]) ? 0 : (cp - range[0]);
+ return (cp >= range[0] && cp <= range[1]) ? 0 : (int)(cp - range[0]);
}
int
Received on Mon Dec 13 2021 - 20:18:02 CET
This archive was generated by hypermail 2.3.0
: Mon Dec 13 2021 - 20:24:32 CET