Skip to content

Commit

Permalink
Fix warning about comparison of integer expressions of different sign…
Browse files Browse the repository at this point in the history
…edness (#53658)

(cherry picked from commit 5fc1662)
  • Loading branch information
giordano authored and N5N3 committed Nov 11, 2024
1 parent c60704b commit 69fa7fa
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/flisp/julia_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ value_t fl_string_only_julia_char(fl_context_t *fl_ctx, value_t *args, uint32_t
uint8_t *s = (uint8_t*)cvalue_data(args[0]);
size_t len = cv_len((cvalue_t*)ptr(args[0]));
uint32_t u = _string_only_julia_char(s, len);
if (u == (uint32_t)-1)
if (u == UINT32_MAX)
return fl_ctx->F;
return fl_list2(fl_ctx, fl_ctx->jl_char_sym, mk_uint32(fl_ctx, u));
}
Expand Down
2 changes: 1 addition & 1 deletion src/llvm-multiversioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ std::pair<uint32_t,GlobalVariable*> CloneCtx::get_reloc_slot(Function *F) const
if (F->isDeclaration()) {
auto extern_decl = extern_relocs.find(F);
assert(extern_decl != extern_relocs.end() && "Missing extern relocation slot!");
return {(uint32_t)-1, extern_decl->second};
return {UINT32_MAX, extern_decl->second};
}
else {
auto id = get_func_id(F);
Expand Down
8 changes: 4 additions & 4 deletions src/processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ JL_UNUSED static uint32_t find_feature_bit(const FeatureName *features, size_t n
return feature.bit;
}
}
return (uint32_t)-1;
return UINT32_MAX;
}

// This is how we save the target identification.
Expand Down Expand Up @@ -633,7 +633,7 @@ static inline jl_image_t parse_sysimg(void *hdl, F &&callback)
jl_value_t* rejection_reason = nullptr;
JL_GC_PUSH1(&rejection_reason);
uint32_t target_idx = callback(ids, &rejection_reason);
if (target_idx == (uint32_t)-1) {
if (target_idx == UINT32_MAX) {
jl_error(jl_string_ptr(rejection_reason));
}
JL_GC_POP();
Expand Down Expand Up @@ -851,7 +851,7 @@ static inline void check_cmdline(T &&cmdline, bool imaging)
}

struct SysimgMatch {
uint32_t best_idx{(uint32_t)-1};
uint32_t best_idx{UINT32_MAX};
int vreg_size{0};
};

