From fe3343bc33c69b6b5288ada0830a9a795901a50e Mon Sep 17 00:00:00 2001 From: yutaka Date: Thu, 17 Apr 2008 01:35:39 +0000 Subject: [PATCH] =?UTF-8?q?=E5=86=97=E9=95=B7=E3=81=AA=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=81=AE=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@1167 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- build/libraries_sysmenu/dht/common/src/dht.c | 31 ++++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/build/libraries_sysmenu/dht/common/src/dht.c b/build/libraries_sysmenu/dht/common/src/dht.c index 9700914e..4d2e3848 100644 --- a/build/libraries_sysmenu/dht/common/src/dht.c +++ b/build/libraries_sysmenu/dht/common/src/dht.c @@ -156,18 +156,14 @@ BOOL DHT_PrepareDatabase(DHTFile* pDHT, FSFile* fp) OS_TPrintf("Cannot read the DHT header (result=%d).\n", result); return FALSE; } - // サイズチェック - PROFILE_COUNT(); - length = (s32)DHT_GetDatabaseLength(pDHT); - if ( FS_GetFileLength(fp) < length ) // パディングがあり得る - { - OS_TPrintf("Invalid DHT file size (%d < %d).\n", FS_GetFileLength(fp), length); - return FALSE; - } - // ヘッダ分を削除 - length -= sizeof(DHTHeader); // データベース読み込み PROFILE_COUNT(); + length = (s32)DHT_GetDatabaseLength(pDHT) - (s32)sizeof(DHTHeader); // ヘッダを除く + if ( length < 0 ) + { + OS_TPrintf("Invalid DHT header.\n"); + return FALSE; + } result = FS_ReadFile(fp, pDHT->database, length); if ( result != length ) { @@ -175,6 +171,11 @@ BOOL DHT_PrepareDatabase(DHTFile* pDHT, FSFile* fp) return FALSE; } } + else + { + PROFILE_COUNT(); + PROFILE_COUNT(); + } // データベースの検証 PROFILE_COUNT(); @@ -184,12 +185,10 @@ BOOL DHT_PrepareDatabase(DHTFile* pDHT, FSFile* fp) #ifdef PRINT_PROFILE PROFILE_COUNT(); OS_TPrintf("\nDone to prepare the database.\n"); - OS_TPrintf("%10d msec for file open.\n", (int)OS_TicksToMilliSeconds(profile[1]-profile[0])); - OS_TPrintf("%10d msec for reading header.\n", (int)OS_TicksToMilliSeconds(profile[2]-profile[1])); - OS_TPrintf("%10d msec for size check.\n", (int)OS_TicksToMilliSeconds(profile[3]-profile[2])); - OS_TPrintf("%10d msec for reading database.\n", (int)OS_TicksToMilliSeconds(profile[4]-profile[3])); - OS_TPrintf("%10d msec for comparing hash.\n", (int)OS_TicksToMilliSeconds(profile[5]-profile[4])); - OS_TPrintf("\nTotal: %10d msec.\n", (int)OS_TicksToMilliSeconds(profile[5]-profile[0])); + OS_TPrintf("%10d msec for reading header.\n", (int)OS_TicksToMilliSeconds(profile[1]-profile[0])); + OS_TPrintf("%10d msec for reading database.\n", (int)OS_TicksToMilliSeconds(profile[2]-profile[1])); + OS_TPrintf("%10d msec for comparing hash.\n", (int)OS_TicksToMilliSeconds(profile[3]-profile[2])); + OS_TPrintf("\nTotal: %10d msec.\n", (int)OS_TicksToMilliSeconds(profile[3]-profile[0])); #endif return result; }