]> git.saurik.com Git - apt.git/blobdiff - ftparchive/cachedb.cc
fix compiler warning about signed comparision on amd64, too
[apt.git] / ftparchive / cachedb.cc
index 7d8718c563d6c5892fe26e8525045c1a9379afde..f0bfa2a6d613cc4ae54c47a5c0e7ba80c79c54a3 100644 (file)
@@ -18,6 +18,7 @@
 #include <apt-pkg/sha2.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/configuration.h>
+#include <apt-pkg/fileutl.h>
     
 #include <netinet/in.h>       // htonl, etc
 
@@ -299,11 +300,15 @@ bool CacheDB::LoadContents(bool const &GenOnly)
                                                                        /*}}}*/
 
 static std::string bytes2hex(uint8_t *bytes, size_t length) {
-   char space[65];
-   if (length * 2 > sizeof(space) - 1) length = (sizeof(space) - 1) / 2;
-   for (size_t i = 0; i < length; i++)
-      snprintf(&space[i*2], 3, "%02x", bytes[i]);
-   return std::string(space);
+   char buf[3];
+   std::string space;
+
+   space.reserve(length*2 + 1);
+   for (size_t i = 0; i < length; i++) {
+      snprintf(buf, sizeof(buf), "%02x", bytes[i]);
+      space.append(buf);
+   }
+   return space;
 }
 
 static inline unsigned char xdig2num(char const &dig) {