Expand Down Expand Up @@ -906,7 +906,7 @@ static inline SysimgMatch match_sysimg_targets(S &&sysimg, T &&target, F &&max_v
feature_size = new_feature_size;
rejection_reasons.push_back("Updating best match to this target\n");
}
if (match.best_idx == (uint32_t)-1) {
if (match.best_idx == UINT32_MAX) {
// Construct a nice error message for debugging purposes
std::string error_msg = "Unable to find compatible target in cached code image.\n";
for (size_t i = 0; i < rejection_reasons.size(); i++) {
Expand Down
10 changes: 5 additions & 5 deletions src/processor_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ static constexpr auto feature_masks = get_feature_masks(
#undef JL_FEATURE_DEF
-1);
static const auto real_feature_masks =
feature_masks & FeatureList<feature_sz>{{(uint32_t)-1, (uint32_t)-1, 0}};
feature_masks & FeatureList<feature_sz>{{UINT32_MAX, UINT32_MAX, 0}};

namespace Feature {
enum : uint32_t {
Expand Down Expand Up @@ -461,7 +461,7 @@ static constexpr auto feature_masks = get_feature_masks(
#undef JL_FEATURE_DEF
-1);
static const auto real_feature_masks =
feature_masks & FeatureList<feature_sz>{{(uint32_t)-1, (uint32_t)-1, 0}};
feature_masks & FeatureList<feature_sz>{{UINT32_MAX, UINT32_MAX, 0}};

namespace Feature {
enum : uint32_t {
Expand Down Expand Up @@ -1493,7 +1493,7 @@ static const std::vector<TargetData<feature_sz>> &get_cmdline_targets(void)
}
#endif
auto fbit = find_feature_bit(feature_names, nfeature_names, str, len);
if (fbit == (uint32_t)-1)
if (fbit == UINT32_MAX)
return false;
set_bit(list, fbit, true);
return true;
Expand Down Expand Up @@ -1574,7 +1574,7 @@ static uint32_t sysimg_init_cb(const void *id, jl_value_t **rejection_reason)
}
}
auto match = match_sysimg_targets(sysimg, target, max_vector_size, rejection_reason);
if (match.best_idx == -1)
if (match.best_idx == UINT32_MAX)
return match.best_idx;
// Now we've decided on which sysimg version to use.
// Make sure the JIT target is compatible with it and save the JIT target.
Expand Down Expand Up @@ -1846,7 +1846,7 @@ JL_DLLEXPORT jl_value_t* jl_check_pkgimage_clones(char *data)
JL_GC_PUSH1(&rejection_reason);
uint32_t match_idx = pkgimg_init_cb(data, &rejection_reason);
JL_GC_POP();
if (match_idx == (uint32_t)-1)
if (match_idx == UINT32_MAX)
return rejection_reason;
return jl_nothing;
}
Expand Down
2 changes: 1 addition & 1 deletion src/processor_fallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ JL_DLLEXPORT jl_value_t* jl_check_pkgimage_clones(char *data)
JL_GC_PUSH1(&rejection_reason);
uint32_t match_idx = pkgimg_init_cb(data, &rejection_reason);
JL_GC_POP();
if (match_idx == (uint32_t)-1)
if (match_idx == UINT32_MAX)
return rejection_reason;
return jl_nothing;
}
Expand Down
6 changes: 3 additions & 3 deletions src/processor_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ static const std::vector<TargetData<feature_sz>> &get_cmdline_targets(void)
{
auto feature_cb = [] (const char *str, size_t len, FeatureList<feature_sz> &list) {
auto fbit = find_feature_bit(feature_names, nfeature_names, str, len);
if (fbit == (uint32_t)-1)
if (fbit == UINT32_MAX)
return false;
set_bit(list, fbit, true);
return true;
Expand Down Expand Up @@ -870,7 +870,7 @@ static uint32_t sysimg_init_cb(const void *id, jl_value_t** rejection_reason)
"https://docs.julialang.org/en/v1/devdocs/sysimg/ for more.");
}
auto match = match_sysimg_targets(sysimg, target, max_vector_size, rejection_reason);
if (match.best_idx == (uint32_t)-1)
if (match.best_idx == UINT32_MAX)
return match.best_idx;
// Now we've decided on which sysimg version to use.
// Make sure the JIT target is compatible with it and save the JIT target.
Expand Down Expand Up @@ -1041,7 +1041,7 @@ JL_DLLEXPORT jl_value_t* jl_check_pkgimage_clones(char *data)
JL_GC_PUSH1(&rejection_reason);
uint32_t match_idx = pkgimg_init_cb(data, &rejection_reason);
JL_GC_POP();
if (match_idx == (uint32_t)-1)
if (match_idx == UINT32_MAX)
return rejection_reason;
return jl_nothing;
}
Expand Down
2 changes: 1 addition & 1 deletion src/support/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern "C" {
/* is c the start of a utf8 sequence? */
#define isutf(c) (((c)&0xC0)!=0x80)

#define UEOF ((uint32_t)-1)
#define UEOF (UINT32_MAX)

/* convert UTF-8 data to wide character */
size_t u8_toucs(uint32_t *dest, size_t sz, const char *src, size_t srcsz);
Expand Down

0 comments on commit 69fa7fa

Please sign in to comment.