From: Paul Floyd Date: Sun, 1 Oct 2023 18:51:59 +0000 (+0200) Subject: coverity: most of the remaining unsigned >= 0 comparison warnings X-Git-Tag: VALGRIND_3_22_0~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a82d6201eaf0324cd71f85d688af9fd8a084a705;p=thirdparty%2Fvalgrind.git coverity: most of the remaining unsigned >= 0 comparison warnings --- diff --git a/VEX/priv/guest_arm_toIR.c b/VEX/priv/guest_arm_toIR.c index 5e9e49568c..58d4ed6b1e 100644 --- a/VEX/priv/guest_arm_toIR.c +++ b/VEX/priv/guest_arm_toIR.c @@ -209,7 +209,7 @@ static inline UShort getUShortLittleEndianly ( const UChar* p ) } static UInt ROR32 ( UInt x, UInt sh ) { - vassert(sh >= 0 && sh < 32); + vassert(sh < 32); if (sh == 0) return x; else diff --git a/VEX/priv/guest_mips_toIR.c b/VEX/priv/guest_mips_toIR.c index 317b49cf79..1285edad0b 100644 --- a/VEX/priv/guest_mips_toIR.c +++ b/VEX/priv/guest_mips_toIR.c @@ -19248,7 +19248,7 @@ static UInt disInstr_MIPS_WRK_Special3(UInt cins, const VexArchInfo* archinfo, size = msb + 1; DIP("dext r%u, r%u, %u, %u", rt, rs, lsb, msb + 1); t1 = newTemp(Ity_I64); - vassert(lsb >= 0 && lsb < 32); + vassert(lsb < 32); vassert(size > 0 && size <= 32); vassert((lsb + size) > 0 && (lsb + size) <= 63); diff --git a/VEX/priv/host_amd64_isel.c b/VEX/priv/host_amd64_isel.c index 7623519617..e15e1e60fb 100644 --- a/VEX/priv/host_amd64_isel.c +++ b/VEX/priv/host_amd64_isel.c @@ -165,7 +165,6 @@ typedef static HReg lookupIRTemp ( ISelEnv* env, IRTemp tmp ) { - vassert(tmp >= 0); vassert(tmp < env->n_vregmap); return env->vregmap[tmp]; } diff --git a/VEX/priv/host_arm64_isel.c b/VEX/priv/host_arm64_isel.c index 82cb2d78c6..4b75a08672 100644 --- a/VEX/priv/host_arm64_isel.c +++ b/VEX/priv/host_arm64_isel.c @@ -112,7 +112,6 @@ typedef static HReg lookupIRTemp ( ISelEnv* env, IRTemp tmp ) { - vassert(tmp >= 0); vassert(tmp < env->n_vregmap); return env->vregmap[tmp]; } diff --git a/VEX/priv/host_arm_isel.c b/VEX/priv/host_arm_isel.c index 891c9f68c2..8b32648438 100644 --- a/VEX/priv/host_arm_isel.c +++ b/VEX/priv/host_arm_isel.c @@ -126,14 +126,12 @@ typedef static HReg lookupIRTemp ( ISelEnv* env, IRTemp tmp ) { - vassert(tmp >= 0); vassert(tmp < env->n_vregmap); return env->vregmap[tmp]; } static void lookupIRTemp64 ( HReg* vrHI, HReg* vrLO, ISelEnv* env, IRTemp tmp ) { - vassert(tmp >= 0); vassert(tmp < env->n_vregmap); vassert(! hregIsInvalid(env->vregmapHI[tmp])); *vrLO = env->vregmap[tmp]; diff --git a/VEX/priv/host_ppc_isel.c b/VEX/priv/host_ppc_isel.c index 34b6afe7cf..ff87ae7ed6 100644 --- a/VEX/priv/host_ppc_isel.c +++ b/VEX/priv/host_ppc_isel.c @@ -300,7 +300,6 @@ typedef static HReg lookupIRTemp ( ISelEnv* env, IRTemp tmp ) { - vassert(tmp >= 0); vassert(tmp < env->n_vregmap); return env->vregmapLo[tmp]; } diff --git a/coregrind/m_debuginfo/image.c b/coregrind/m_debuginfo/image.c index 70c3bd859a..ede8357309 100644 --- a/coregrind/m_debuginfo/image.c +++ b/coregrind/m_debuginfo/image.c @@ -142,7 +142,6 @@ static Bool is_sane_CEnt ( const HChar* who, const DiImage* img, UInt i ) if (!(ce->used == ce->size || ce->used == 0)) goto fail; } else { if (!(ce->size == CACHE_ENTRY_SIZE)) goto fail; - if (!(ce->off >= 0)) goto fail; if (!(ce->off + ce->used <= img->real_size)) goto fail; } return True; diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c index 5456fafb02..9bb60f42ad 100644 --- a/coregrind/m_debuginfo/readelf.c +++ b/coregrind/m_debuginfo/readelf.c @@ -1098,7 +1098,7 @@ void read_elf_symtab__ppc64be_linux( disym.isText = elem->is_text; disym.isIFunc = elem->is_ifunc; disym.isGlobal = elem->is_global; - if (cstr) { ML_(dinfo_free)(cstr); cstr = NULL; } + ML_(dinfo_free)(cstr); vg_assert(disym.pri_name != NULL); ML_(addSym) ( di, &disym ); diff --git a/coregrind/m_syswrap/syswrap-amd64-darwin.c b/coregrind/m_syswrap/syswrap-amd64-darwin.c index 1b22a96d47..5b70e8377c 100644 --- a/coregrind/m_syswrap/syswrap-amd64-darwin.c +++ b/coregrind/m_syswrap/syswrap-amd64-darwin.c @@ -574,7 +574,7 @@ void wqthread_hijack(Addr self, Addr kport, Addr stackaddr, Addr workitem, // Go! /* Same comments as the 'release' in the then-clause. - start_thread_NORETURN calls run_thread_NORETURN calls + start_thread_NORETURN calls run_a_thread_NORETURN calls thread_wrapper which acquires the lock before continuing. Let's hope nothing non-thread-local happens until that point. diff --git a/coregrind/m_transtab.c b/coregrind/m_transtab.c index 789a169dcd..724ea6b1fc 100644 --- a/coregrind/m_transtab.c +++ b/coregrind/m_transtab.c @@ -1152,7 +1152,7 @@ UInt addEClassNo ( /*MOD*/Sector* sec, EClassNo ec, TTEno tteno ) Int old_sz, new_sz, i, r; TTEno *old_ar, *new_ar; - vg_assert(ec >= 0 && ec < ECLASS_N); + vg_assert(ec < ECLASS_N); vg_assert(tteno < N_TTES_PER_SECTOR); if (DEBUG_TRANSTAB) VG_(printf)("ec %d gets %d\n", ec, (Int)tteno); diff --git a/helgrind/hg_wordset.c b/helgrind/hg_wordset.c index 3b780262a6..1f9e30ddcc 100644 --- a/helgrind/hg_wordset.c +++ b/helgrind/hg_wordset.c @@ -489,7 +489,7 @@ void HG_(dieWS) ( WordSetU* wsu, WordSet ws ) Bool HG_(plausibleWS) ( WordSetU* wsu, WordSet ws ) { if (wsu == NULL) return False; - if (ws < 0 || ws >= wsu->ix2vec_used) + if (ws >= wsu->ix2vec_used) return False; return True; } diff --git a/helgrind/libhb_core.c b/helgrind/libhb_core.c index 101624028f..cb3daaa139 100644 --- a/helgrind/libhb_core.c +++ b/helgrind/libhb_core.c @@ -5941,7 +5941,6 @@ static void zsm_swrite64 ( Addr a, SVal svNew ) { CacheLine* cl; UWord cloff, tno; - SizeT i; //UWord toff; stats__cline_swrite64s++; if (UNLIKELY(!aligned64(a))) goto slowcase; diff --git a/mpi/libmpiwrap.c b/mpi/libmpiwrap.c index b277617854..df0a1ae9df 100644 --- a/mpi/libmpiwrap.c +++ b/mpi/libmpiwrap.c @@ -2279,10 +2279,10 @@ long WRAPPER_FOR(PMPI_Init)(int *argc, char ***argv) VALGRIND_GET_ORIG_FN(fn); before("Init"); if (argc) { - check_mem_is_defined_untyped(argc, sizeof(int)); + check_mem_is_defined_untyped(argc, sizeof(*argc)); } if (argc && argv) { - check_mem_is_defined_untyped(*argv, *argc * sizeof(char**)); + check_mem_is_defined_untyped(*argv, *argc * sizeof(**argv)); } if (cONFIG_DER) VALGRIND_DISABLE_ERROR_REPORTING; CALL_FN_W_WW(err, fn, argc,argv);