Windows: fixed a number of int size warnings mostly by casting them away

This commit is contained in:
Jean-Francois Dockes 2015-08-30 17:30:31 +02:00
parent d5aa8db282
commit 970935f130
13 changed files with 21 additions and 42 deletions

View file

@ -199,7 +199,7 @@ namespace Binc {
s.seekg(0, ios::end);
std::streampos lst = s.tellg();
s.seekg(st);
size_t nbytes = lst - st;
size_t nbytes = size_t(lst - st);
if (nbytes > nb) {
nbytes = nb;
}

View file

@ -46,7 +46,7 @@ typedef int mode_t;
typedef int ssize_t;
#define strncasecmp _strnicmp
#define strcasecmp _stricmp
#define ftruncate _chsize
#define ftruncate _chsize_s
#define PATH_MAX MAX_PATH
#define MAXPATHLEN PATH_MAX
#define R_OK 4
@ -56,7 +56,7 @@ typedef int ssize_t;
#define S_ISLNK(X) false
#define lstat stat
#define fseeko _fseeki64
#define ftello _ftelli64
#define ftello (off_t)_ftelli64
#define timegm _mkgmtime
#endif

View file

@ -329,7 +329,7 @@ bool FsIndexer::indexFiles(list<string>& files, int flags)
{
LOGDEB(("FsIndexer::indexFiles\n"));
m_noretryfailed = (flags & ConfIndexer::IxFNoRetryFailed) != 0;
int ret = false;
bool ret = false;
if (!init())
return false;
@ -702,7 +702,7 @@ FsIndexer::processonefile(RclConfig *config,
}
LOGDEB0(("processone: processing: [%s] %s\n",
displayableBytes(stp->st_size).c_str(), fn.c_str()));
displayableBytes(off_t(stp->st_size)).c_str(), fn.c_str()));
string utf8fn = compute_utf8fn(config, fn);

View file

@ -140,7 +140,7 @@ namespace Dijon
stat() calls The value is stored inside metaData, docsize
key
*/
virtual void set_docsize(size_t size) = 0;
virtual void set_docsize(off_t size) = 0;
// Going from one nested document to the next.

View file

