Skip to content

Commit 5fc1662

Browse files
authored
Fix warning about comparison of integer expressions of different signedness (#53658)
1 parent f9e08f7 commit 5fc1662

8 files changed

+18
-18
lines changed

src/flisp/julia_extensions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ value_t fl_string_only_julia_char(fl_context_t *fl_ctx, value_t *args, uint32_t
405405
uint8_t *s = (uint8_t*)cvalue_data(args[0]);
406406
size_t len = cv_len((cvalue_t*)ptr(args[0]));
407407
uint32_t u = _string_only_julia_char(s, len);
408-
if (u == (uint32_t)-1)
408+
if (u == UINT32_MAX)
409409
return fl_ctx->F;
410410
return fl_list2(fl_ctx, fl_ctx->jl_char_sym, mk_uint32(fl_ctx, u));
411411
}

src/llvm-multiversioning.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ std::pair<uint32_t,GlobalVariable*> CloneCtx::get_reloc_slot(Function *F) const
754754
if (F->isDeclaration()) {
755755
auto extern_decl = extern_relocs.find(F);
756756
assert(extern_decl != extern_relocs.end() && "Missing extern relocation slot!");
757-
return {(uint32_t)-1, extern_decl->second};
757+
return {UINT32_MAX, extern_decl->second};
758758
}
759759
else {
760760
auto id = get_func_id(F);

src/processor.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ JL_UNUSED static uint32_t find_feature_bit(const FeatureName *features, size_t n
389389
return feature.bit;
390390
}
391391
}
392-
return (uint32_t)-1;
392+
return UINT32_MAX;
393393
}
394394

395395
// This is how we save the target identification.
@@ -642,7 +642,7 @@ static inline jl_image_t parse_sysimg(void *hdl, F &&callback)
642642
jl_value_t* rejection_reason = nullptr;
643643
JL_GC_PUSH1(&rejection_reason);
644644
uint32_t target_idx = callback(ids, &rejection_reason);
645-
if (target_idx == (uint32_t)-1) {
645+
if (target_idx == UINT32_MAX) {
646646
jl_error(jl_string_ptr(rejection_reason));
647647
}
648648
JL_GC_POP();
@@ -856,7 +856,7 @@ static inline void check_cmdline(T &&cmdline, bool imaging)
856856
}
857857

858858
struct SysimgMatch {
859-
uint32_t best_idx{(uint32_t)-1};
859+
uint32_t best_idx{UINT32_MAX};
860860
int vreg_size{0};
861861
};
862862

