Merge pull request #1462 from jaredmulconry/issue_1330
Fully addressed identifiable build warnings on gccpull/1468/head
commit
6ae35fb4d1
|
@ -32,7 +32,7 @@
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Return the next byte in the pseudo-random sequence
|
* Return the next byte in the pseudo-random sequence
|
||||||
*/
|
*/
|
||||||
static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
|
static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab)
|
||||||
{
|
{
|
||||||
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an
|
||||||
* unpredictable manner on 16-bit systems; not a problem
|
* unpredictable manner on 16-bit systems; not a problem
|
||||||
|
@ -45,7 +45,7 @@ static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab)
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Update the encryption keys with the next byte of plain text
|
* Update the encryption keys with the next byte of plain text
|
||||||
*/
|
*/
|
||||||
static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c)
|
static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c)
|
||||||
{
|
{
|
||||||
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
(*(pkeys+0)) = CRC32((*(pkeys+0)), c);
|
||||||
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
(*(pkeys+1)) += (*(pkeys+0)) & 0xff;
|
||||||
|
@ -62,7 +62,7 @@ static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int
|
||||||
* Initialize the encryption keys and the random header according to
|
* Initialize the encryption keys and the random header according to
|
||||||
* the given password.
|
* the given password.
|
||||||
*/
|
*/
|
||||||
static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab)
|
static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab)
|
||||||
{
|
{
|
||||||
*(pkeys+0) = 305419896L;
|
*(pkeys+0) = 305419896L;
|
||||||
*(pkeys+1) = 591751049L;
|
*(pkeys+1) = 591751049L;
|
||||||
|
|
|
@ -147,7 +147,7 @@ typedef struct
|
||||||
int encrypted;
|
int encrypted;
|
||||||
# ifndef NOUNCRYPT
|
# ifndef NOUNCRYPT
|
||||||
unsigned long keys[3]; /* keys defining the pseudo-random sequence */
|
unsigned long keys[3]; /* keys defining the pseudo-random sequence */
|
||||||
const unsigned long* pcrc_32_tab;
|
const z_crc_t* pcrc_32_tab;
|
||||||
# endif
|
# endif
|
||||||
} unz_s;
|
} unz_s;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
Open Asset Import Library (assimp)
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Copyright (c) 2006-2017, assimp team
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use of this software in source and binary forms,
|
||||||
|
with or without modification, are permitted provided that the following
|
||||||
|
conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the
|
||||||
|
following disclaimer in the documentation and/or other
|
||||||
|
materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the assimp team, nor the names of its
|
||||||
|
contributors may be used to endorse or promote products
|
||||||
|
derived from this software without specific prior
|
||||||
|
written permission of the assimp team.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#if defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define TMP_PATH "/tmp/"
|
||||||
|
inline FILE* MakeTmpFile(char* tmplate)
|
||||||
|
{
|
||||||
|
auto fd = mkstemp(tmplate);
|
||||||
|
EXPECT_NE(-1, fd);
|
||||||
|
if(fd == -1)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto fs = fdopen(fd, "w+");
|
||||||
|
EXPECT_NE(nullptr, fs);
|
||||||
|
return fs;
|
||||||
|
}
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
#include <io.h>
|
||||||
|
#define TMP_PATH "./"
|
||||||
|
inline FILE* MakeTmpFile(char* tmplate)
|
||||||
|
{
|
||||||
|
auto pathtemplate = _mktemp(tmplate);
|
||||||
|
EXPECT_NE(pathtemplate, nullptr);
|
||||||
|
if(pathtemplate == nullptr)
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
auto* fs = std::fopen(pathtemplate, "w+");
|
||||||
|
EXPECT_NE(fs, nullptr);
|
||||||
|
return fs;
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -39,35 +39,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
-------------------------------------------------------------------------*/
|
-------------------------------------------------------------------------*/
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "TestIOStream.h"
|
#include "TestIOStream.h"
|
||||||
|
#include "UnitTestFileGenerator.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#if defined(__GNUC__) || defined(__clang__)
|
|
||||||
#define TMP_PATH "/tmp/"
|
|
||||||
void MakeTmpFilePath(char* tmplate)
|
|
||||||
{
|
|
||||||
auto err = mkstemp(tmplate);
|
|
||||||
ASSERT_NE(err, -1);
|
|
||||||
}
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
#include <io.h>
|
|
||||||
#define TMP_PATH "./"
|
|
||||||
void MakeTmpFilePath(char* tmplate)
|
|
||||||
{
|
|
||||||
auto pathtemplate = _mktemp(tmplate);
|
|
||||||
ASSERT_NE(pathtemplate, nullptr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace ::Assimp;
|
using namespace ::Assimp;
|
||||||
|
|
||||||
class utDefaultIOStream : public ::testing::Test {
|
class utDefaultIOStream : public ::testing::Test {
|
||||||
// empty
|
// empty
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const char data[]{"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui\
|
const char data[]{"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui\
|
||||||
sque luctus sem diam, ut eleifend arcu auctor eu. Vestibulum id est vel nulla l\
|
sque luctus sem diam, ut eleifend arcu auctor eu. Vestibulum id est vel nulla l\
|
||||||
obortis malesuada ut sed turpis. Nulla a volutpat tortor. Nunc vestibulum portt\
|
obortis malesuada ut sed turpis. Nulla a volutpat tortor. Nunc vestibulum portt\
|
||||||
|
@ -78,18 +60,18 @@ TEST_F( utDefaultIOStream, FileSizeTest ) {
|
||||||
const auto dataCount = dataSize / sizeof(*data);
|
const auto dataCount = dataSize / sizeof(*data);
|
||||||
|
|
||||||
char fpath[] = { TMP_PATH"rndfp.XXXXXX" };
|
char fpath[] = { TMP_PATH"rndfp.XXXXXX" };
|
||||||
MakeTmpFilePath(fpath);
|
auto* fs = MakeTmpFile(fpath);
|
||||||
|
ASSERT_NE(nullptr, fs);
|
||||||
|
{
|
||||||
|
auto written = std::fwrite(data, sizeof(*data), dataCount, fs );
|
||||||
|
EXPECT_NE( 0U, written );
|
||||||
|
|
||||||
auto *fs = std::fopen(fpath, "w+" );
|
auto vflush = std::fflush( fs );
|
||||||
ASSERT_NE(fs, nullptr);
|
ASSERT_EQ(vflush, 0);
|
||||||
auto written = std::fwrite(data, sizeof(*data), dataCount, fs );
|
|
||||||
EXPECT_NE( 0U, written );
|
|
||||||
auto vflush = std::fflush( fs );
|
|
||||||
ASSERT_EQ(vflush, 0);
|
|
||||||
|
|
||||||
TestDefaultIOStream myStream( fs, fpath);
|
TestDefaultIOStream myStream( fs, fpath);
|
||||||
size_t size = myStream.FileSize();
|
size_t size = myStream.FileSize();
|
||||||
EXPECT_EQ( size, dataSize);
|
EXPECT_EQ( size, dataSize);
|
||||||
|
}
|
||||||
remove(fpath);
|
remove(fpath);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
#include "IOStreamBuffer.h"
|
#include "IOStreamBuffer.h"
|
||||||
#include "TestIOStream.h"
|
#include "TestIOStream.h"
|
||||||
|
#include "UnitTestFileGenerator.h"
|
||||||
|
|
||||||
class IOStreamBufferTest : public ::testing::Test {
|
class IOStreamBufferTest : public ::testing::Test {
|
||||||
// empty
|
// empty
|
||||||
|
@ -68,40 +69,59 @@ TEST_F( IOStreamBufferTest, accessCacheSizeTest ) {
|
||||||
EXPECT_EQ( 100U, myBuffer2.cacheSize() );
|
EXPECT_EQ( 100U, myBuffer2.cacheSize() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char data[]{"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Qui\
|
||||||
|
sque luctus sem diam, ut eleifend arcu auctor eu. Vestibulum id est vel nulla l\
|
||||||
|
obortis malesuada ut sed turpis. Nulla a volutpat tortor. Nunc vestibulum portt\
|
||||||
|
itor sapien ornare sagittis volutpat."};
|
||||||
|
|
||||||
|
|
||||||
TEST_F( IOStreamBufferTest, open_close_Test ) {
|
TEST_F( IOStreamBufferTest, open_close_Test ) {
|
||||||
IOStreamBuffer<char> myBuffer;
|
IOStreamBuffer<char> myBuffer;
|
||||||
|
|
||||||
EXPECT_FALSE( myBuffer.open( nullptr ) );
|
EXPECT_FALSE( myBuffer.open( nullptr ) );
|
||||||
EXPECT_FALSE( myBuffer.close() );
|
EXPECT_FALSE( myBuffer.close() );
|
||||||
|
|
||||||
|
const auto dataSize = sizeof(data);
|
||||||
|
const auto dataCount = dataSize / sizeof(*data);
|
||||||
|
|
||||||
char buffer[ L_tmpnam ];
|
char fname[]={ "octest.XXXXXX" };
|
||||||
tmpnam( buffer );
|
auto* fs = MakeTmpFile(fname);
|
||||||
std::FILE *fs( std::fopen( buffer, "w+" ) );
|
ASSERT_NE(nullptr, fs);
|
||||||
size_t written( std::fwrite( buffer, 1, sizeof( char ) * L_tmpnam, fs ) );
|
|
||||||
|
auto written = std::fwrite( data, sizeof(*data), dataCount, fs );
|
||||||
EXPECT_NE( 0U, written );
|
EXPECT_NE( 0U, written );
|
||||||
std::fflush( fs );
|
std::fflush( fs );
|
||||||
|
{
|
||||||
|
TestDefaultIOStream myStream( fs, fname );
|
||||||
|
|
||||||
TestDefaultIOStream myStream( fs, buffer );
|
EXPECT_TRUE( myBuffer.open( &myStream ) );
|
||||||
|
EXPECT_FALSE( myBuffer.open( &myStream ) );
|
||||||
EXPECT_TRUE( myBuffer.open( &myStream ) );
|
EXPECT_TRUE( myBuffer.close() );
|
||||||
EXPECT_FALSE( myBuffer.open( &myStream ) );
|
}
|
||||||
EXPECT_TRUE( myBuffer.close() );
|
remove(fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F( IOStreamBufferTest, readlineTest ) {
|
TEST_F( IOStreamBufferTest, readlineTest ) {
|
||||||
char buffer[ L_tmpnam ];
|
|
||||||
tmpnam( buffer );
|
const auto dataSize = sizeof(data);
|
||||||
std::FILE *fs( std::fopen( buffer, "w+" ) );
|
const auto dataCount = dataSize / sizeof(*data);
|
||||||
size_t written( std::fwrite( buffer, 1, sizeof( char ) * L_tmpnam, fs ) );
|
|
||||||
|
char fname[]={ "readlinetest.XXXXXX" };
|
||||||
|
auto* fs = MakeTmpFile(fname);
|
||||||
|
ASSERT_NE(nullptr, fs);
|
||||||
|
|
||||||
|
auto written = std::fwrite( data, sizeof(*data), dataCount, fs );
|
||||||
EXPECT_NE( 0U, written );
|
EXPECT_NE( 0U, written );
|
||||||
std::fflush( fs );
|
std::fflush( fs );
|
||||||
|
|
||||||
IOStreamBuffer<char> myBuffer( 26 );
|
const auto tCacheSize = 26u;
|
||||||
EXPECT_EQ( 26U, myBuffer.cacheSize() );
|
|
||||||
|
|
||||||
TestDefaultIOStream myStream( fs, buffer );
|
IOStreamBuffer<char> myBuffer( tCacheSize );
|
||||||
size_t size( myStream.FileSize() );
|
EXPECT_EQ(tCacheSize, myBuffer.cacheSize() );
|
||||||
size_t numBlocks( size / myBuffer.cacheSize() );
|
|
||||||
|
TestDefaultIOStream myStream( fs, fname );
|
||||||
|
auto size = myStream.FileSize();
|
||||||
|
auto numBlocks = size / myBuffer.cacheSize();
|
||||||
if ( size % myBuffer.cacheSize() > 0 ) {
|
if ( size % myBuffer.cacheSize() > 0 ) {
|
||||||
numBlocks++;
|
numBlocks++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue