]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD: clang-tidy corrections
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 8 Jan 2023 16:52:48 +0000 (17:52 +0100)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sun, 8 Jan 2023 16:52:48 +0000 (17:52 +0100)
coregrind/m_libcfile.c
coregrind/m_scheduler/scheduler.c
coregrind/m_syswrap/syswrap-amd64-freebsd.c
coregrind/m_syswrap/syswrap-x86-freebsd.c

index 4fdfcbd28ba23eed5192c19c0aa1cfa9744decef..95fa4bce4f8a433693828c0a68aa74b9e8f3bae5 100644 (file)
@@ -124,7 +124,8 @@ Bool VG_(resolve_filename) ( Int fd, const HChar** result )
    Int mib[4];
    SysRes sres;
    vki_size_t len;
-   Char *bp, *eb;
+   Char *bp;
+   Char *eb;
    struct vki_kinfo_file *kf;
    static HChar *buf = NULL;
    static SizeT  bufsiz = 0;
@@ -150,14 +151,16 @@ Bool VG_(resolve_filename) ( Int fd, const HChar** result )
    eb = filedesc_buf + len;
    while (bp < eb) {
       kf = (struct vki_kinfo_file *)bp;
-      if (kf->vki_kf_fd == fd)
+      if (kf->vki_kf_fd == fd) {
          break;
+      }
       bp += kf->vki_kf_structsize;
    }
-   if (bp >= eb || *kf->vki_kf_path == '\0')
+   if (bp >= eb || *kf->vki_kf_path == '\0') {
      VG_(strncpy)( buf, "[unknown]", bufsiz );
-   else
+   } else {
      VG_(strncpy)( buf, kf->vki_kf_path, bufsiz );
+   }
    *result = buf;
    return True;
 #else
@@ -210,7 +213,8 @@ Bool VG_(resolve_filename) ( Int fd, const HChar** result )
  * so that filedesc_buf is still valid for fd */
 Bool VG_(resolve_filemode) ( Int fd, Int * result )
 {
-   Char *bp, *eb;
+   Char *bp;
+   Char *eb;
    struct vki_kinfo_file *kf;
 
    /* Walk though the list. */
@@ -218,14 +222,16 @@ Bool VG_(resolve_filemode) ( Int fd, Int * result )
    eb = filedesc_buf + sizeof(filedesc_buf);
    while (bp < eb) {
       kf = (struct vki_kinfo_file *)bp;
-      if (kf->vki_kf_fd == fd)
+      if (kf->vki_kf_fd == fd) {
          break;
+      }
       bp += kf->vki_kf_structsize;
    }
-   if (bp >= eb)
+   if (bp >= eb) {
      *result = -1;
-   else
+   } else {
      *result = kf->vki_kf_flags;
+   }
    return True;
 }
 #else
