From f416b812ddefbcfcf2ad730f2436b10ac7ac0abf Mon Sep 17 00:00:00 2001 From: xwlan Date: Tue, 22 Sep 2015 13:12:58 +0800 Subject: [PATCH] fix log/sym folder creation failure, clean code --- apspf/aps.c | 12 ++++++++---- dprofiler/cpuflame.c | 2 -- dprofiler/cpuhistory.c | 2 +- dprofiler/cputhread.c | 18 ------------------ dprofiler/cputree.c | 2 -- dprofiler/find.c | 2 -- dprofiler/fullstack.c | 4 +--- dprofiler/rebar.c | 1 - 8 files changed, 10 insertions(+), 33 deletions(-) diff --git a/apspf/aps.c b/apspf/aps.c index 19b22b9..0e2bf61 100755 --- a/apspf/aps.c +++ b/apspf/aps.c @@ -221,8 +221,10 @@ ApsInitialize( StringCchPrintf(ApsLogPath, MAX_PATH, L"%s\\log", Path); Status = CreateDirectory(ApsLogPath, NULL); - if (Status != APS_STATUS_OK && Status != ERROR_ALREADY_EXISTS) { - return Status; + if (!Status) { + if (GetLastError() != ERROR_ALREADY_EXISTS) { + return APS_STATUS_ERROR; + } } // @@ -231,8 +233,10 @@ ApsInitialize( StringCchPrintf(ApsLocalSymPath, MAX_PATH, L"%s\\sym", Path); Status = CreateDirectory(ApsLocalSymPath, NULL); - if (Status != APS_STATUS_OK && Status != ERROR_ALREADY_EXISTS) { - return Status; + if (!Status) { + if (GetLastError() != ERROR_ALREADY_EXISTS) { + return APS_STATUS_ERROR; + } } Status = ApsInitializeLog(APS_FLAG_LOGGING); diff --git a/dprofiler/cpuflame.c b/dprofiler/cpuflame.c index f0c385f..dcc6752 100755 --- a/dprofiler/cpuflame.c +++ b/dprofiler/cpuflame.c @@ -236,8 +236,6 @@ CpuFlameInsertData( PBTR_STACK_RECORD Record; ULONG Count; PCALL_GRAPH Graph; - PCPU_THREAD_TABLE ThreadTable; - PCPU_THREAD Thread; Object = (PDIALOG_OBJECT)SdkGetObject(hWnd); Context = (PCPU_FORM_CONTEXT)Object->Context; diff --git a/dprofiler/cpuhistory.c b/dprofiler/cpuhistory.c index d6af517..81e7c63 100755 --- a/dprofiler/cpuhistory.c +++ b/dprofiler/cpuhistory.c @@ -2304,7 +2304,7 @@ CpuHistoryInsertBackTrace( lvi.iSubItem = 2; lvi.mask = LVIF_TEXT; - if (Text->LineId != -1) { + if (Text != NULL && Text->LineId != -1) { ASSERT(Line != NULL); LineEntry = Line + Text->LineId; StringCchPrintf(Buffer, MAX_PATH, L"%S:%u", LineEntry->File, LineEntry->Line); diff --git a/dprofiler/cputhread.c b/dprofiler/cputhread.c index 7ea80a6..3188379 100755 --- a/dprofiler/cputhread.c +++ b/dprofiler/cputhread.c @@ -728,24 +728,6 @@ CpuThreadGetTable( return (PCPU_THREAD_TABLE)Context->Context; } -PCPU_THREAD -CpuThreadGetMostBusyThread( - __in HWND hWnd - ) -{ - PDIALOG_OBJECT Object; - PCPU_FORM_CONTEXT Context; - PCPU_THREAD_TABLE Table; - - Object = (PDIALOG_OBJECT)SdkGetObject(hWnd); - Context = (PCPU_FORM_CONTEXT)Object->Context; - Table = (PCPU_THREAD_TABLE)Context->Context; - - ASSERT(Table != NULL); - - -} - VOID CpuThreadInsertThreads( __in HWND hWnd, diff --git a/dprofiler/cputree.c b/dprofiler/cputree.c index 6fe7d37..c62af07 100755 --- a/dprofiler/cputree.c +++ b/dprofiler/cputree.c @@ -534,8 +534,6 @@ CpuTreeInsertData( PBTR_STACK_RECORD Record; ULONG Count; PCALL_GRAPH Graph; - PCPU_THREAD Thread; - PCPU_THREAD_TABLE ThreadTable; Object = (PDIALOG_OBJECT)SdkGetObject(hWnd); Context = (PCPU_FORM_CONTEXT)Object->Context; diff --git a/dprofiler/find.c b/dprofiler/find.c index 22acf62..4aae977 100755 --- a/dprofiler/find.c +++ b/dprofiler/find.c @@ -12,8 +12,6 @@ FindIsComplete( __in ULONG Current ) { - ULONG Count; - if (Context->FindForward) { return TRUE; } diff --git a/dprofiler/fullstack.c b/dprofiler/fullstack.c index 7df20a3..9982055 100755 --- a/dprofiler/fullstack.c +++ b/dprofiler/fullstack.c @@ -206,7 +206,6 @@ FullStackInsertBackTrace( PBTR_TEXT_TABLE Table; PPF_REPORT_HEAD Report; PBTR_TEXT_ENTRY Text; - PBTR_DLL_ENTRY DllEntry; ULONG Length; PWCHAR Symbol; ULONG i; @@ -507,7 +506,6 @@ FullStackOnTreeListSort( PDIALOG_OBJECT Object; PFULLSTACK_CONTEXT Context; PTREELIST_OBJECT TreeList; - ULONG Column; TVSORTCB Tsc = {0}; CPU_SORT_CONTEXT SortContext; TVITEM tvi = {0}; @@ -518,7 +516,7 @@ FullStackOnTreeListSort( ASSERT(TreeList != NULL); SortContext.Column = wp; - SortContext.Context = NULL; + SortContext.Context = (LPARAM)NULL; SortContext.Order = TreeList->SortOrder; Tsc.hParent = TVI_ROOT; diff --git a/dprofiler/rebar.c b/dprofiler/rebar.c index f1d29c4..950faa0 100755 --- a/dprofiler/rebar.c +++ b/dprofiler/rebar.c @@ -267,7 +267,6 @@ RebarInsertBands( HWND hWndCombo; HWND hWndBar; HWND hWndRebar; - HWND hWndEdit; PREBAR_BAND Band; HIMAGELIST Normal; HIMAGELIST Grayed;