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)
  • Loading branch information
giordano authored Mar 11, 2024
1 parent f9e08f7 commit 5fc1662
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 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 @@ -754,7 +754,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 @@ -389,7 +389,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 @@ -642,7 +642,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 @@ -856,7 +856,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 @@ -911,7 +911,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 @@ -207,7 +207,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 @@ -473,7 +473,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 @@ -1522,7 +1522,7 @@ static const llvm::SmallVector<TargetData<feature_sz>, 0> &get_cmdline_targets(v
}
#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 @@ -1603,7 +1603,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 @@ -1865,7 +1865,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 @@ -179,7 +179,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 @@ -786,7 +786,7 @@ static const llvm::SmallVector<TargetData<feature_sz>, 0> &get_cmdline_targets(v
{
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 @@ -880,7 +880,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 @@ -1058,7 +1058,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
4 changes: 2 additions & 2 deletions src/smallintset.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static inline size_t jl_intref(const jl_genericmemory_t *arr, size_t idx) JL_NOT
else if (el == jl_memory_uint16_type)
return ignore_tombstone(jl_atomic_load_relaxed(&((_Atomic(uint16_t)*)arr->ptr)[idx]), (uint16_t)-1);
else if (el == jl_memory_uint32_type)
return ignore_tombstone(jl_atomic_load_relaxed(&((_Atomic(uint32_t)*)arr->ptr)[idx]), (uint32_t)-1);
return ignore_tombstone(jl_atomic_load_relaxed(&((_Atomic(uint32_t)*)arr->ptr)[idx]), UINT32_MAX);
else
abort();
}
Expand All @@ -53,7 +53,7 @@ static inline size_t jl_intref_acquire(const jl_genericmemory_t *arr, size_t idx
else if (el == jl_memory_uint16_type)
return acquire_tombstone(jl_atomic_load_acquire(&((_Atomic(uint16_t)*)arr->ptr)[idx]), (uint16_t)-1);
else if (el == jl_memory_uint32_type)
return acquire_tombstone(jl_atomic_load_acquire(&((_Atomic(uint32_t)*)arr->ptr)[idx]), (uint32_t)-1);
return acquire_tombstone(jl_atomic_load_acquire(&((_Atomic(uint32_t)*)arr->ptr)[idx]), UINT32_MAX);
else
abort();
}
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 5fc1662

Please sign in to comment.