From: Oliver Kurth Date: Fri, 15 Sep 2017 18:22:43 +0000 (-0700) Subject: lib/hashMap: Remove unused HasMap_Store() and _Retrieve() functions. X-Git-Tag: stable-10.2.0~707 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ec88ceddf4df201a75e026ed70acd34a7ffbc9a0;p=thirdparty%2Fopen-vm-tools.git lib/hashMap: Remove unused HasMap_Store() and _Retrieve() functions. CheckSanity() should only be compiled if VMX86_DEBUG is set to avoid an unused function warning from clang 3.4. --- diff --git a/open-vm-tools/lib/hashMap/hashMap.c b/open-vm-tools/lib/hashMap/hashMap.c index 16a359c6d..935f21db3 100644 --- a/open-vm-tools/lib/hashMap/hashMap.c +++ b/open-vm-tools/lib/hashMap/hashMap.c @@ -161,10 +161,10 @@ INLINE void EnsureSanity(HashMap *map); * ---------------------------------------------------------------------------- */ +#ifdef VMX86_DEBUG static INLINE Bool CheckSanity(HashMap *map) { -#ifdef VMX86_DEBUG uint32 i, cnt = 0; ASSERT(map); @@ -192,9 +192,9 @@ CheckSanity(HashMap *map) if (!map->numEntries) { return FALSE; } -#endif return TRUE; } +#endif /* * ---------------------------------------------------------------------------- @@ -539,221 +539,6 @@ HashMap_Count(struct HashMap *map) // IN } -#ifdef VMX86_SERVER -/* - * ---------------------------------------------------------------------------- - * - * HashMap_Store -- - * - * Write the contents of the HashMap to the given AIOhandle - * - * Results: - * The number of bytes written on success -1 on error - * - * Side Effects: - * None. - * - * ---------------------------------------------------------------------------- - */ - -uint64 -HashMap_Store(struct HashMap *map, // IN - void *h, // IN - uint64 startByteOffset) // IN -{ - AIOHandle *handle = (AIOHandle *)h; - AIOMgrError aioErr; - struct iovec vec; - uint64 numBytes; - struct HashMapOnDisk hashMapOnDisk; - - hashMapOnDisk.numEntries = map->numEntries; - hashMapOnDisk.count = map->count; - hashMapOnDisk.alpha = map->alpha; - hashMapOnDisk.keySize = map->keySize; - hashMapOnDisk.dataSize = map->dataSize; - hashMapOnDisk.entrySize = map->entrySize; - hashMapOnDisk.keyOffset = map->keyOffset; - hashMapOnDisk.dataOffset = map->dataOffset; - - /* - * write map - */ - vec.iov_base = (void *)&hashMapOnDisk; - vec.iov_len = sizeof hashMapOnDisk; - numBytes = vec.iov_len; - - aioErr = AIOMgr_Queue(*handle, &vec, 1, OP_WRITE, startByteOffset, numBytes, - AIOMGR_INVALID_IO_REQUEST_ID, NULL, NULL); - ASSERT(!AIOMgr_IsAsync(aioErr)); - if (!AIOMgr_IsSuccess(aioErr)) { - return -1; - } - - /* - * write map entries - */ - vec.iov_base = (void *)map->entries; - vec.iov_len = map->numEntries * map->entrySize; - - aioErr = AIOMgr_Queue(*handle, &vec, 1, OP_WRITE, - startByteOffset + numBytes, vec.iov_len, - AIOMGR_INVALID_IO_REQUEST_ID, NULL, NULL); - ASSERT(!AIOMgr_IsAsync(aioErr)); - if (!AIOMgr_IsSuccess(aioErr)) { - return -1; - } - - return numBytes + (map->numEntries * map->entrySize); -} - - -/* - * ---------------------------------------------------------------------------- - * - * HashMap_Retrieve -- - * - * Read the contents of the HashMap from the given AIOhandle - * - * Results: - * The allocated map - * - * Side Effects: - * None. - * - * ---------------------------------------------------------------------------- - */ -struct HashMap * -HashMap_Retrieve(void *h, // IN - uint32 numEntries, // IN - uint64 startByteOffset, // IN - uint64 *retNumBytes) // OUT -{ - AIOMgrError aioErr = AIOMgr_MakeError(AIOERR_RDONLY, 0); - struct iovec vec; - uint64 numBytes; - struct HashMap *map; - struct HashMapOnDisk hashMapOnDisk; - AIOHandle *handle = (AIOHandle *)h; - - map = calloc(1, sizeof *map); - - /* - * read map - */ - vec.iov_base = (void *)&hashMapOnDisk; - vec.iov_len = sizeof hashMapOnDisk; - numBytes = vec.iov_len; - if (handle) { - aioErr = AIOMgr_Queue(*handle, &vec, 1, OP_READ, startByteOffset, - numBytes, AIOMGR_INVALID_IO_REQUEST_ID, NULL, - NULL); - ASSERT(!AIOMgr_IsAsync(aioErr)); - } - - if (!AIOMgr_IsSuccess(aioErr)) { - free(map); - map = HashMap_AllocMapAlpha(numEntries, 1, sizeof(int32), sizeof(int32)); - *retNumBytes = sizeof(hashMapOnDisk) + (map->numEntries * map->entrySize); - return map; - } - - if (!hashMapOnDisk.numEntries) { - free(map); - map = HashMap_AllocMapAlpha(numEntries, 1, sizeof(int32), sizeof(int32)); - *retNumBytes = sizeof(hashMapOnDisk) + (map->numEntries * map->entrySize); - return map; - } - - map->numEntries = hashMapOnDisk.numEntries; - map->count = hashMapOnDisk.count; - map->alpha = hashMapOnDisk.alpha; - map->keySize = hashMapOnDisk.keySize; - map->dataSize = hashMapOnDisk.dataSize; - map->entrySize = hashMapOnDisk.entrySize; - map->keyOffset = hashMapOnDisk.keyOffset; - map->dataOffset = hashMapOnDisk.dataOffset; - - /* - * read map entries - */ - map->entries = calloc(map->numEntries, map->entrySize); - vec.iov_base = (void *)map->entries; - vec.iov_len = map->numEntries * map->entrySize; - ASSERT(handle); - aioErr = AIOMgr_Queue(*handle, &vec, 1, OP_READ, - startByteOffset + numBytes, vec.iov_len, - AIOMGR_INVALID_IO_REQUEST_ID, NULL, NULL); - ASSERT(!AIOMgr_IsAsync(aioErr)); - if (!AIOMgr_IsSuccess(aioErr)) { - free(map->entries); - free(map); - return NULL; - } - - *retNumBytes = numBytes + (map->numEntries * map->entrySize); - if (!CheckSanity(map)) { - free(map->entries); - free(map); - return NULL; - } - return map; -} - -#else - -/* - * ---------------------------------------------------------------------------- - * - * HashMap_Store -- - * - * Stub for non server targets - * - * Results: - * None - * - * Side Effects: - * None. - * - * ---------------------------------------------------------------------------- - */ -uint64 -HashMap_Store(struct HashMap *map, // IN - void *h, // IN - uint64 startByteOffset) // IN -{ - ASSERT(0); - return -1; -} - - -/* - * ---------------------------------------------------------------------------- - * - * HashMap_Retrieve -- - * - * Stub for non-server targets - * - * Results: - * None - * - * Side Effects: - * None. - * - * ---------------------------------------------------------------------------- - */ -struct HashMap * -HashMap_Retrieve(void *h, // IN - uint32 numEntries, // IN - uint64 startByteOffset, // IN - uint64 *retNumBytes) // OUT -{ - ASSERT(0); - return NULL; -} -#endif - - /* * ---------------------------------------------------------------------------- * diff --git a/open-vm-tools/lib/include/hashMap.h b/open-vm-tools/lib/include/hashMap.h index 6ba250cba..05a37a446 100644 --- a/open-vm-tools/lib/include/hashMap.h +++ b/open-vm-tools/lib/include/hashMap.h @@ -78,8 +78,6 @@ uint32 HashMap_Count(HashMap *map); void HashMap_Iterate(HashMap* map, HashMapIteratorFn mapFn, Bool clear, void *userData); Bool HashMap_DoTests(void); -uint64 HashMap_Store(struct HashMap *, void *, uint64); -struct HashMap *HashMap_Retrieve(void *, uint32, uint64, uint64 *); #ifdef __cplusplus }