index 5ecb39076beb8898817211bcf407a398f54b5642..788018c3e957900668c69a836b9f164a4aa9d9d3 100644 (file)
@@ -754,20 +754,20 @@ void VG_(scheduler_init_phase2) ( ThreadId tid_main,
 /* Use gcc's built-in setjmp/longjmp.  longjmp must not restore signal
    mask state, but does need to pass "val" through.  jumped must be a
    volatile UWord. */
-#define SCHEDSETJMP(tid, jumped, stmt)                                 \
-   do {                                                                        \
-      ThreadState * volatile _qq_tst = VG_(get_ThreadState)(tid);      \
-                                                                       \
-      (jumped) = VG_MINIMAL_SETJMP(_qq_tst->sched_jmpbuf);              \
-      if ((jumped) == ((UWord)0)) {                                     \
-        vg_assert(!_qq_tst->sched_jmpbuf_valid);                       \
-        _qq_tst->sched_jmpbuf_valid = True;                            \
-        stmt;                                                          \
-      }        else if (VG_(clo_trace_sched))                                  \
-        VG_(printf)("SCHEDSETJMP(line %d) tid %u, jumped=%lu\n",       \
-                     __LINE__, tid, jumped);                            \
-      vg_assert(_qq_tst->sched_jmpbuf_valid);                          \
-      _qq_tst->sched_jmpbuf_valid = False;                             \
+#define SCHEDSETJMP(tid, jumped, stmt)                            \
+   do {                                                           \
+      ThreadState * volatile _qq_tst = VG_(get_ThreadState)(tid); \
+                                                                  \
+      (jumped) = VG_MINIMAL_SETJMP(_qq_tst->sched_jmpbuf);        \
+      if ((jumped) == ((UWord)0)) {                               \
+         vg_assert(!_qq_tst->sched_jmpbuf_valid);                 \
+         _qq_tst->sched_jmpbuf_valid = True;                      \
+         stmt;                                                    \
+      }        else if (VG_(clo_trace_sched))                           \
+         VG_(printf)("SCHEDSETJMP(line %d) tid %u, jumped=%lu\n", \
+                     __LINE__, tid, jumped);                      \
+      vg_assert(_qq_tst->sched_jmpbuf_valid);                     \
+      _qq_tst->sched_jmpbuf_valid = False;                        \
    } while(0)
 
 
index 52eeb808ccb08d6243724ff66304195c62fe817d..dfbca4d7b5dba55470f3a47d84576899ef034c1a 100644 (file)
@@ -1081,7 +1081,7 @@ PRE(sys_fake_sigreturn)
 {
    ThreadState* tst;
    struct vki_ucontext *uc;
-   int rflags;
+   ULong rflags;
 
    PRINT("sys_sigreturn ( %#" FMT_REGWORD "x )", ARG1);
    PRE_REG_READ1(long, "sigreturn",
@@ -1118,7 +1118,7 @@ PRE(sys_fake_sigreturn)
       the guest registers written by VG_(sigframe_destroy). */
    rflags = LibVEX_GuestAMD64_get_rflags(&tst->arch.vex);
    SET_STATUS_from_SysRes( VG_(mk_SysRes_amd64_freebsd)( tst->arch.vex.guest_RAX,
-                           tst->arch.vex.guest_RDX, (rflags & 1) != 0 ? True : False) );
+                           tst->arch.vex.guest_RDX, (rflags & 1U) != 0U ? True : False) );
 
    /*
     * Signal handler might have changed the signal mask.  Respect that.
index cd7db23646c393806e22a1bd09d510dfd902dab7..e28183d94302606e2abcabcdee6e5d1b628e04cf 100644 (file)
@@ -317,15 +317,16 @@ out:
 /* Translate a struct modify_ldt_ldt_s to a VexGuestX86SegDescr */
 
 static
-void translate_to_hw_format ( /* IN  */ void* base,
-                                        /* OUT */ VexGuestX86SegDescr* out)
+void translate_to_hw_format( /* IN  */ void* base,
+                             /* OUT */ VexGuestX86SegDescr* out)
 {
    UInt entry_1, entry_2;
    UInt base_addr = (UInt) base;
    vg_assert(8 == sizeof(VexGuestX86SegDescr));
 
-   if (0)
+   if (0) {
       VG_(printf)("translate_to_hw_format: base %p\n", base );
+   }
 
    /* Allow LDTs to be cleared by the user. */
    if (base == 0) {
@@ -372,8 +373,9 @@ static void copy_LDT_from_to ( VexGuestX86SegDescr* src,
    Int i;
    vg_assert(src);
    vg_assert(dst);
-   for (i = 0; i < VEX_GUEST_X86_LDT_NENT; i++)
+   for (i = 0; i < VEX_GUEST_X86_LDT_NENT; i++) {
       dst[i] = src[i];
+   }
 }
 
 /* Copy contents between two existing GDTs. */
@@ -383,8 +385,9 @@ static void copy_GDT_from_to ( VexGuestX86SegDescr* src,
    Int i;
    vg_assert(src);
    vg_assert(dst);
-   for (i = 0; i < VEX_GUEST_X86_GDT_NENT; i++)
+   for (i = 0; i < VEX_GUEST_X86_GDT_NENT; i++) {
       dst[i] = src[i];
+   }
 }
 
 /* Free this thread's DTs, if it has any. */
@@ -392,10 +395,11 @@ static void deallocate_LGDTs_for_thread ( VexGuestX86State* vex )
 {
    vg_assert(sizeof(HWord) == sizeof(void*));
 
-   if (0)
+   if (0) {
       VG_(printf)("deallocate_LGDTs_for_thread: "
                   "ldt = 0x%llx, gdt = 0x%llx\n",
                   vex->guest_LDT, vex->guest_GDT );
+   }
 
    if (vex->guest_LDT != (HWord)NULL) {
       free_LDT_or_GDT( (VexGuestX86SegDescr*)vex->guest_LDT );
@@ -432,12 +436,14 @@ static SysRes sys_set_thread_area ( ThreadId tid, Int *idxptr, void *base)
          Wine). */
       for (idx = 1; idx < VEX_GUEST_X86_GDT_NENT; idx++) {
          if (gdt[idx].LdtEnt.Words.word1 == 0
-               && gdt[idx].LdtEnt.Words.word2 == 0)
+               && gdt[idx].LdtEnt.Words.word2 == 0) {
             break;
+         }
       }
 
-      if (idx == VEX_GUEST_X86_GDT_NENT)
+      if (idx == VEX_GUEST_X86_GDT_NENT) {
          return VG_(mk_SysRes_Error)( VKI_ESRCH );
+      }
    } else if (idx < 0 || idx == 0 || idx >= VEX_GUEST_X86_GDT_NENT) {
       /* Similarly, reject attempts to use GDT[0]. */
       return VG_(mk_SysRes_Error)( VKI_EINVAL );