@@ -911,7 +911,7 @@ static inline SysimgMatch match_sysimg_targets(S &&sysimg, T &&target, F &&max_v
911911
feature_size = new_feature_size;
912912
rejection_reasons.push_back("Updating best match to this target\n");
913913
}
914-
if (match.best_idx == (uint32_t)-1) {
914+
if (match.best_idx == UINT32_MAX) {
915915
// Construct a nice error message for debugging purposes
916916
std::string error_msg = "Unable to find compatible target in cached code image.\n";
917917
for (size_t i = 0; i < rejection_reasons.size(); i++) {

src/processor_arm.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static constexpr auto feature_masks = get_feature_masks(
207207
#undef JL_FEATURE_DEF
208208
-1);
209209
static const auto real_feature_masks =
210-
feature_masks & FeatureList<feature_sz>{{(uint32_t)-1, (uint32_t)-1, 0}};
210+
feature_masks & FeatureList<feature_sz>{{UINT32_MAX, UINT32_MAX, 0}};
211211

212212
namespace Feature {
213213
enum : uint32_t {
@@ -473,7 +473,7 @@ static constexpr auto feature_masks = get_feature_masks(
473473
#undef JL_FEATURE_DEF
474474
-1);
475475
static const auto real_feature_masks =
476-
feature_masks & FeatureList<feature_sz>{{(uint32_t)-1, (uint32_t)-1, 0}};
476+
feature_masks & FeatureList<feature_sz>{{UINT32_MAX, UINT32_MAX, 0}};
477477

478478
namespace Feature {
479479
enum : uint32_t {
@@ -1522,7 +1522,7 @@ static const llvm::SmallVector<TargetData<feature_sz>, 0> &get_cmdline_targets(v
15221522
}
15231523
#endif
15241524
auto fbit = find_feature_bit(feature_names, nfeature_names, str, len);
1525-
if (fbit == (uint32_t)-1)
1525+
if (fbit == UINT32_MAX)
15261526
return false;
15271527
set_bit(list, fbit, true);
15281528
return true;
@@ -1603,7 +1603,7 @@ static uint32_t sysimg_init_cb(const void *id, jl_value_t **rejection_reason)
16031603
}
16041604
}
16051605
auto match = match_sysimg_targets(sysimg, target, max_vector_size, rejection_reason);
1606-
if (match.best_idx == -1)
1606+
if (match.best_idx == UINT32_MAX)
16071607
return match.best_idx;
16081608
// Now we've decided on which sysimg version to use.
16091609
// Make sure the JIT target is compatible with it and save the JIT target.
@@ -1865,7 +1865,7 @@ JL_DLLEXPORT jl_value_t* jl_check_pkgimage_clones(char *data)
18651865
JL_GC_PUSH1(&rejection_reason);
18661866
uint32_t match_idx = pkgimg_init_cb(data, &rejection_reason);
18671867
JL_GC_POP();
1868-
if (match_idx == (uint32_t)-1)
1868+
if (match_idx == UINT32_MAX)
18691869
return rejection_reason;
18701870
return jl_nothing;
18711871
}

src/processor_fallback.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ JL_DLLEXPORT jl_value_t* jl_check_pkgimage_clones(char *data)
179179
JL_GC_PUSH1(&rejection_reason);
180180
uint32_t match_idx = pkgimg_init_cb(data, &rejection_reason);
181181
JL_GC_POP();
182-
if (match_idx == (uint32_t)-1)
182+
if (match_idx == UINT32_MAX)
183183
return rejection_reason;
184184
return jl_nothing;
185185
}

src/processor_x86.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ static const llvm::SmallVector<TargetData<feature_sz>, 0> &get_cmdline_targets(v
786786
{
787787
auto feature_cb = [] (const char *str, size_t len, FeatureList<feature_sz> &list) {
788788
auto fbit = find_feature_bit(feature_names, nfeature_names, str, len);
789-
if (fbit == (uint32_t)-1)
789+
if (fbit == UINT32_MAX)
790790
return false;
791791
set_bit(list, fbit, true);
792792
return true;
@@ -880,7 +880,7 @@ static uint32_t sysimg_init_cb(const void *id, jl_value_t** rejection_reason)
880880
"https://docs.julialang.org/en/v1/devdocs/sysimg/ for more.");
881881
}
882882
auto match = match_sysimg_targets(sysimg, target, max_vector_size, rejection_reason);
883-
if (match.best_idx == (uint32_t)-1)
883+
if (match.best_idx == UINT32_MAX)
884884
return match.best_idx;
885885
// Now we've decided on which sysimg version to use.
886886
// Make sure the JIT target is compatible with it and save the JIT target.
@@ -1058,7 +1058,7 @@ JL_DLLEXPORT jl_value_t* jl_check_pkgimage_clones(char *data)
10581058
JL_GC_PUSH1(&rejection_reason);
10591059
uint32_t match_idx = pkgimg_init_cb(data, &rejection_reason);
10601060
JL_GC_POP();
1061-
if (match_idx == (uint32_t)-1)
1061+
if (match_idx == UINT32_MAX)
10621062
return rejection_reason;
10631063
return jl_nothing;
10641064
}

src/smallintset.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static inline size_t jl_intref(const jl_genericmemory_t *arr, size_t idx) JL_NOT
3636
else if (el == jl_memory_uint16_type)
3737
return ignore_tombstone(jl_atomic_load_relaxed(&((_Atomic(uint16_t)*)arr->ptr)[idx]), (uint16_t)-1);
3838
else if (el == jl_memory_uint32_type)
39-
return ignore_tombstone(jl_atomic_load_relaxed(&((_Atomic(uint32_t)*)arr->ptr)[idx]), (uint32_t)-1);
39+
return ignore_tombstone(jl_atomic_load_relaxed(&((_Atomic(uint32_t)*)arr->ptr)[idx]), UINT32_MAX);
4040
else
4141
abort();
4242
}
@@ -53,7 +53,7 @@ static inline size_t jl_intref_acquire(const jl_genericmemory_t *arr, size_t idx
5353
else if (el == jl_memory_uint16_type)
5454
return acquire_tombstone(jl_atomic_load_acquire(&((_Atomic(uint16_t)*)arr->ptr)[idx]), (uint16_t)-1);
5555
else if (el == jl_memory_uint32_type)
56-
return acquire_tombstone(jl_atomic_load_acquire(&((_Atomic(uint32_t)*)arr->ptr)[idx]), (uint32_t)-1);
56+
return acquire_tombstone(jl_atomic_load_acquire(&((_Atomic(uint32_t)*)arr->ptr)[idx]), UINT32_MAX);
5757
else
5858
abort();
5959
}

src/support/utf8.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extern "C" {
1212
/* is c the start of a utf8 sequence? */
1313
#define isutf(c) (((c)&0xC0)!=0x80)
1414

15-
#define UEOF ((uint32_t)-1)
15+
#define UEOF (UINT32_MAX)
1616

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

0 commit comments

Comments
 (0)