Fix statement-before-declaration warnings for the core code.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4906
This commit is contained in:
Tom Hughes 2005-10-12 10:45:27 +00:00
parent c7a4bfb614
commit 6961dcf591
10 changed files with 71 additions and 51 deletions

View File

@ -1630,8 +1630,8 @@ static inline Bool host_is_little_endian ( void )
static Short read_Short ( UChar* data )
{
vg_assert(host_is_little_endian());
Short r = 0;
vg_assert(host_is_little_endian());
r = data[0]
| ( ((UInt)data[1]) << 8 );
return r;
@ -1639,8 +1639,8 @@ static Short read_Short ( UChar* data )
static Int read_Int ( UChar* data )
{
vg_assert(host_is_little_endian());
Int r = 0;
vg_assert(host_is_little_endian());
r = data[0]
| ( ((UInt)data[1]) << 8 )
| ( ((UInt)data[2]) << 16 )
@ -1650,8 +1650,8 @@ static Int read_Int ( UChar* data )
static Long read_Long ( UChar* data )
{
vg_assert(host_is_little_endian());
Long r = 0;
vg_assert(host_is_little_endian());
r = data[0]
| ( ((ULong)data[1]) << 8 )
| ( ((ULong)data[2]) << 16 )
@ -1665,8 +1665,8 @@ static Long read_Long ( UChar* data )
static UShort read_UShort ( UChar* data )
{
vg_assert(host_is_little_endian());
UInt r = 0;
vg_assert(host_is_little_endian());
r = data[0]
| ( ((UInt)data[1]) << 8 );
return r;
@ -1674,8 +1674,8 @@ static UShort read_UShort ( UChar* data )
static UInt read_UInt ( UChar* data )
{
vg_assert(host_is_little_endian());
UInt r = 0;
vg_assert(host_is_little_endian());
r = data[0]
| ( ((UInt)data[1]) << 8 )
| ( ((UInt)data[2]) << 16 )
@ -1685,8 +1685,8 @@ static UInt read_UInt ( UChar* data )
static ULong read_ULong ( UChar* data )
{
vg_assert(host_is_little_endian());
ULong r = 0;
vg_assert(host_is_little_endian());
r = data[0]
| ( ((ULong)data[1]) << 8 )
| ( ((ULong)data[2]) << 16 )
@ -2236,6 +2236,9 @@ void ML_(read_callframe_info_dwarf2)
previously-seen CIE.
*/
while (True) {
UChar* ciefde_start;
UInt ciefde_len;
UInt cie_pointer;
/* Are we done? */
if (data == ehframe + ehframe_sz)
@ -2250,12 +2253,12 @@ void ML_(read_callframe_info_dwarf2)
/* Ok, we must be looking at the start of a new CIE or FDE.
Figure out which it is. */
UChar* ciefde_start = data;
ciefde_start = data;
if (VG_(clo_trace_cfi))
VG_(printf)("\ncie/fde.start = %p (ehframe + 0x%x)\n",
ciefde_start, ciefde_start - ehframe);
UInt ciefde_len = read_UInt(data); data += sizeof(UInt);
ciefde_len = read_UInt(data); data += sizeof(UInt);
if (VG_(clo_trace_cfi))
VG_(printf)("cie/fde.length = %d\n", ciefde_len);
@ -2269,7 +2272,7 @@ void ML_(read_callframe_info_dwarf2)
goto bad;
}
UInt cie_pointer = read_UInt(data);
cie_pointer = read_UInt(data);
data += sizeof(UInt); /* XXX see XXX below */
if (VG_(clo_trace_cfi))
VG_(printf)("cie.pointer = %d\n", cie_pointer);
@ -2277,7 +2280,9 @@ void ML_(read_callframe_info_dwarf2)
/* If cie_pointer is zero, we've got a CIE; else it's an FDE. */
if (cie_pointer == 0) {
Int this_CIE;
Int this_CIE;
UChar cie_version;
UChar* cie_augmentation;
/* --------- CIE --------- */
if (VG_(clo_trace_cfi))
@ -2299,7 +2304,7 @@ void ML_(read_callframe_info_dwarf2)
later when looking at an FDE. */
the_CIEs[this_CIE].offset = ciefde_start - ehframe;
UChar cie_version = read_UChar(data); data += sizeof(UChar);
cie_version = read_UChar(data); data += sizeof(UChar);
if (VG_(clo_trace_cfi))
VG_(printf)("cie.version = %d\n", (Int)cie_version);
if (cie_version != 1) {
@ -2307,7 +2312,7 @@ void ML_(read_callframe_info_dwarf2)
goto bad;
}
UChar* cie_augmentation = data;
cie_augmentation = data;
data += 1 + VG_(strlen)(cie_augmentation);
if (VG_(clo_trace_cfi))
VG_(printf)("cie.augment = \"%s\"\n", cie_augmentation);
@ -2408,9 +2413,13 @@ void ML_(read_callframe_info_dwarf2)
} else {
UnwindContext ctx, restore_ctx;
Int cie;
UInt look_for;
Bool ok;
Int cie;
UInt look_for;
Bool ok;
Addr fde_initloc;
UWord fde_arange;
UChar* fde_instrs;
Int fde_ilen;
/* --------- FDE --------- */
@ -2433,14 +2442,14 @@ void ML_(read_callframe_info_dwarf2)
goto bad;
}
Addr fde_initloc
fde_initloc
= read_encoded_Addr(data, the_CIEs[cie].address_encoding,
&nbytes, ehframe, ehframe_addr);
data += nbytes;
if (VG_(clo_trace_cfi))
VG_(printf)("fde.initloc = %p\n", (void*)fde_initloc);
UWord fde_arange
fde_arange
= read_encoded_Addr(data, the_CIEs[cie].address_encoding & 0xf,
&nbytes, ehframe, ehframe_addr);
data += nbytes;
@ -2452,8 +2461,8 @@ void ML_(read_callframe_info_dwarf2)
data += nbytes;
}
UChar* fde_instrs = data;
Int fde_ilen = ciefde_start + ciefde_len + sizeof(UInt) - data;
fde_instrs = data;
fde_ilen = ciefde_start + ciefde_len + sizeof(UInt) - data;
if (VG_(clo_trace_cfi)) {
VG_(printf)("fde.instrs = %p\n", fde_instrs);
VG_(printf)("fde.ilen = %d\n", (Int)fde_ilen);

View File

@ -498,6 +498,8 @@ void ML_(addScopeInfo) ( SegInfo* si,
void ML_(addCfiSI) ( SegInfo* si, CfiSI* cfisi )
{
static const Bool debug = False;
UInt new_sz, i;
CfiSI* new_tab;
if (debug) {
VG_(printf)("adding CfiSI: ");
@ -506,9 +508,6 @@ void ML_(addCfiSI) ( SegInfo* si, CfiSI* cfisi )
vg_assert(cfisi->len > 0 && cfisi->len < 2000000);
UInt new_sz, i;
CfiSI* new_tab;
/* Rule out ones which are completely outside the segment. These
probably indicate some kind of bug, but for the meantime ignore
them. */

View File

@ -212,8 +212,7 @@ SysRes VG_(pread) ( Int fd, void* buf, Int count, Int offset )
OffT off = VG_(lseek)( fd, (OffT)offset, VKI_SEEK_SET);
if (off != 0)
return VG_(mk_SysRes_Error)( VKI_EINVAL );
SysRes res = VG_(do_syscall3)(__NR_read, fd, (UWord)buf, count );
return res;
return VG_(do_syscall3)(__NR_read, fd, (UWord)buf, count );
}
/* Create and open (-rw------) a tmp file name incorporating said arg.

View File

@ -114,7 +114,7 @@ static HChar** setup_client_env ( HChar** origenv, const HChar* toolname)
HChar** cpp;
HChar** ret;
HChar* preload_tool_path;;
HChar* preload_tool_path;
Int envc, i;
/* Alloc space for the vgpreload_core.so path and vgpreload_<tool>.so
@ -417,6 +417,7 @@ Addr setup_client_stack( void* init_sp,
Addr anon_start = clstack_start;
Addr resvn_start = anon_start - resvn_size;
SizeT inner_HACK = 0;
Bool ok;
vg_assert(VG_IS_PAGE_ALIGNED(anon_size));
vg_assert(VG_IS_PAGE_ALIGNED(resvn_size));
@ -434,12 +435,12 @@ Addr setup_client_stack( void* init_sp,
/* Create a shrinkable reservation followed by an anonymous
segment. Together these constitute a growdown stack. */
Bool ok = VG_(am_create_reservation)(
resvn_start,
resvn_size -inner_HACK,
SmUpper,
anon_size +inner_HACK
);
ok = VG_(am_create_reservation)(
resvn_start,
resvn_size -inner_HACK,
SmUpper,
anon_size +inner_HACK
);
vg_assert(ok);
/* allocate a stack - mmap enough space for the stack */
res = VG_(am_mmap_anon_fixed_client)(
@ -1468,8 +1469,10 @@ static Bool process_cmd_line_options( UInt* client_auxv, const char* toolname )
results of a run which encompasses multiple processes. */
static void print_preamble(Bool logging_to_fd, const char* toolname)
{
Int i;
HChar* xpre = VG_(clo_xml) ? " <line>" : "";
HChar* xpost = VG_(clo_xml) ? "</line>" : "";
Int i;
if (VG_(clo_xml)) {
VG_(message)(Vg_UserMsg, "<?xml version=\"1.0\"?>");
VG_(message)(Vg_UserMsg, "");
@ -1479,9 +1482,6 @@ static void print_preamble(Bool logging_to_fd, const char* toolname)
VG_(message)(Vg_UserMsg, "");
}
HChar* xpre = VG_(clo_xml) ? " <line>" : "";
HChar* xpost = VG_(clo_xml) ? "</line>" : "";
if (VG_(clo_verbosity > 0)) {
if (VG_(clo_xml))

View File

@ -607,8 +607,8 @@ Superblock* findSb ( Arena* a, Block* b )
static
UInt pszB_to_listNo ( SizeT pszB )
{
vg_assert(0 == pszB % VG_MIN_MALLOC_SZB);
SizeT n = pszB / VG_MIN_MALLOC_SZB;
vg_assert(0 == pszB % VG_MIN_MALLOC_SZB);
// The first 13 lists hold blocks of size VG_MIN_MALLOC_SZB * list_num.
// The final 5 hold bigger blocks.

View File

@ -433,11 +433,13 @@ static Bool avl_insert(AvlTree* t, AvlNode* n)
// avl_insert() which doesn't return a Bool.
void VG_(OSet_Insert)(AvlTree* t, void* e)
{
AvlNode* n;
vg_assert(t);
// Initialise. Even though OSet_AllocNode zeroes these fields, we should
// do it again in case a node is removed and then re-added to the tree.
AvlNode* n = node_of_elem(e);
n = node_of_elem(e);
n->left = 0;
n->right = 0;
n->balance = 0;
@ -532,9 +534,9 @@ static Bool avl_remove(AvlTree* t, AvlNode* n)
Int cmpres = cmp_key_root(t, n);
if (cmpres < 0) {
AvlTree left_subtree;
// Remove from the left subtree
vg_assert(t->root->left);
AvlTree left_subtree;
// Only need to set the used fields in the subtree.
left_subtree.root = t->root->left;
left_subtree.cmp = t->cmp;

View File

@ -107,6 +107,8 @@ static Addr allocstack(ThreadId tid)
static void run_a_thread_NORETURN ( Word tidW )
{
ThreadId tid = (ThreadId)tidW;
VgSchedReturnCode src;
Int c;
VG_(debugLog)(1, "syswrap-amd64-linux",
"run_a_thread_NORETURN(tid=%lld): "
@ -114,14 +116,14 @@ static void run_a_thread_NORETURN ( Word tidW )
(ULong)tidW);
/* Run the thread all the way through. */
VgSchedReturnCode src = ML_(thread_wrapper)(tid);
src = ML_(thread_wrapper)(tid);
VG_(debugLog)(1, "syswrap-amd64-linux",
"run_a_thread_NORETURN(tid=%lld): "
"ML_(thread_wrapper) done\n",
(ULong)tidW);
Int c = VG_(count_living_threads)();
c = VG_(count_living_threads)();
vg_assert(c >= 1); /* stay sane */
if (c == 1) {
@ -138,13 +140,15 @@ static void run_a_thread_NORETURN ( Word tidW )
} else {
ThreadState *tst;
VG_(debugLog)(1, "syswrap-amd64-linux",
"run_a_thread_NORETURN(tid=%lld): "
"not last one standing\n",
(ULong)tidW);
/* OK, thread is dead, but others still exist. Just exit. */
ThreadState *tst = VG_(get_ThreadState)(tid);
tst = VG_(get_ThreadState)(tid);
/* This releases the run lock */
VG_(exit_thread)(tid);
@ -220,10 +224,12 @@ asm(
*/
void VG_(main_thread_wrapper_NORETURN)(ThreadId tid)
{
Addr rsp;
VG_(debugLog)(1, "syswrap-amd64-linux",
"entering VG_(main_thread_wrapper_NORETURN)\n");
Addr rsp = allocstack(tid);
rsp = allocstack(tid);
/* If we can't even allocate the first thread's stack, we're hosed.
Give up. */

View File

@ -1095,9 +1095,9 @@ ML_(generic_POST_sys_socketpair) ( ThreadId tid,
UWord arg2, UWord arg3 )
{
SysRes r = res;
vg_assert(!res.isError); /* guaranteed by caller */
Int fd1 = ((Int*)arg3)[0];
Int fd2 = ((Int*)arg3)[1];
vg_assert(!res.isError); /* guaranteed by caller */
POST_MEM_WRITE( arg3, 2*sizeof(int) );
if (!ML_(fd_allowed)(fd1, "socketcall.socketpair", tid, True) ||
!ML_(fd_allowed)(fd2, "socketcall.socketpair", tid, True)) {
@ -4761,8 +4761,8 @@ PRE(sys_poll)
int poll(struct pollfd *ufds, unsigned int nfds, int timeout)
*/
UInt i;
*flags |= SfMayBlock;
struct vki_pollfd* ufds = (struct vki_pollfd *)ARG1;
*flags |= SfMayBlock;
PRINT("sys_poll ( %p, %d, %d )\n", ARG1,ARG2,ARG3);
PRE_REG_READ3(long, "poll",
struct pollfd *, ufds, unsigned int, nfds, long, timeout);

View File

@ -54,14 +54,14 @@
// scheduler-return-code.
VgSchedReturnCode ML_(thread_wrapper)(Word /*ThreadId*/ tidW)
{
VG_(debugLog)(1, "core_os",
"ML_(thread_wrapper)(tid=%lld): entry\n",
(ULong)tidW);
VgSchedReturnCode ret;
ThreadId tid = (ThreadId)tidW;
ThreadState* tst = VG_(get_ThreadState)(tid);
VG_(debugLog)(1, "core_os",
"ML_(thread_wrapper)(tid=%lld): entry\n",
(ULong)tidW);
vg_assert(tst->status == VgTs_Init);
/* make sure we get the CPU lock before doing anything significant */

View File

@ -405,10 +405,10 @@ static
void putSyscallStatusIntoGuestState ( /*IN*/ SyscallStatus* canonical,
/*OUT*/VexGuestArchState* gst_vanilla )
{
vg_assert(canonical->what == SsSuccess
|| canonical->what == SsFailure);
#if defined(VGP_x86_linux)
VexGuestX86State* gst = (VexGuestX86State*)gst_vanilla;
vg_assert(canonical->what == SsSuccess
|| canonical->what == SsFailure);
if (canonical->what == SsFailure) {
/* This isn't exactly right, in that really a Failure with res
not in the range 1 .. 4095 is unrepresentable in the
@ -419,6 +419,8 @@ void putSyscallStatusIntoGuestState ( /*IN*/ SyscallStatus* canonical,
}
#elif defined(VGP_amd64_linux)
VexGuestAMD64State* gst = (VexGuestAMD64State*)gst_vanilla;
vg_assert(canonical->what == SsSuccess
|| canonical->what == SsFailure);
if (canonical->what == SsFailure) {
/* This isn't exactly right, in that really a Failure with res
not in the range 1 .. 4095 is unrepresentable in the
@ -432,6 +434,9 @@ void putSyscallStatusIntoGuestState ( /*IN*/ SyscallStatus* canonical,
VexGuestPPC32State* gst = (VexGuestPPC32State*)gst_vanilla;
UInt old_cr = LibVEX_GuestPPC32_get_CR(gst);
vg_assert(canonical->what == SsSuccess
|| canonical->what == SsFailure);
gst->guest_GPR3 = canonical->val;
if (canonical->what == SsFailure) {