@ -169,7 +169,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
l_mime = *imime;
}
size_t docsize = stp->st_size;
off_t docsize = stp->st_size;
if (!l_mime.empty()) {
// Has mime: check for a compressed file. If so, create a

View file

@ -91,7 +91,7 @@ public:
return set_document_string(mtype, std::string(cp, sz));
}
virtual void set_docsize(size_t size)
virtual void set_docsize(off_t size)
{
char csize[30];
sprintf(csize, "%lld", (long long)size);

View file

@ -386,7 +386,7 @@ int Query::Native::makeAbstract(Xapian::docid docid,
for (multimap<double, vector<string> >::reverse_iterator mit = byQ.rbegin();
mit != byQ.rend(); mit++) {
unsigned int maxgrpoccs;
float q;
double q;
if (byQ.size() == 1) {
maxgrpoccs = maxtotaloccs;
q = 1.0;

View file

@ -549,8 +549,7 @@ bool Db::Native::getPagePositions(Xapian::docid docid, vector<int>& vpos)
return true;
}
int Db::Native::getPageNumberForPosition(const vector<int>& pbreaks,
unsigned int pos)
int Db::Native::getPageNumberForPosition(const vector<int>& pbreaks, int pos)
{
if (pos < baseTextPosition) // Not in text body
return -1;

View file

@ -120,7 +120,7 @@ class Db::Native {
const string& uniterm);
bool getPagePositions(Xapian::docid docid, vector<int>& vpos);
int getPageNumberForPosition(const vector<int>& pbreaks, unsigned int pos);
int getPageNumberForPosition(const vector<int>& pbreaks, int pos);
bool dbDataToRclDoc(Xapian::docid docid, std::string &data, Doc &doc);

View file

@ -956,10 +956,10 @@ bool CirCache::erase(const string& udi)
// entry.
class CCScanHookSpacer : public CCScanHook {
public:
UINT sizewanted;
UINT sizeseen;
off_t sizewanted;
off_t sizeseen;
vector<pair<string, off_t> > squashed_udis;
CCScanHookSpacer(int sz)
CCScanHookSpacer(off_t sz)
: sizewanted(sz), sizeseen(0) {assert(sz > 0);}
virtual status takeone(off_t offs, const string& udi,
@ -1035,15 +1035,15 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf,
// Characteristics for the new entry.
int nsize = CIRCACHE_HEADER_SIZE + dic.size() + datalen;
int nwriteoffs = m_d->m_oheadoffs;
int npadsize = 0;
off_t nwriteoffs = m_d->m_oheadoffs;
off_t npadsize = 0;
bool extending = false;
LOGDEB(("CirCache::put: nsz %d oheadoffs %d\n", nsize, m_d->m_oheadoffs));
// Check if we can recover some pad space from the (physically) previous
// entry.
int recovpadsize = m_d->m_oheadoffs == CIRCACHE_FIRSTBLOCK_SIZE ?
off_t recovpadsize = m_d->m_oheadoffs == CIRCACHE_FIRSTBLOCK_SIZE ?
0 : m_d->m_npadsize;
if (recovpadsize != 0) {
// Need to read the latest entry's header, to rewrite it with a
@ -1082,7 +1082,7 @@ bool CirCache::put(const string& udi, const ConfSimple *iconf,
} else {
// Scan the file until we have enough space for the new entry,
// and determine the pad size up to the 1st preserved entry
int scansize = nsize - recovpadsize;
off_t scansize = nsize - recovpadsize;
LOGDEB(("CirCache::put: scanning for size %d from offs %u\n",
scansize, (UINT)m_d->m_oheadoffs));
CCScanHookSpacer spacer(scansize);

View file

@ -26,7 +26,6 @@
#include <sys/param.h>
#include <pwd.h>
#include <sys/file.h>
#include <glob.h>
#endif
#include <math.h>
#include <errno.h>
@ -420,25 +419,6 @@ bool makepath(const string& ipath)
return true;
}
vector<string> path_dirglob(const string &dir, const string pattern)
{
#ifdef _WIN32
return vector<string>();
#else
vector<string> res;
glob_t mglob;
string mypat=path_cat(dir, pattern);
if (glob(mypat.c_str(), 0, 0, &mglob)) {
return res;
}
for (int i = 0; i < int(mglob.gl_pathc); i++) {
res.push_back(mglob.gl_pathv[i]);
}
globfree(&mglob);
return res;
#endif
}
bool path_isdir(const string& path)
{
struct stat st;

View file

@ -104,7 +104,7 @@ bool file_scan(const string &fn, FileScanDo* doer, off_t startoffs,
if (cnttoread != (size_t)-1 && cnttoread) {
doer->init(cnttoread+1, reason);
} else if (st.st_size > 0) {
doer->init(st.st_size+1, reason);
doer->init(size_t(st.st_size+1), reason);
} else {
doer->init(0, reason);
}
@ -123,7 +123,7 @@ bool file_scan(const string &fn, FileScanDo* doer, off_t startoffs,
for (;;) {
size_t toread = RDBUFSZ;
if (startoffs > 0 && curoffs < startoffs) {
toread = MIN(RDBUFSZ, startoffs - curoffs);
toread = size_t(MIN(RDBUFSZ, startoffs - curoffs));
}
if (cnttoread != size_t(-1)) {

View file

@ -637,7 +637,7 @@ string displayableBytes(off_t size)
unit = " GB ";
roundable = double(size) / 1E9;
}
size = round(roundable);
size = off_t(round(roundable));
sprintf(sizebuf, "%lld" "%s", (long long)size, unit);
return string(sizebuf);
}