]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
get rid of a couple of warnings for msvc
authorMichael Schroeder <mls@suse.de>
Fri, 29 Aug 2014 11:10:14 +0000 (13:10 +0200)
committerMichael Schroeder <mls@suse.de>
Fri, 29 Aug 2014 11:10:14 +0000 (13:10 +0200)
src/poolid.c
src/qsort_r.c
src/repo.c
src/repo.h
src/repo_solv.c
src/repo_write.c
src/repodata.c
src/strpool.c

index 5fe502b495d79d6a483e4f231d7ed7ab94f3ebe9..7bcc1f6094e46562c8f5a16002170ef782fb626e 100644 (file)
@@ -65,7 +65,7 @@ pool_rel2id(Pool *pool, Id name, Id evr, int flags, int create)
   ran = pool->rels;
 
   /* extend hashtable if needed */
-  if (pool->nrels * 2 > hashmask)
+  if ((Hashval)pool->nrels * 2 > hashmask)
     {
       solv_free(pool->relhashtbl);
       pool->relhashmask = hashmask = mkmask(pool->nrels + REL_BLOCK);
index f264ed0a22dc6d74c8fc9b5641dc94997e684df9..d49049aad80886168db63ed5f7f3cf3038b23251 100644 (file)
@@ -47,7 +47,9 @@ typedef int            cmp_t(const void *, const void *, void *);
 static inline char     *med3(char *, char *, char *, cmp_t *, void *);
 static inline void      swapfunc(char *, char *, int, int);
 
+#ifndef min
 #define min(a, b)      (a) < (b) ? a : b
+#endif
 
 /*
  * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
index 511fd9227271ba132beea5af9598807f3498661b..15e7e80d8e311df5ad211652eb35a0c07f75993c 100644 (file)
@@ -388,10 +388,10 @@ repo_addid_dep_hash(Repo *repo, Offset olddeps, Id id, Id marker, int size)
     }
 
   /* maintain hash and lastmarkerpos */
-  if (repo->lastidhash_idarraysize != repo->idarraysize || size * 2 > repo->lastidhash_mask || repo->lastmarker != marker)
+  if (repo->lastidhash_idarraysize != repo->idarraysize || (Hashval)size * 2 > repo->lastidhash_mask || repo->lastmarker != marker)
     {
       repo->lastmarkerpos = 0;
-      if (size * 2 > repo->lastidhash_mask)
+      if (size * 2 > (Hashval)repo->lastidhash_mask)
        {
          repo->lastidhash_mask = mkmask(size < REPO_ADDID_DEP_HASHMIN ? REPO_ADDID_DEP_HASHMIN : size);
          repo->lastidhash = solv_realloc2(repo->lastidhash, repo->lastidhash_mask + 1, sizeof(Id));
index 106f2a53e74da00905c3dc59a7859ad41394b44f..952dbebae836061bc80faa223addfdb6346a0a92 100644 (file)
@@ -41,7 +41,7 @@ typedef struct _Repo {
   Id *idarraydata;             /* array of metadata Ids, solvable dependencies are offsets into this array */
   int idarraysize;
 
-  unsigned nrepodata;          /* number of our stores..  */
+  int nrepodata;               /* number of our stores..  */
 
   Id *rpmdbid;                 /* solvable side data: rpm database id */
 
index 0e8b8541411656f8a9d29a26a3228de98c6bd0f1..86c851ccf5f2864df014fd02fe604afa62321020 100644 (file)
@@ -113,7 +113,7 @@ read_id(Repodata *data, Id max)
       if (!(c & 128))
        {
          x = (x << 7) | c;
-         if (max && x >= max)
+         if (max && x >= (unsigned int)max)
            {
              data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "read_id: id too large (%u/%u)", x, max);
              return 0;
@@ -149,7 +149,7 @@ read_idarray(Repodata *data, Id max, Id *map, Id *store, Id *end)
          continue;
        }
       x = (x << 6) | (c & 63);
-      if (max && x >= max)
+      if (max && x >= (unsigned int)max)
        {
          data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "read_idarray: id too large (%u/%u)", x, max);
          return 0;
@@ -217,7 +217,7 @@ data_read_idarray(unsigned char *dp, Id **storep, Id *map, int max, Repodata *da
          continue;
        }
       x = (x << 6) | (c & 63);
-      if (max && x >= max)
+      if (max && x >= (unsigned int)max)
        {
          data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_idarray: id too large (%u/%u)", x, max);
          data->error = SOLV_ERROR_ID_RANGE;
@@ -261,7 +261,7 @@ data_read_rel_idarray(unsigned char *dp, Id **storep, Id *map, int max, Repodata
        }
       x = old + (x - 1);
       old = x;
-      if (max && x >= max)
+      if (max && x >= (unsigned int)max)
        {
          data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_rel_idarray: id too large (%u/%u)", x, max);
          break;
@@ -360,7 +360,7 @@ incore_add_ideof(Repodata *data, Id sx, int eof)
 static void
 incore_add_blob(Repodata *data, unsigned char *buf, int len)
 {
-  if (data->incoredatafree < len)
+  if (data->incoredatafree < (unsigned int)len)
     {
       data->incoredata = solv_realloc(data->incoredata, data->incoredatalen + INCORE_ADD_CHUNK + len);
       data->incoredatafree = INCORE_ADD_CHUNK + len;
@@ -444,8 +444,8 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
 {
   Pool *pool = repo->pool;
   int i, l;
-  unsigned int numid, numrel, numdir, numsolv;
-  unsigned int numkeys, numschemata;
+  int numid, numrel, numdir, numsolv;
+  int numkeys, numschemata;
 
   Offset sizeid;
   Offset *str;                        /* map Id -> Offset into string space */
@@ -519,16 +519,26 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
         return pool_error(pool, SOLV_ERROR_UNSUPPORTED, "unsupported SOLV version");
     }
 
-  numid = read_u32(&data);
-  numrel = read_u32(&data);
-  numdir = read_u32(&data);
-  numsolv = read_u32(&data);
-  numkeys = read_u32(&data);
-  numschemata = read_u32(&data);
+  numid = (int)read_u32(&data);
+  numrel = (int)read_u32(&data);
+  numdir = (int)read_u32(&data);
+  numsolv = (int)read_u32(&data);
+  numkeys = (int)read_u32(&data);
+  numschemata = (int)read_u32(&data);
   solvflags = read_u32(&data);
 
-  if (numdir && numdir < 2)
+  if (numid < 0 || numid >= 0x20000000)
+    return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of ids");
+  if (numrel < 0 || numrel >= 0x20000000)
+    return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of rels");
+  if (numdir && (numdir < 2 || numdir >= 0x20000000))
     return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of dirs");
+  if (numsolv < 0 || numsolv >= 0x20000000)
+    return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of solvables");
+  if (numkeys < 0 || numkeys >= 0x20000000)
+    return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of keys");
+  if (numschemata < 0 || numschemata >= 0x20000000)
+    return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of schematas");
 
   if (numrel && (flags & REPO_LOCALPOOL) != 0)
     return pool_error(pool, SOLV_ERROR_CORRUPT, "relations are forbidden in a local pool");
index 11002b44d3d368fb83fe64716c5697441a9d75ba..210636c4306b7da598ce4c09b1ca57dfff0caf51 100644 (file)
@@ -1568,7 +1568,7 @@ for (i = 1; i < target.nkeys; i++)
 
   /* remove unused keys */
   keyused = solv_calloc(target.nkeys, sizeof(Id));
-  for (i = 1; i < target.schemadatalen; i++)
+  for (i = 1; i < (int)target.schemadatalen; i++)
     keyused[target.schemadata[i]] = 1;
   keyused[0] = 0;
   for (n = i = 1; i < target.nkeys; i++)
@@ -1592,7 +1592,7 @@ for (i = 1; i < target.nkeys; i++)
     queue_truncate(keyq, 2 * n - 2);
 
   /* update schema data to the new key ids */
-  for (i = 1; i < target.schemadatalen; i++)
+  for (i = 1; i < (int)target.schemadatalen; i++)
     target.schemadata[i] = keyused[target.schemadata[i]];
   /* update keymap to the new key ids */
   for (i = 0; i < cbdata.nkeymap; i++)
index d527a421cc9a910fe4e0a356c35f6bc2b6d3548b..4d577902c11bca92ffbb58d8eaf95b46b875fa7c 100644 (file)
@@ -479,11 +479,11 @@ get_vertical_data(Repodata *data, Repokey *key, Id off, Id len)
   if (off >= data->lastverticaloffset)
     {
       off -= data->lastverticaloffset;
-      if (off + len > data->vincorelen)
+      if ((unsigned int)off + len > data->vincorelen)
        return 0;
       return data->vincore + off;
     }
-  if (off + len > key->size)
+  if ((unsigned int)off + len > key->size)
     return 0;
   /* we now have the offset, go into vertical */
   off += data->verticaloffset[key - data->keys];
@@ -2928,7 +2928,7 @@ compact_attrdata(Repodata *data, int entry, int nentry)
            case REPOKEY_TYPE_STR:
            case REPOKEY_TYPE_BINARY:
            case_CHKSUM_TYPES:
-             if (attrs[1] < attrdatastart)
+             if ((unsigned int)attrs[1] < attrdatastart)
                 attrdatastart = attrs[1];
              break;
            case REPOKEY_TYPE_DIRSTRARRAY:
@@ -2938,7 +2938,7 @@ compact_attrdata(Repodata *data, int entry, int nentry)
              /* FALLTHROUGH */
            case REPOKEY_TYPE_IDARRAY:
            case REPOKEY_TYPE_DIRNUMNUMARRAY:
-             if (attrs[1] < attriddatastart)
+             if ((unsigned int)attrs[1] < attriddatastart)
                attriddatastart = attrs[1];
              break;
            case REPOKEY_TYPE_FIXARRAY:
index 3ad0a800e2f84d36eded68579174576d03bfd356..af43e01d31a1668b3a64bae44db9ee82479ef3f9 100644 (file)
@@ -93,7 +93,7 @@ stringpool_strn2id(Stringpool *ss, const char *str, unsigned int len, int create
   hashtbl = ss->stringhashtbl;
 
   /* expand hashtable if needed */
-  if (ss->nstrings * 2 > hashmask)
+  if ((Hashval)ss->nstrings * 2 > hashmask)
     {
       solv_free(hashtbl);