diff --git a/hwpfilter/source/drawing.h b/hwpfilter/source/drawing.h index 00eef6335571..1967ddffed1c 100644 --- a/hwpfilter/source/drawing.h +++ b/hwpfilter/source/drawing.h @@ -107,14 +107,14 @@ static bool SkipPrivateBlock(int type) { if (!hmem->read4b(n)) return false; - if (hmem->state() || hmem->skipBlock(n) != n) + if (hmem->state() || hmem->skipBlock(n) != static_cast(n)) return false; } if (!hmem->read4b(n)) return false; if (hmem->state()) return false; - return hmem->skipBlock(n) == n; + return hmem->skipBlock(n) == static_cast(n); } static int SizeExpected; diff --git a/hwpfilter/source/hgzip.cxx b/hwpfilter/source/hgzip.cxx index 81dda52e60f1..d4adc6961431 100644 --- a/hwpfilter/source/hgzip.cxx +++ b/hwpfilter/source/hgzip.cxx @@ -148,17 +148,17 @@ static int destroy(gz_stream * s) Reads the given number of uncompressed bytes from the compressed file. gz_read returns the number of bytes actually read (0 for end of file). */ -int gz_read(gz_stream * file, voidp buf, unsigned len) +size_t gz_read(gz_stream * file, voidp buf, unsigned len) { //printf("@@ gz_read : len : %d\t",len); gz_stream *s = file; Bytef *start = static_cast(buf); /* starting point for crc computation */ Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ if (s == nullptr) - return Z_STREAM_ERROR; + return 0; if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) - return -1; + return 0; if (s->z_err == Z_STREAM_END) return 0; /* EOF */ @@ -201,7 +201,7 @@ int gz_read(gz_stream * file, voidp buf, unsigned len) break; } s->crc = crc32(s->crc, start, (uInt) (s->stream.next_out - start)); - return (int) (len - s->stream.avail_out); + return len - s->stream.avail_out; } /* =========================================================================== diff --git a/hwpfilter/source/hgzip.h b/hwpfilter/source/hgzip.h index 4cff263ed390..40260a99dcc7 100644 --- a/hwpfilter/source/hgzip.h +++ b/hwpfilter/source/hgzip.h @@ -80,7 +80,7 @@ int gz_close ( gz_stream *file ); * @param len Length of data to be read * @returns The number of bytes actually read */ -int gz_read ( gz_stream *file, voidp buf, unsigned len ); +size_t gz_read ( gz_stream *file, voidp buf, unsigned len ); /** * Flushes all pending output into the compressed file * gz_flush should be called only when strictly necessary because it can diff --git a/hwpfilter/source/hiodev.cxx b/hwpfilter/source/hiodev.cxx index 48d105ff23ed..45ccb987bcd5 100644 --- a/hwpfilter/source/hiodev.cxx +++ b/hwpfilter/source/hiodev.cxx @@ -34,7 +34,7 @@ #include "hwpfile.h" #include "hstream.hxx" -const int BUFSIZE = 1024; +const size_t BUFSIZE = 1024; static uchar rBuf[BUFSIZE]; // HIODev abstract class @@ -55,14 +55,14 @@ void HIODev::init() } -int HIODev::read1b(void *ptr, int nmemb) +size_t HIODev::read1b(void *ptr, size_t nmemb) { uchar *p = static_cast(ptr); - int ii; if (state()) - return -1; - for (ii = 0; ii < nmemb; ii++) + return 0; + size_t ii; + for (ii = 0; ii < nmemb; ++ii) { if (!read1b(p[ii])) break; @@ -72,14 +72,14 @@ int HIODev::read1b(void *ptr, int nmemb) return ii; } -int HIODev::read2b(void *ptr, int nmemb) +size_t HIODev::read2b(void *ptr, size_t nmemb) { ushort *p = static_cast(ptr); - int ii; if (state()) - return -1; - for (ii = 0; ii < nmemb; ii++) + return 0; + size_t ii; + for (ii = 0; ii < nmemb; ++ii) { if (!read2b(p[ii])) break; @@ -89,14 +89,14 @@ int HIODev::read2b(void *ptr, int nmemb) return ii; } -int HIODev::read4b(void *ptr, int nmemb) +size_t HIODev::read4b(void *ptr, size_t nmemb) { uint *p = static_cast(ptr); - int ii; if (state()) - return -1; - for (ii = 0; ii < nmemb; ii++) + return 0; + size_t ii; + for (ii = 0; ii < nmemb; ++ii) { if (!read4b(p[ii])) break; @@ -174,7 +174,7 @@ bool HStreamIODev::setCompressed(bool flag) bool HStreamIODev::read1b(unsigned char &out) { - int res = (compressed) ? GZREAD(rBuf, 1) : _stream->readBytes(rBuf, 1); + size_t res = (compressed) ? GZREAD(rBuf, 1) : _stream->readBytes(rBuf, 1); if (res < 1) return false; @@ -194,7 +194,7 @@ bool HStreamIODev::read1b(char &out) bool HStreamIODev::read2b(unsigned short &out) { - int res = (compressed) ? GZREAD(rBuf, 2) : _stream->readBytes(rBuf, 2); + size_t res = (compressed) ? GZREAD(rBuf, 2) : _stream->readBytes(rBuf, 2); if (res < 2) return false; @@ -205,7 +205,7 @@ bool HStreamIODev::read2b(unsigned short &out) bool HStreamIODev::read4b(unsigned int &out) { - int res = (compressed) ? GZREAD(rBuf, 4) : _stream->readBytes(rBuf, 4); + size_t res = (compressed) ? GZREAD(rBuf, 4) : _stream->readBytes(rBuf, 4); if (res < 4) return false; @@ -224,9 +224,9 @@ bool HStreamIODev::read4b(int &out) return true; } -int HStreamIODev::readBlock(void *ptr, int size) +size_t HStreamIODev::readBlock(void *ptr, size_t size) { - int count = + size_t count = (compressed) ? GZREAD(ptr, size) : _stream->readBytes(static_cast(ptr), size); @@ -234,16 +234,16 @@ int HStreamIODev::readBlock(void *ptr, int size) return count; } -int HStreamIODev::skipBlock(int size) +size_t HStreamIODev::skipBlock(size_t size) { if (compressed){ if( size <= BUFSIZE ) return GZREAD(rBuf, size); else{ - int remain = size; + size_t remain = size; while(remain){ if( remain > BUFSIZE ) { - int read = GZREAD(rBuf, BUFSIZE); + size_t read = GZREAD(rBuf, BUFSIZE); remain -= read; if (read != BUFSIZE) break; @@ -260,7 +260,7 @@ int HStreamIODev::skipBlock(int size) } -HMemIODev::HMemIODev(char *s, int len) +HMemIODev::HMemIODev(char *s, size_t len) { init(); ptr = reinterpret_cast(s); @@ -357,7 +357,7 @@ bool HMemIODev::read4b(int &out) return true; } -int HMemIODev::readBlock(void *p, int size) +size_t HMemIODev::readBlock(void *p, size_t size) { if (length < pos + size) size = length - pos; @@ -366,7 +366,7 @@ int HMemIODev::readBlock(void *p, int size) return size; } -int HMemIODev::skipBlock(int size) +size_t HMemIODev::skipBlock(size_t size) { if (length < pos + size) return 0; diff --git a/hwpfilter/source/hiodev.h b/hwpfilter/source/hiodev.h index 7c20e1ffa699..af49703c3482 100644 --- a/hwpfilter/source/hiodev.h +++ b/hwpfilter/source/hiodev.h @@ -56,12 +56,12 @@ class DLLEXPORT HIODev virtual bool read2b(unsigned short &out) = 0; virtual bool read4b(unsigned int &out) = 0; virtual bool read4b(int &out) = 0; - virtual int readBlock( void *ptr, int size ) = 0; - virtual int skipBlock( int size ) = 0; + virtual size_t readBlock( void *ptr, size_t size ) = 0; + virtual size_t skipBlock( size_t size ) = 0; - int read1b( void *ptr, int nmemb ); - int read2b( void *ptr, int nmemb ); - int read4b( void *ptr, int nmemb ); + size_t read1b( void *ptr, size_t nmemb ); + size_t read2b( void *ptr, size_t nmemb ); + size_t read4b( void *ptr, size_t nmemb ); }; struct gz_stream; @@ -117,11 +117,11 @@ class HStreamIODev final: public HIODev /** * Read some bytes from stream to given pointer as amount of size */ - virtual int readBlock( void *ptr, int size ) override; + virtual size_t readBlock( void *ptr, size_t size ) override; /** * Move current pointer of stream as amount of size */ - virtual int skipBlock( int size ) override; + virtual size_t skipBlock( size_t size ) override; private: /** * Initialize this object @@ -137,9 +137,9 @@ class HStreamIODev final: public HIODev class HMemIODev final: public HIODev { uchar *ptr; - int pos, length; + size_t pos, length; public: - HMemIODev(char *s, int len); + HMemIODev(char *s, size_t len); virtual ~HMemIODev() override; virtual bool open() override; @@ -155,8 +155,8 @@ class HMemIODev final: public HIODev using HIODev::read4b; virtual bool read4b(unsigned int &out) override; virtual bool read4b(int &out) override; - virtual int readBlock( void *ptr, int size ) override; - virtual int skipBlock( int size ) override; + virtual size_t readBlock( void *ptr, size_t size ) override; + virtual size_t skipBlock( size_t size ) override; private: virtual void init() override; };