1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-02 05:11:47 +02:00

Fix some random -Wconversion warnings

This commit is contained in:
Eelco Dolstra 2018-05-02 13:56:34 +02:00
parent 548ad391d9
commit 53ec5ac69f
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
16 changed files with 82 additions and 80 deletions

View file

@ -82,7 +82,7 @@ static string printHash32(const Hash & hash)
string s;
s.reserve(len);
for (int n = len - 1; n >= 0; n--) {
for (int n = (int) len - 1; n >= 0; n--) {
unsigned int b = n * 5;
unsigned int i = b / 8;
unsigned int j = b % 8;

View file

@ -227,7 +227,7 @@ inline Sink & operator << (Sink & sink, uint64_t n)
buf[4] = (n >> 32) & 0xff;
buf[5] = (n >> 40) & 0xff;
buf[6] = (n >> 48) & 0xff;
buf[7] = (n >> 56) & 0xff;
buf[7] = (unsigned char) (n >> 56) & 0xff;
sink(buf, sizeof(buf));
return sink;
}
@ -259,7 +259,7 @@ T readNum(Source & source)
if (n > std::numeric_limits<T>::max())
throw SerialisationError("serialised integer %d is too large for type '%s'", n, typeid(T).name());
return n;
return (T) n;
}

View file

@ -28,7 +28,7 @@ void XMLWriter::close()
}
void XMLWriter::indent_(unsigned int depth)
void XMLWriter::indent_(size_t depth)
{
if (!indent) return;
output << string(depth * 2, ' ');
@ -75,7 +75,7 @@ void XMLWriter::writeAttrs(const XMLAttrs & attrs)
{
for (auto & i : attrs) {
output << " " << i.first << "=\"";
for (unsigned int j = 0; j < i.second.size(); ++j) {
for (size_t j = 0; j < i.second.size(); ++j) {
char c = i.second[j];
if (c == '"') output << "&quot;";
else if (c == '<') output << "&lt;";

View file

@ -44,7 +44,7 @@ public:
private:
void writeAttrs(const XMLAttrs & attrs);
void indent_(unsigned int depth);
void indent_(size_t depth);
};