/* Get hold of a file descriptor which refers to the client
executable. This is needed for attaching to GDB. */
res = VG_(open)(exe_name, VKI_O_RDONLY, VKI_S_IRUSR);
- if (!sr_isError(res))
+ if (!sr_isError(res)) {
VG_(cl_exec_fd) = sr_Res(res);
+ }
/* Copy necessary bits of 'info' that were filled in */
*client_ip = info->init_ip;
HChar** cpp;
HChar** ret;
HChar* preload_tool_path;
- Int envc, i;
+ Int envc;
+ Int i;
/* Alloc space for the vgpreload_core.so path and vgpreload_<tool>.so
paths. We might not need the space for vgpreload_<tool>.so, but it
VG_(debugLog)(2, "initimg", " \"%s\"\n", preload_string);
/* Count the original size of the env */
- if (debug) VG_(printf)("\n\n");
+ if (debug) {
+ VG_(printf)("\n\n");
+ }
envc = 0;
for (cpp = origenv; cpp && *cpp; cpp++) {
envc++;
- if (debug) VG_(printf)("XXXXXXXXX: BEFORE %s\n", *cpp);
+ if (debug) {
+ VG_(printf)("XXXXXXXXX: BEFORE %s\n", *cpp);
+ }
}
/* Allocate a new space */
/* copy it over */
for (cpp = ret; *origenv; ) {
- if (debug) VG_(printf)("XXXXXXXXX: COPY %s\n", *origenv);
+ if (debug) {
+ VG_(printf)("XXXXXXXXX: COPY %s\n", *origenv);
+ }
*cpp++ = *origenv++;
}
*cpp = NULL;
ld_preload_done = True;
}
- if (debug) VG_(printf)("XXXXXXXXX: MASH %s\n", *cpp);
+ if (debug) {
+ VG_(printf)("XXXXXXXXX: MASH %s\n", *cpp);
+ }
}
/* Add the missing bits */
VG_(snprintf)(cp, len, "%s%s", ld_preload, preload_string);
ret[envc++] = cp;
- if (debug) VG_(printf)("XXXXXXXXX: ADD %s\n", cp);
+ if (debug) {
+ VG_(printf)("XXXXXXXXX: ADD %s\n", cp);
+ }
}
#if defined(VGP_x86_freebsd)
/* ret[0 .. envc-1] is live now. */
/* Find and remove a binding for VALGRIND_LAUNCHER. */
- for (i = 0; i < envc; i++)
- if (0 == VG_(memcmp)(ret[i], v_launcher, v_launcher_len))
+ for (i = 0; i < envc; i++) {
+ if (0 == VG_(memcmp)(ret[i], v_launcher, v_launcher_len)) {
break;
+ }
+ }
if (i < envc) {
- for (; i < envc-1; i++)
+ for (; i < envc-1; i++) {
ret[i] = ret[i+1];
+ }
envc--;
}
ret[envc] = NULL;
for (i = 0; i < envc; i++) {
- if (debug) VG_(printf)("XXXXXXXXX: FINAL %s\n", ret[i]);
+ if (debug) {
+ VG_(printf)("XXXXXXXXX: FINAL %s\n", ret[i]);
+ }
}
return ret;
HChar *cp = *tab;
HChar *orig = cp;
- while(*str)
+ while(*str) {
*cp++ = *str++;
+ }
*cp++ = '\0';
- if (0)
+ if (0) {
VG_(printf)("copied %p \"%s\" len %lld\n", (void*)orig, orig, (Long)(cp-orig));
+ }
*tab = cp;
{
sp++; // skip argc (Nb: is word-sized, not int-sized!)
- while (*sp != 0) // skip argv
+ while (*sp != 0) { // skip argv
sp++;
+ }
sp++;
- while (*sp != 0) // skip env
+ while (*sp != 0) { // skip env
sp++;
+ }
sp++;
return (struct auxv *)sp;
}
/* now scan the args we're given... */
- if (have_exename)
+ if (have_exename) {
stringsize += VG_(strlen)( VG_(args_the_exename) ) + 1;
+ }
for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
argc++;
auxsize + /* auxv */
VG_ROUNDUP(stringsize, sizeof(Word)); /* strings (aligned) */
- if (0) VG_(printf)("stacksize = %u\n", stacksize);
+ if (0) {
+ VG_(printf)("stacksize = %u\n", stacksize);
+ }
/* client_SP is the client's stack pointer */
client_SP = clstack_end - stacksize;
/* The max stack size */
clstack_max_size = VG_PGROUNDUP(clstack_max_size);
- if (0)
+ if (0) {
VG_(printf)("stringsize=%u auxsize=%u stacksize=%u maxsize=0x%lx\n"
"clstack_start %p\n"
"clstack_end %p\n",
stringsize, auxsize, stacksize, clstack_max_size,
(void*)clstack_start, (void*)clstack_end);
+ }
/* ==================== allocate space ==================== */
inner_HACK = 1024*1024; // create 1M non-fault-extending stack
# endif
- if (0)
+ if (0) {
VG_(printf)("%#lx 0x%lx %#lx 0x%lx\n",
resvn_start, resvn_size, anon_start, anon_size);
+ }
/* Create a shrinkable reservation followed by an anonymous
segment. Together these constitute a growdown stack. */
/* --- client argv --- */
client_argv = (Word)ptr;
- if (info->interp_name)
+ if (info->interp_name) {
*ptr++ = (Addr)copy_str(&strtab, info->interp_name);
- if (info->interp_args)
+ }
+ if (info->interp_args) {
*ptr++ = (Addr)copy_str(&strtab, info->interp_args);
+ }
- if (have_exename)
+ if (have_exename) {
*ptr++ = (Addr)copy_str(&strtab, VG_(args_the_exename));
+ }
for (i = 0; i < VG_(sizeXA)( VG_(args_for_client) ); i++) {
*ptr++ = (Addr)copy_str(
/* --- envp --- */
VG_(client_envp) = (HChar **)ptr;
- for (cpp = orig_envp; cpp && *cpp; ptr++, cpp++)
+ for (cpp = orig_envp; cpp && *cpp; ptr++, cpp++) {
*ptr = (Addr)copy_str(&strtab, *cpp);
+ }
*ptr++ = 0;
/* --- auxv --- */
auxv->u.a_ptr = copy_str(&strtab, orig_auxv->u.a_ptr);
break;
case VKI_AT_CANARY:
- if (canarylen >= 1)
+ if (canarylen >= 1) {
auxv->u.a_ptr = copy_bytes(&strtab, orig_auxv->u.a_ptr, canarylen);
- else
+ } else {
auxv->a_type = VKI_AT_IGNORE;
+ }
break;
case VKI_AT_PAGESIZES:
- if (pagesizeslen >= 1)
+ if (pagesizeslen >= 1) {
auxv->u.a_ptr = copy_bytes(&strtab, orig_auxv->u.a_ptr, pagesizeslen);
- else
+ } else {
auxv->a_type = VKI_AT_IGNORE;
+ }
break;
#if 0
/*
#endif
case VKI_AT_PHDR:
- if (info->phdr == 0)
+ if (info->phdr == 0) {
auxv->a_type = VKI_AT_IGNORE;
- else
+ } else {
auxv->u.a_val = info->phdr;
+ }
break;
case VKI_AT_PHNUM:
- if (info->phdr == 0)
+ if (info->phdr == 0) {
auxv->a_type = VKI_AT_IGNORE;
- else
+ } else {
auxv->u.a_val = info->phnum;
+ }
break;
case VKI_AT_BASE:
/* client_SP is pointing at client's argc/argv */
- if (0) VG_(printf)("startup SP = %#lx\n", client_SP);
+ if (0) {
+ VG_(printf)("startup SP = %#lx\n", client_SP);
+ }
return client_SP;
}
SmLower,
anon_size
);
- if (ok)
+ if (ok) {
VG_(brk_base) = VG_(brk_limit) = anon_start;
+ }
}
/* that too might have failed, but if it has, we're hosed: there
is no Plan C. */
//--------------------------------------------------------------
VG_(debugLog)(1, "initimg", "Loading client\n");
- if (VG_(args_the_exename) == NULL)
+ if (VG_(args_the_exename) == NULL) {
VG_(err_missing_prog)();
+ }
VG_(memset)(&info, 0, sizeof(info));
SizeT m1 = 1024 * 1024;
SizeT m16 = 16 * m1;
SizeT szB = (SizeT)VG_(client_rlimit_stack).rlim_cur;
- if (szB < m1) szB = m1;
- if (szB > m16) szB = m16;
- if (VG_(clo_main_stacksize) > 0) szB = VG_(clo_main_stacksize);
- if (szB < m1) szB = m1;
+ if (szB < m1) {
+ szB = m1;
+ }
+ if (szB > m16) {
+ szB = m16;
+ }
+ if (VG_(clo_main_stacksize) > 0) {
+ szB = VG_(clo_main_stacksize);
+ }
+ if (szB < m1) {
+ szB = m1;
+ }
szB = VG_PGROUNDUP(szB);
VG_(debugLog)(1, "initimg",
"Setup client stack: size will be %lu\n", szB);
SizeT m8 = 8 * m1;
SizeT dseg_max_size = (SizeT)VG_(client_rlimit_data).rlim_cur;
VG_(debugLog)(1, "initimg", "Setup client data (brk) segment\n");
- if (dseg_max_size < m1) dseg_max_size = m1;
- if (dseg_max_size > m8) dseg_max_size = m8;
+ if (dseg_max_size < m1) {
+ dseg_max_size = m1;
+ }
+ if (dseg_max_size > m8) {
+ dseg_max_size = m8;
+ }
dseg_max_size = VG_PGROUNDUP(dseg_max_size);
setup_client_dataseg( dseg_max_size );
VG_(memset)(&arch->vex_shadow2, 0, sizeof(VexGuestAMD64State));
/* Put essential stuff into the new state. */
- arch->vex.guest_RSP = ((iifii.initial_client_SP - 8) & ~0xFul) + 8;
+ arch->vex.guest_RSP = ((iifii.initial_client_SP - 8) & ~0xFUL) + 8;
arch->vex.guest_RDI = iifii.initial_client_SP;
arch->vex.guest_RIP = iifii.initial_client_IP;
/* make sure we get the CPU lock before doing anything significant */
VG_(acquire_BigLock)(tid, "thread_wrapper(starting new thread)");
- if (0)
+ if (0) {
VG_(printf)("thread tid %u started: stack = %p\n",
tid, (void*)&tid);
+ }
/* Make sure error reporting is enabled in the new thread. */
tst->err_disablement_level = 0;
vg_assert(c >= 1); /* stay sane */
/* Deregister thread's stack. */
- if (tst->os_state.stk_id != NULL_STK_ID)
+ if (tst->os_state.stk_id != NULL_STK_ID) {
VG_(deregister_stack)(tst->os_state.stk_id);
+ }
// Tell the tool this thread is exiting
VG_TRACK( pre_thread_ll_exit, tid );
}
}
- if (0)
+ if (0) {
VG_(printf)( "stack for tid %u at %p; init_SP=%p\n",
tid,
(void*)tst->os_state.valgrind_stack_base,
(void*)tst->os_state.valgrind_stack_init_SP );
+ }
return tst->os_state.valgrind_stack_init_SP;
}
/* parent */
VG_(do_atfork_parent)(tid);
- if (VG_(clo_trace_syscalls))
+ if (VG_(clo_trace_syscalls)) {
VG_(printf)(" clone(fork): process %d created child %lu\n",
VG_(getpid)(), sr_Res(res));
+ }
/* restore signal mask */
VG_(sigprocmask)(VKI_SIG_SETMASK, &fork_saved_mask, NULL);
/* Mark all threads (including this one) to exit. */
for (t = 1; t < VG_N_THREADS; t++) {
- if ( /* not alive */ VG_(threads)[t].status == VgTs_Empty )
+ if ( /* not alive */ VG_(threads)[t].status == VgTs_Empty ) {
continue;
+ }
//VG_(threads)[t].exitreason = VgSrc_ExitThread;
VG_(threads)[t].os_state.exitcode = ARG1;
switch (ARG1) {
case VKI_PTRACE_TRACEME:
- break;
case VKI_PTRACE_READ_I:
case VKI_PTRACE_READ_D:
- break;
-
case VKI_PTRACE_WRITE_I:
case VKI_PTRACE_WRITE_D:
break;
break;
case VKI_PTRACE_CONTINUE:
- break;
-
case VKI_PTRACE_STEP:
- break;
-
case VKI_PTRACE_KILL:
- break;
-
case VKI_PTRACE_ATTACH:
- break;
-
case VKI_PTRACE_DETACH:
break;
case VKI_PTRACE_GETREGS:
- PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_user_regs_struct));
+ PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_user_regs_struct));
break;
case VKI_PTRACE_SETREGS:
- PRE_MEM_READ( "ptrace", ARG3, sizeof(struct vki_user_regs_struct));
+ PRE_MEM_READ("ptrace", ARG3, sizeof(struct vki_user_regs_struct));
break;
case VKI_PTRACE_GETFPREGS:
- PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_fpreg));
+ PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_fpreg));
break;
case VKI_PTRACE_SETFPREGS:
- PRE_MEM_READ( "ptrace", ARG3, sizeof(struct vki_fpreg));
+ PRE_MEM_READ("ptrace", ARG3, sizeof(struct vki_fpreg));
break;
case VKI_PTRACE_GETDBREGS:
- PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_dbreg));
+ PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_dbreg));
break;
case VKI_PTRACE_SETDBREGS:
- PRE_MEM_READ( "ptrace", ARG3, sizeof(struct vki_dbreg));
+ PRE_MEM_READ("ptrace", ARG3, sizeof(struct vki_dbreg));
break;
case VKI_PTRACE_LWPINFO:
- PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_ptrace_lwpinfo));
+ PRE_MEM_WRITE("ptrace", ARG3, sizeof(struct vki_ptrace_lwpinfo));
break;
case VKI_PTRACE_GETNUMLWPS:
break;
case VKI_PTRACE_SETSTEP:
- break;
-
case VKI_PTRACE_CLEARSTEP:
- break;
-
case VKI_PTRACE_SUSPEND:
- break;
-
case VKI_PTRACE_RESUME:
- break;
-
case VKI_PTRACE_TO_SCE:
- break;
-
case VKI_PTRACE_TO_SCX:
- break;
-
case VKI_PTRACE_SYSCALL:
- break;
-
case VKI_PTRACE_VM_TIMESTAMP:
break;
-
case VKI_PTRACE_VM_ENTRY:
PRE_MEM_WRITE( "ptrace", ARG3, sizeof(struct vki_ptrace_vm_entry));
break;
switch (ARG1) {
case VKI_PTRACE_TRACEME:
- break;
case VKI_PTRACE_READ_I:
case VKI_PTRACE_READ_D:
- break;
-
case VKI_PTRACE_WRITE_I:
case VKI_PTRACE_WRITE_D:
break;
switch (io_desc->piod_op) {
case VKI_PIOD_READ_D:
case VKI_PIOD_READ_I:
- if ((Word)RES != -1)
+ if ((Word)RES != -1) {
POST_MEM_WRITE((UWord)io_desc->piod_addr, io_desc->piod_len);
+ }
break;
case VKI_PIOD_WRITE_D:
case VKI_PIOD_WRITE_I:
break;
case VKI_PTRACE_CONTINUE:
- break;
-
case VKI_PTRACE_STEP:
- break;
-
case VKI_PTRACE_KILL:
- break;
-
case VKI_PTRACE_ATTACH:
- break;
-
case VKI_PTRACE_DETACH:
break;
case VKI_PTRACE_GETREGS:
- if ((Word)RES != -1)
+ if ((Word)RES != -1) {
POST_MEM_WRITE(ARG3, sizeof(struct vki_user_regs_struct));
+ }
break;
case VKI_PTRACE_SETREGS:
break;
case VKI_PTRACE_GETFPREGS:
- if ((Word)RES != -1)
+ if ((Word)RES != -1) {
POST_MEM_WRITE(ARG3, sizeof(struct vki_fpreg));
+ }
break;
case VKI_PTRACE_SETFPREGS:
break;
case VKI_PTRACE_GETDBREGS:
- if ((Word)RES != -1)
+ if ((Word)RES != -1) {
POST_MEM_WRITE(ARG3, sizeof(struct vki_dbreg));
+ }
break;
case VKI_PTRACE_SETDBREGS:
break;
case VKI_PTRACE_LWPINFO:
- if ((Word)RES != -1)
+ if ((Word)RES != -1) {
POST_MEM_WRITE(ARG3, sizeof(struct vki_ptrace_lwpinfo));
+ }
break;
case VKI_PTRACE_GETNUMLWPS:
break;
case VKI_PTRACE_GETLWPLIST:
- if ((Word)RES != -1)
+ if ((Word)RES != -1) {
POST_MEM_WRITE(ARG3, sizeof(vki_lwpid_t) * RES);
+ }
break;
case VKI_PTRACE_SETSTEP:
- break;
-
case VKI_PTRACE_CLEARSTEP:
- break;
-
case VKI_PTRACE_SUSPEND:
- break;
-
case VKI_PTRACE_RESUME:
- break;
-
case VKI_PTRACE_TO_SCE:
- break;
-
case VKI_PTRACE_TO_SCX:
- break;
-
case VKI_PTRACE_SYSCALL:
- break;
-
case VKI_PTRACE_VM_TIMESTAMP:
break;
case VKI_PTRACE_VM_ENTRY:
- if ((Word)RES != -1)
+ if ((Word)RES != -1) {
POST_MEM_WRITE(ARG3, sizeof(struct vki_ptrace_vm_entry));
+ }
break;
}
}
/* Check if have not already moaned for this request. */
UInt i;
for (i = 0; i < sizeof(unknown_ioctl)/sizeof(unknown_ioctl[0]); i++) {
- if (unknown_ioctl[i] == ARG2)
+ if (unknown_ioctl[i] == ARG2) {
break;
+ }
if (unknown_ioctl[i] == 0) {
unknown_ioctl[i] = ARG2;
moans--;
}
}
} else {
- if ((dir & _VKI_IOC_WRITE) && size > 0)
+ if ((dir & _VKI_IOC_WRITE) && size > 0) {
PRE_MEM_READ( "ioctl(generic)", ARG3, size);
- if ((dir & _VKI_IOC_READ) && size > 0)
+ }
+ if ((dir & _VKI_IOC_READ) && size > 0) {
PRE_MEM_WRITE( "ioctl(generic)", ARG3, size);
+ }
}
// The block below is from Ryan Stone
UInt size = _VKI_IOC_SIZE(ARG2);
vg_assert(SUCCESS);
if (size > 0 && (dir & _VKI_IOC_READ)
- && RES == 0 && ARG3 != (Addr)NULL)
+ && RES == 0 && ARG3 != (Addr)NULL) {
POST_MEM_WRITE(ARG3, size);
+ }
#if 0
/* Handle specific ioctls which pass structures which may have pointers to other
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
- if (VG_(clo_track_fds))
+ if (VG_(clo_track_fds)) {
ML_(record_fd_open_named)(tid, RES);
+ }
}
} else if (ARG2 == VKI_F_DUPFD_CLOEXEC) {
if (!ML_(fd_allowed)(RES, "fcntl(DUPFD_CLOEXEC)", tid, True)) {
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
- if (VG_(clo_track_fds))
+ if (VG_(clo_track_fds)) {
ML_(record_fd_open_named)(tid, RES);
+ }
}
}
}
POST(sys_rtprio)
{
- if (ARG1 == VKI_RTP_LOOKUP && RES == 0)
+ if (ARG1 == VKI_RTP_LOOKUP && RES == 0) {
POST_MEM_WRITE( ARG3, sizeof(struct vki_rtprio));
+ }
}
// freebsd6_pread 173 FREEBSD_VERS <= 10
int, nbytes,
long *, basep);
PRE_MEM_WRITE( "getdirentries(buf)", ARG2, ARG3 );
- if (ARG4)
+ if (ARG4) {
PRE_MEM_WRITE( "getdirentries(basep)", ARG4, sizeof(long) );
+ }
}
POST(sys_freebsd11_getdirentries)
vg_assert(SUCCESS);
if (RES > 0) {
POST_MEM_WRITE( ARG2, RES );
- if ( ARG4 != 0 )
+ if ( ARG4 != 0 ) {
POST_MEM_WRITE( ARG4, sizeof (long));
+ }
}
}
#else
PRE_MEM_READ("sysctl(name)", (Addr)ARG1, ARG2 * sizeof(int));
// if 'newp' is not NULL can read namelen bytes from that address
- if (ARG5 != (UWord)NULL)
+ if (ARG5 != (UWord)NULL) {
PRE_MEM_READ("sysctl(newp)", (Addr)ARG5, ARG6);
+ }
// there are two scenarios for oldlenp/oldp
// 1. oldval is NULL and oldlenp is non-NULL
if (ARG3 != (UWord)NULL) {
//POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t));
POST_MEM_WRITE((Addr)ARG3, *(vki_size_t *)ARG4);
- } else
+ } else {
POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t));
+ }
}
}
{
PRINT("sys_lutimes ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2);
PRE_REG_READ2(long, "futimes", int, fd, struct timeval *, times);
- if (ARG2 != 0)
+ if (ARG2 != 0) {
PRE_MEM_READ( "futimes(times)", ARG2, sizeof(struct vki_timeval) );
+ }
}
// SYS_getpgid 207
PRE_REG_READ3(void *, "shmat",
int, shmid, const void *, addr, int, flag);
arg2tmp = ML_(generic_PRE_sys_shmat)(tid, ARG1,ARG2,ARG3);
- if (arg2tmp == 0)
+ if (arg2tmp == 0) {
SET_STATUS_Failure( VKI_EINVAL );
- else
+ } else {
ARG2 = arg2tmp;
+ }
}
POST(sys_shmat)
{
PRINT("sys_shmdt ( %#" FMT_REGWORD "x )",ARG1);
PRE_REG_READ1(int, "shmdt", const void *, addr);
- if (!ML_(generic_PRE_sys_shmdt)(tid, ARG1))
+ if (!ML_(generic_PRE_sys_shmdt)(tid, ARG1)) {
SET_STATUS_Failure( VKI_EINVAL );
+ }
}
POST(sys_shmdt)
// defined above!
PRE_REG_READ2(int, "clock_getres",
vki_clockid_t, clock_id, struct timespec *, tp);
- if (ARG2 != 0)
+ if (ARG2 != 0) {
PRE_MEM_WRITE( "clock_getres(tp)", ARG2, sizeof(struct vki_timespec) );
+ }
}
POST(sys_clock_getres)
{
- if (ARG2 != 0)
+ if (ARG2 != 0) {
POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) );
+ }
}
// SYS_ktimer_create 235
PRE_REG_READ3(int, "timer_create",
vki_clockid_t, clockid, struct sigevent *, evp,
vki_timer_t *, timerid);
- if (ARG2 != 0)
+ if (ARG2 != 0) {
PRE_MEM_READ( "timer_create(evp)", ARG2, sizeof(struct vki_sigevent) );
+ }
PRE_MEM_WRITE( "timer_create(timerid)", ARG3, sizeof(vki_timer_t) );
}
struct itimerspec *, ovalue);
PRE_MEM_READ( "timer_settime(value)", ARG3,
sizeof(struct vki_itimerspec) );
- if (ARG4 != 0)
+ if (ARG4 != 0) {
PRE_MEM_WRITE( "timer_settime(ovalue)", ARG4,
sizeof(struct vki_itimerspec) );
+ }
}
POST(sys_timer_settime)
{
- if (ARG4 != 0)
+ if (ARG4 != 0) {
POST_MEM_WRITE( ARG4, sizeof(struct vki_itimerspec) );
+ }
}
// SYS_ktimer_gettime 238
PRE_REG_READ4(int, "clock_nanosleep", clockid_t, clock_id, int, flags,
const struct timespec *, rqtp, struct timespec *, rmtp);
PRE_MEM_READ("clock_nanosleep(rqtp)", ARG1, sizeof(struct vki_timespec));
- if (ARG2 != 0)
+ if (ARG2 != 0) {
PRE_MEM_WRITE( "clock_nanosleep(rmtp)", ARG2, sizeof(struct vki_timespec) );
-
+ }
}
POST(sys_clock_nanosleep)
{
- if (ARG2 != 0)
+ if (ARG2 != 0) {
POST_MEM_WRITE( ARG2, sizeof(struct vki_timespec) );
+ }
}
// SYS_clock_getcpuclockid2 247
PRINT("sys_minherit( %#" FMT_REGWORD "x, %" FMT_REGWORD "u, %" FMT_REGWORD "u )", ARG1,ARG2,ARG3);
PRE_REG_READ3(int, "minherit",
void *, addr, vki_size_t, len, int, inherit);
- if (ARG2 != 0)
+ if (ARG2 != 0) {
PRE_MEM_WRITE( "minherit(addr)", ARG1,ARG2 );
+ }
}
POST(sys_minherit)
{
- if (ARG2 != 0)
+ if (ARG2 != 0) {
POST_MEM_WRITE( ARG1, ARG2 );
+ }
}
// SYS_rfork 251
PRINT("sys_lutimes ( %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,(char *)ARG1,ARG2);
PRE_REG_READ2(int, "lutimes", char *, path, struct timeval *, times);
PRE_MEM_RASCIIZ( "lutimes(path)", ARG1 );
- if (ARG2 != 0)
+ if (ARG2 != 0) {
PRE_MEM_READ( "lutimes(times)", ARG2, sizeof(struct vki_timeval) );
+ }
}
// SYS_freebsd11_nstat 278
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
- if (VG_(clo_track_fds))
+ if (VG_(clo_track_fds)) {
ML_(record_fd_open_nameless)(tid, RES);
+ }
}
}
PRINT("sys_sched_setscheduler ( %" FMT_REGWORD "d, %" FMT_REGWORD "d, %#" FMT_REGWORD "x )", SARG1,SARG2,ARG3);
PRE_REG_READ3(int, "sched_setscheduler",
vki_pid_t, pid, int, policy, struct sched_param *, param);
- if (ARG3 != 0)
+ if (ARG3 != 0) {
PRE_MEM_READ("sched_setscheduler(param)",
ARG3, sizeof(struct vki_sched_param));
+ }
}
// SYS_sched_getscheduler 330
PRINT("sys_sigprocmask ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",ARG1,ARG2,ARG3);
PRE_REG_READ3(int, "sigprocmask",
int, how, vki_sigset_t *, set, vki_sigset_t *, oset);
- if (ARG2 != 0)
+ if (ARG2 != 0) {
PRE_MEM_READ( "sigprocmask(set)", ARG2, sizeof(vki_sigset_t));
- if (ARG3 != 0)
+ }
+ if (ARG3 != 0) {
PRE_MEM_WRITE( "sigprocmask(oset)", ARG3, sizeof(vki_sigset_t));
+ }
if (ARG2 != 0 &&
!ML_(safe_to_deref)((void *)(Addr)ARG2, sizeof(vki_sigset_t))) {
(vki_sigset_t*)(Addr)ARG3));
}
- if (SUCCESS)
+ if (SUCCESS) {
*flags |= SfPollAfter;
+ }
}
POST(sys_sigprocmask)
{
vg_assert(SUCCESS);
- if (RES == 0 && ARG3 != 0)
+ if (RES == 0 && ARG3 != 0) {
POST_MEM_WRITE( ARG3, sizeof(vki_sigset_t));
+ }
}
// SYS_sigsuspend 341
PRE_REG_READ3(int, "sigtimedwait",
const vki_sigset_t *, set, vki_siginfo_t *, info,
const struct timespec *, timeout);
- if (ARG1 != 0)
+ if (ARG1 != 0) {
PRE_MEM_READ( "sigtimedwait(set)", ARG1, sizeof(vki_sigset_t));
- if (ARG2 != 0)
+ }
+ if (ARG2 != 0) {
PRE_MEM_WRITE( "sigtimedwait(info)", ARG2, sizeof(vki_siginfo_t) );
- if (ARG3 != 0)
+ }
+ if (ARG3 != 0) {
PRE_MEM_READ( "sigtimedwait(timeout)",
ARG3, sizeof(struct vki_timespec) );
+ }
}
POST(sys_sigtimedwait)
{
- if (ARG2 != 0)
+ if (ARG2 != 0) {
POST_MEM_WRITE( ARG2, sizeof(vki_siginfo_t) );
+ }
}
// SYS_sigwaitinfo 346
ARG1,ARG2);
PRE_REG_READ2(int, "sigwaitinfo",
const vki_sigset_t *, set, vki_siginfo_t *, info);
- if (ARG1 != 0)
+ if (ARG1 != 0) {
PRE_MEM_READ( "sigwaitinfo(set)", ARG1, sizeof(vki_sigset_t));
- if (ARG2 != 0)
+ }
+ if (ARG2 != 0) {
PRE_MEM_WRITE( "sigwaitinfo(info)", ARG2, sizeof(vki_siginfo_t) );
+ }
}
POST(sys_sigwaitinfo)
{
- if (ARG2 != 0)
+ if (ARG2 != 0) {
POST_MEM_WRITE( ARG2, sizeof(vki_siginfo_t) );
+ }
}
// SYS___acl_get_file 347
int, fd, const struct vki_kevent_freebsd11 *, changelist, int, nchanges,
struct vki_kevent_freebsd11 *, eventlist, int, nevents,
struct timespec *, timeout);
- if (ARG2 != 0 && ARG3 != 0)
+ if (ARG2 != 0 && ARG3 != 0) {
PRE_MEM_READ( "kevent(changelist)", ARG2, sizeof(struct vki_kevent_freebsd11)*ARG3 );
- if (ARG4 != 0 && ARG5 != 0)
+ }
+ if (ARG4 != 0 && ARG5 != 0) {
PRE_MEM_WRITE( "kevent(eventlist)", ARG4, sizeof(struct vki_kevent_freebsd11)*ARG5);
- if (ARG5 != 0)
+ }
+ if (ARG5 != 0) {
*flags |= SfMayBlock;
- if (ARG6 != 0)
+ }
+ if (ARG6 != 0) {
PRE_MEM_READ( "kevent(timeout)",
ARG6, sizeof(struct vki_timespec));
+ }
}
POST(sys_freebsd11_kevent)
{
vg_assert(SUCCESS);
if ((Word)RES != -1) {
- if (ARG4 != 0)
+ if (ARG4 != 0) {
POST_MEM_WRITE( ARG4, sizeof(struct vki_kevent_freebsd11)*RES) ;
+ }
}
}
#else
POST_MEM_WRITE(ARG3, ARG4);
break;
case VKI_KENV_DUMP:
- if (ARG3 != (Addr)NULL)
+ if (ARG3 != (Addr)NULL) {
POST_MEM_WRITE(ARG3, ARG4);
+ }
break;
}
}
POST(sys_uuidgen)
{
- if (SUCCESS)
+ if (SUCCESS) {
POST_MEM_WRITE( ARG1, ARG2 * sizeof(struct vki_uuid) );
+ }
}
// SYS_sendfile 393
// struct sigaction * restrict oact);
PRE(sys_sigaction)
{
- vki_sigaction_toK_t new, *newp;
- vki_sigaction_fromK_t old, *oldp;
+ vki_sigaction_toK_t new;
+ vki_sigaction_toK_t *newp;
+ vki_sigaction_fromK_t old;
+ vki_sigaction_fromK_t *oldp;
PRINT("sys_sigaction ( %" FMT_REGWORD "d, %#" FMT_REGWORD "x, %#" FMT_REGWORD "x )",
SARG1,ARG2,ARG3);
POST(sys_sigaction)
{
vg_assert(SUCCESS);
- if (RES == 0 && ARG3 != 0)
+ if (RES == 0 && ARG3 != 0) {
POST_MEM_WRITE( ARG3, sizeof(struct vki_sigaction));
+ }
}
// SYS_sigreturn 417
POST(sys_swapcontext)
{
- if (SUCCESS)
+ if (SUCCESS) {
POST_MEM_WRITE( ARG1, sizeof(struct vki_ucontext) );
+ }
}
#if (FREEBSD_VERS >= FREEBSD_13_1)
ARG1,ARG2);
PRE_REG_READ2(int, "sigwait",
const vki_sigset_t *, set, int *, sig);
- if (ARG1 != 0)
+ if (ARG1 != 0) {
PRE_MEM_READ( "sigwait(set)", ARG1, sizeof(vki_sigset_t));
- if (ARG2 != 0)
+ }
+ if (ARG2 != 0) {
PRE_MEM_WRITE( "sigwait(sig)", ARG2, sizeof(int));
+ }
}
POST(sys_sigwait)
{
- if (ARG2 != 0)
+ if (ARG2 != 0) {
POST_MEM_WRITE( ARG2, sizeof(int));
+ }
}
// SYS_thr_create 430
/* Check to see if this kill gave us a pending signal */
*flags |= SfPollAfter;
- if (VG_(clo_trace_signals))
+ if (VG_(clo_trace_signals)) {
VG_(message)(Vg_DebugMsg, "thr_kill: sending signal %lu to tid %lu\n",
ARG2, ARG1);
+ }
/* If we're sending SIGKILL, check to see if the target is one of
our threads and handle it specially. */
POST(sys_thr_kill)
{
- if (VG_(clo_trace_signals))
+ if (VG_(clo_trace_signals)) {
VG_(message)(Vg_DebugMsg, "thr_kill: sent signal %lu to tid %lu\n",
ARG2, ARG1);
+ }
}
#if (FREEBSD_VERS <= FREEBSD_10)
POST(sys__umtx_lock)
{
- if (SUCCESS)
+ if (SUCCESS) {
POST_MEM_WRITE(ARG1, sizeof(struct vki_umtx));
+ }
}
// SYS__umtx_unlock 434
POST(sys__umtx_unlock)
{
- if (SUCCESS)
+ if (SUCCESS) {
POST_MEM_WRITE(ARG1, sizeof(struct vki_umtx));
+ }
}
#endif
{
switch(ARG2) {
case VKI_UMTX_OP_LOCK:
- if (SUCCESS)
- POST_MEM_WRITE( ARG1, sizeof(struct vki_umtx) );
- break;
case VKI_UMTX_OP_UNLOCK:
- if (SUCCESS)
+ if (SUCCESS) {
POST_MEM_WRITE( ARG1, sizeof(struct vki_umtx) );
+ }
break;
case VKI_UMTX_OP_WAIT:
case VKI_UMTX_OP_WAKE:
case VKI_UMTX_OP_MUTEX_UNLOCK:
case VKI_UMTX_OP_MUTEX_WAIT: /* Sets/clears contested bits */
case VKI_UMTX_OP_MUTEX_WAKE: /* Sets/clears contested bits */
- if (SUCCESS)
+ if (SUCCESS) {
POST_MEM_WRITE( ARG1, sizeof(struct vki_umutex) );
+ }
break;
case VKI_UMTX_OP_SET_CEILING:
if (SUCCESS) {
POST_MEM_WRITE( ARG1, sizeof(struct vki_umutex) );
- if (ARG4)
+ if (ARG4) {
POST_MEM_WRITE( ARG4, sizeof(vki_uint32_t) );
+ }
}
break;
case VKI_UMTX_OP_CV_WAIT:
}
break;
case VKI_UMTX_OP_CV_SIGNAL:
- if (SUCCESS) {
- POST_MEM_WRITE( ARG1, sizeof(struct vki_ucond) );
- }
- break;
case VKI_UMTX_OP_CV_BROADCAST:
if (SUCCESS) {
POST_MEM_WRITE( ARG1, sizeof(struct vki_ucond) );
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
- if (VG_(clo_track_fds))
+ if (VG_(clo_track_fds)) {
ML_(record_fd_open_with_given_name)(tid, RES, (const HChar*)ARG1);
+ }
}
}
SET_STATUS_Failure( VKI_EBADF );
} else {
PRE_MEM_WRITE( "mq_timedreceive(msg_ptr)", ARG2, ARG3 );
- if (ARG4 != 0)
+ if (ARG4 != 0) {
PRE_MEM_WRITE( "mq_timedreceive(msg_prio)",
ARG4, sizeof(unsigned int) );
- if (ARG5 != 0)
+ }
+ if (ARG5 != 0) {
PRE_MEM_READ( "mq_timedreceive(abs_timeout)",
ARG5, sizeof(struct vki_timespec) );
+ }
}
}
POST(sys_kmq_timedreceive)
{
POST_MEM_WRITE( ARG2, ARG3 );
- if (ARG4 != 0)
+ if (ARG4 != 0) {
POST_MEM_WRITE( ARG4, sizeof(unsigned int) );
+ }
}
// SYS_kmq_timedsend 460
SET_STATUS_Failure( VKI_EBADF );
} else {
PRE_MEM_READ( "mq_timedsend(msg_ptr)", ARG2, ARG3 );
- if (ARG5 != 0)
+ if (ARG5 != 0) {
PRE_MEM_READ( "mq_timedsend(abs_timeout)", ARG5,
sizeof(struct vki_timespec) );
+ }
}
}
PRINT("sys_kmq_notify( %" FMT_REGWORD "u, %#" FMT_REGWORD "x )", ARG1,ARG2 );
PRE_REG_READ2(int, "mq_notify",
vki_mqd_t, mqdes, const struct sigevent *, notification);
- if (!ML_(fd_allowed)(ARG1, "mq_notify", tid, False))
+ if (!ML_(fd_allowed)(ARG1, "mq_notify", tid, False)) {
SET_STATUS_Failure( VKI_EBADF );
- else if (ARG2 != 0)
+ }
+ else if (ARG2 != 0) {
PRE_MEM_READ( "mq_notify(notification)",
ARG2, sizeof(struct vki_sigevent) );
+ }
}
// SYS_kmq_unlink 462
POST(sys_rtprio_thread)
{
- if (ARG1 == VKI_RTP_LOOKUP && RES == 0)
+ if (ARG1 == VKI_RTP_LOOKUP && RES == 0) {
POST_MEM_WRITE( ARG3, sizeof(struct vki_rtprio));
+ }
}
// SYS_sctp_peeloff 471
ML_(pre_mem_read_sockaddr) (tid, "sctp_generic_sendmsg(to)", (struct vki_sockaddr *)ARG4, ARG5);
- if (ARG6 != (Addr)NULL)
+ if (ARG6 != (Addr)NULL) {
PRE_MEM_READ( "sctp_generic_sendmsg(sinfo)", ARG6, sizeof(struct vki_sctp_sndrcvinfo));
+ }
}
// SYS_sctp_generic_sendmsg_iov 473
PRE_MEM_WRITE("sctp_generic_recvmsg(iov.iov_base)", (Addr)iovec->iov_base, iovec->iov_len);
}
- if (ARG4 != (Addr)NULL)
+ if (ARG4 != (Addr)NULL) {
ML_(buf_and_len_pre_check) (tid, ARG4, ARG5,
"sctp_generic_recvmsg(from)",
"sctp_generic_recvmsg(fromlen_in)");
+ }
- if (ARG6 != (Addr)NULL)
+ if (ARG6 != (Addr)NULL) {
PRE_MEM_WRITE("sctp_generic_recvmsg(sinfo)", ARG6, sizeof(struct vki_sctp_sndrcvinfo));
+ }
- if (ARG7 != (Addr)NULL)
+ if (ARG7 != (Addr)NULL) {
PRE_MEM_WRITE("sctp_generic_recvmsg(msgflags)", ARG7, sizeof(int));
+ }
}
POST(sys_sctp_generic_recvmsg)
POST_MEM_WRITE( ARG2, ARG3*sizeof(struct vki_iovec) );
- if (ARG4 != (Addr)NULL)
+ if (ARG4 != (Addr)NULL) {
ML_(buf_and_len_post_check) (tid, VG_(mk_SysRes_Success)(RES), ARG4, ARG5,
"sctp_generic_recvmsg(fromlen_out)");
+ }
- if (ARG6 != (Addr)NULL)
+ if (ARG6 != (Addr)NULL) {
POST_MEM_WRITE(ARG6, sizeof(struct vki_sctp_sndrcvinfo));
+ }
- if (ARG7 != (Addr)NULL)
+ if (ARG7 != (Addr)NULL) {
POST_MEM_WRITE(ARG7, sizeof(int));
+ }
}
// SYS_pread 475
/* Check to see if this kill gave us a pending signal */
*flags |= SfPollAfter;
- if (VG_(clo_trace_signals))
+ if (VG_(clo_trace_signals)) {
VG_(message)(Vg_DebugMsg, "thr_kill2: sending signal %lu to pid %lu/%lu\n",
ARG3, ARG1, ARG2);
+ }
/* If we're sending SIGKILL, check to see if the target is one of
our threads and handle it specially. */
POST(sys_thr_kill2)
{
- if (VG_(clo_trace_signals))
+ if (VG_(clo_trace_signals)) {
VG_(message)(Vg_DebugMsg, "thr_kill2: sent signal %lu to pid %lu/%lu\n",
ARG3, ARG1, ARG2);
+ }
}
// SYS_shm_open 482
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
- if (VG_(clo_track_fds))
+ if (VG_(clo_track_fds)) {
ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG1);
+ }
}
}
if (sr_isError(res)) {
SET_STATUS_Failure(VKI_ENOENT);
return;
- } else {
- char buf[2];
- VG_(read)((Int)sr_Res(res), buf, 2);
- VG_(close)((Int)sr_Res(res));
- if (buf[0] == '#' && buf[1] == '!')
- {
- isScript = True;
- }
+ }
+
+ char buf[2];
+ VG_(read)((Int)sr_Res(res), buf, 2);
+ VG_(close)((Int)sr_Res(res));
+ if (buf[0] == '#' && buf[1] == '!') {
+ isScript = True;
}
if (isScript) {
PRINT("sys_futimesat ( %" FMT_REGWORD "u, %#" FMT_REGWORD "x(%s), %#" FMT_REGWORD "x )", ARG1,ARG2,(char*)ARG2,ARG3);
PRE_REG_READ3(int, "futimesat",
int, fd, const char *, path, struct timeval *, times);
- if (ARG2 != 0)
+ if (ARG2 != 0) {
PRE_MEM_RASCIIZ( "futimesat(path)", ARG2 );
- if (ARG3 != 0)
+ }
+ if (ARG3 != 0) {
PRE_MEM_READ( "futimesat(times)", ARG3, 2 * sizeof(struct vki_timeval) );
+ }
}
// SYS_linkat 495
int, fd, const char *, path, int, flags);
}
- if (ARG1 != (unsigned)VKI_AT_FDCWD && !ML_(fd_allowed)(ARG1, "openat", tid, False))
+ if (ARG1 != (unsigned)VKI_AT_FDCWD && !ML_(fd_allowed)(ARG1, "openat", tid, False)) {
SET_STATUS_Failure( VKI_EBADF );
- else
+ } else {
PRE_MEM_RASCIIZ( "openat(path)", ARG2 );
+ }
/* Otherwise handle normally */
*flags |= SfMayBlock;
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
- if (VG_(clo_track_fds))
+ if (VG_(clo_track_fds)) {
ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG2);
+ }
}
}
SET_STATUS_from_SysRes( VG_(do_syscall2)(__NR_pdfork, ARG1, ARG2) );
- if (!SUCCESS) return;
+ if (!SUCCESS) {
+ return;
+ }
// RES is 0 for child, non-0 (the child's PID) for parent.
is_child = ( RES == 0 ? True : False );
- child_pid = ( is_child ? -1 : RES );
+ child_pid = ( is_child ? -1 : (Int)RES );
if (is_child) {
VG_(do_atfork_child)(tid);
SET_STATUS_from_SysRes(VG_(do_syscall2)(SYSNO, ARG1, ARG2));
- if (VG_(clo_trace_signals))
+ if (VG_(clo_trace_signals)) {
VG_(message)(Vg_DebugMsg, "pdkill: sent signal %ld to fd %ld\n",
SARG2, SARG1);
+ }
/* This kill might have given us a pending signal. Ask for a check once
the syscall is done. */
vki_fd_set *, exceptfds, struct vki_timespec *, timeout,
const sigset_t *, newsigmask);
// XXX: this possibly understates how much memory is read.
- if (ARG2 != 0)
+ if (ARG2 != 0) {
PRE_MEM_READ( "pselect(readfds)",
ARG2, ARG1/8 /* __FD_SETSIZE/8 */ );
- if (ARG3 != 0)
+ }
+ if (ARG3 != 0) {
PRE_MEM_READ( "pselect(writefds)",
ARG3, ARG1/8 /* __FD_SETSIZE/8 */ );
- if (ARG4 != 0)
+ }
+ if (ARG4 != 0) {
PRE_MEM_READ( "pselect(exceptfds)",
ARG4, ARG1/8 /* __FD_SETSIZE/8 */ );
- if (ARG5 != 0)
+ }
+ if (ARG5 != 0) {
PRE_MEM_READ( "pselect(timeout)", ARG5, sizeof(struct vki_timeval) );
+ }
if (ARG6 != 0) {
PRE_MEM_READ( "pselect(sig)", ARG6, sizeof(vki_sigset_t) );
{
int *fildes;
- if (RES != 0)
+ if (RES != 0) {
return;
+ }
POST_MEM_WRITE(ARG1, 2 * sizeof(int));
fildes = (int *)ARG1;
size_t, nbytes,
off_t *, basep);
PRE_MEM_WRITE( "getdirentries(buf)", ARG2, ARG3 );
- if (ARG4)
+ if (ARG4) {
PRE_MEM_WRITE("getdirentries(basep)", ARG4, sizeof (vki_off_t));
+ }
}
POST(sys_getdirentries)
vg_assert(SUCCESS);
if (RES > 0) {
POST_MEM_WRITE( ARG2, RES );
- if ( ARG4 != 0 )
+ if ( ARG4 != 0 ) {
POST_MEM_WRITE( ARG4, sizeof (vki_off_t));
+ }
}
}
// size_t len, unsigned int flags);
PRE(sys_copy_file_range)
{
- PRINT("sys_copy_file_range (%" FMT_REGWORD"d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "d, %" FMT_REGWORD "d)",
- SARG1, ARG2, SARG3, ARG4, (char*)ARG4, SARG5, SARG6);
-
- PRE_REG_READ6(vki_ssize_t, "copy_file_range",
- int, "infd",
- vki_off_t *, "inoffp",
- int, "outfd",
- vki_off_t *, "outoffp",
- vki_size_t, "len",
- unsigned int, "flags");
-
- /* File descriptors are "specially" tracked by valgrind.
- valgrind itself uses some, so make sure someone didn't
- put in one of our own... */
- if (!ML_(fd_allowed)(ARG1, "copy_file_range(infd)", tid, False) ||
- !ML_(fd_allowed)(ARG3, "copy_file_range(infd)", tid, False)) {
- SET_STATUS_Failure( VKI_EBADF );
- } else {
- /* Now see if the offsets are defined. PRE_MEM_READ will
- double check it can dereference them. */
- if (ARG2 != 0)
- PRE_MEM_READ( "copy_file_range(inoffp)", ARG2, sizeof(vki_off_t));
- if (ARG4 != 0)
- PRE_MEM_READ( "copy_file_range(outoffp)", ARG4, sizeof(vki_off_t));
- }
+ PRINT("sys_copy_file_range (%" FMT_REGWORD"d, %#" FMT_REGWORD "x, %" FMT_REGWORD "d, %#" FMT_REGWORD "x(%s), %" FMT_REGWORD "d, %" FMT_REGWORD "d)",
+ SARG1, ARG2, SARG3, ARG4, (char*)ARG4, SARG5, SARG6);
+
+ PRE_REG_READ6(vki_ssize_t, "copy_file_range",
+ int, "infd",
+ vki_off_t *, "inoffp",
+ int, "outfd",
+ vki_off_t *, "outoffp",
+ vki_size_t, "len",
+ unsigned int, "flags");
+
+ /* File descriptors are "specially" tracked by valgrind.
+ valgrind itself uses some, so make sure someone didn't
+ put in one of our own... */
+ if (!ML_(fd_allowed)(ARG1, "copy_file_range(infd)", tid, False) ||
+ !ML_(fd_allowed)(ARG3, "copy_file_range(infd)", tid, False)) {
+ SET_STATUS_Failure( VKI_EBADF );
+ } else {
+ /* Now see if the offsets are defined. PRE_MEM_READ will
+ double check it can dereference them. */
+ if (ARG2 != 0) {
+ PRE_MEM_READ( "copy_file_range(inoffp)", ARG2, sizeof(vki_off_t));
+ }
+ if (ARG4 != 0) {
+ PRE_MEM_READ( "copy_file_range(outoffp)", ARG4, sizeof(vki_off_t));
+ }
+ }
}
PRE_MEM_READ("__sysctlbyname(name)", (Addr)ARG1, ARG2 * sizeof(int));
// if 'newp' is not NULL can read namelen bytes from that addess
- if (ARG5 != (UWord)NULL)
+ if (ARG5 != (UWord)NULL) {
PRE_MEM_READ("__sysctlbyname(newp)", (Addr)ARG5, ARG6);
+ }
// there are two scenarios for oldlenp/oldp
// 1. oldval is NULL and oldlenp is non-NULL
if (ARG3 != (UWord)NULL) {
//POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t));
POST_MEM_WRITE((Addr)ARG3, *(vki_size_t *)ARG4);
- } else
+ } else {
POST_MEM_WRITE((Addr)ARG4, sizeof(vki_size_t));
+ }
}
}
VG_(close)(RES);
SET_STATUS_Failure( VKI_EMFILE );
} else {
- if (VG_(clo_track_fds))
+ if (VG_(clo_track_fds)) {
ML_(record_fd_open_with_given_name)(tid, RES, (HChar*)ARG1);
+ }
}
}