aboutsummaryrefslogtreecommitdiff
path: root/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/args.cc2
-rw-r--r--src/libutil/args.hh2
-rw-r--r--src/libutil/compression.cc2
-rw-r--r--src/libutil/error.cc16
-rw-r--r--src/libutil/error.hh24
-rw-r--r--src/libutil/hash.cc72
-rw-r--r--src/libutil/hash.hh31
-rw-r--r--src/libutil/logging.cc22
-rw-r--r--src/libutil/logging.hh76
-rw-r--r--src/libutil/tests/hash.cc18
-rw-r--r--src/libutil/tests/logging.cc18
-rw-r--r--src/libutil/util.cc4
12 files changed, 149 insertions, 138 deletions
diff --git a/src/libutil/args.cc b/src/libutil/args.cc
index ce6580119..23e2d6227 100644
--- a/src/libutil/args.cc
+++ b/src/libutil/args.cc
@@ -162,7 +162,7 @@ Args::Flag Args::Flag::mkHashTypeFlag(std::string && longName, HashType * ht)
.labels = {"hash-algo"},
.handler = {[ht](std::string s) {
*ht = parseHashType(s);
- if (*ht == htUnknown)
+ if (*ht == HashType::Unknown)
throw UsageError("unknown hash type '%1%'", s);
}}
};
diff --git a/src/libutil/args.hh b/src/libutil/args.hh
index 154d1e6aa..d0ec4269a 100644
--- a/src/libutil/args.hh
+++ b/src/libutil/args.hh
@@ -10,7 +10,7 @@ namespace nix {
MakeError(UsageError, Error);
-enum HashType : char;
+enum struct HashType : char;
class Args
{
diff --git a/src/libutil/compression.cc b/src/libutil/compression.cc
index a117ddc72..9f270c8f3 100644
--- a/src/libutil/compression.cc
+++ b/src/libutil/compression.cc
@@ -314,7 +314,7 @@ struct XzCompressionSink : CompressionSink
ret = lzma_stream_encoder_mt(&strm, &mt_options);
done = true;
#else
- printMsg(lvlError, "warning: parallel XZ compression requested but not supported, falling back to single-threaded compression");
+ printMsg(Verbosity::Error, "warning: parallel XZ compression requested but not supported, falling back to single-threaded compression");
#endif
}
diff --git a/src/libutil/error.cc b/src/libutil/error.cc
index 0fad9ae42..5c2f9ed3f 100644
--- a/src/libutil/error.cc
+++ b/src/libutil/error.cc
@@ -110,50 +110,50 @@ std::ostream& operator<<(std::ostream &out, const ErrorInfo &einfo)
string levelString;
switch (einfo.level) {
- case Verbosity::lvlError: {
+ case Verbosity::Error: {
levelString = ANSI_RED;
levelString += "error:";
levelString += ANSI_NORMAL;
break;
}
- case Verbosity::lvlWarn: {
+ case Verbosity::Warn: {
levelString = ANSI_YELLOW;
levelString += "warning:";
levelString += ANSI_NORMAL;
break;
}
- case Verbosity::lvlInfo: {
+ case Verbosity::Info: {
levelString = ANSI_GREEN;
levelString += "info:";
levelString += ANSI_NORMAL;
break;
}
- case Verbosity::lvlTalkative: {
+ case Verbosity::Talkative: {
levelString = ANSI_GREEN;
levelString += "talk:";
levelString += ANSI_NORMAL;
break;
}
- case Verbosity::lvlChatty: {
+ case Verbosity::Chatty: {
levelString = ANSI_GREEN;
levelString += "chat:";
levelString += ANSI_NORMAL;
break;
}
- case Verbosity::lvlVomit: {
+ case Verbosity::Vomit: {
levelString = ANSI_GREEN;
levelString += "vomit:";
levelString += ANSI_NORMAL;
break;
}
- case Verbosity::lvlDebug: {
+ case Verbosity::Debug: {
levelString = ANSI_YELLOW;
levelString += "debug:";
levelString += ANSI_NORMAL;
break;
}
default: {
- levelString = fmt("invalid error level: %1%", einfo.level);
+ levelString = fmt("invalid error level: %d", (uint8_t)einfo.level);
break;
}
}
diff --git a/src/libutil/error.hh b/src/libutil/error.hh
index 1e6102ce1..4f9df826f 100644
--- a/src/libutil/error.hh
+++ b/src/libutil/error.hh
@@ -40,15 +40,15 @@ See the error-demo.cc program for usage examples.
*/
-typedef enum {
- lvlError = 0,
- lvlWarn,
- lvlInfo,
- lvlTalkative,
- lvlChatty,
- lvlDebug,
- lvlVomit
-} Verbosity;
+enum struct Verbosity {
+ Error = 0,
+ Warn,
+ Info,
+ Talkative,
+ Chatty,
+ Debug,
+ Vomit,
+};
// ErrPos indicates the location of an error in a nix file.
struct ErrPos {
@@ -113,7 +113,7 @@ public:
template<typename... Args>
BaseError(unsigned int status, const Args & ... args)
- : err { .level = lvlError,
+ : err { .level = Verbosity::Error,
.hint = hintfmt(args...)
}
, status(status)
@@ -121,13 +121,13 @@ public:
template<typename... Args>
BaseError(const std::string & fs, const Args & ... args)
- : err { .level = lvlError,
+ : err { .level = Verbosity::Error,
.hint = hintfmt(fs, args...)
}
{ }
BaseError(hintformat hint)
- : err { .level = lvlError,
+ : err { .level = Verbosity::Error,
.hint = hint
}
{ }
diff --git a/src/libutil/hash.cc b/src/libutil/hash.cc
index 460d479a3..9a4bb4278 100644
--- a/src/libutil/hash.cc
+++ b/src/libutil/hash.cc
@@ -18,10 +18,10 @@ namespace nix {
void Hash::init()
{
- if (type == htMD5) hashSize = md5HashSize;
- else if (type == htSHA1) hashSize = sha1HashSize;
- else if (type == htSHA256) hashSize = sha256HashSize;
- else if (type == htSHA512) hashSize = sha512HashSize;
+ if (type == HashType::MD5) hashSize = md5HashSize;
+ else if (type == HashType::SHA1) hashSize = sha1HashSize;
+ else if (type == HashType::SHA256) hashSize = sha256HashSize;
+ else if (type == HashType::SHA512) hashSize = sha512HashSize;
else abort();
assert(hashSize <= maxHashSize);
memset(hash, 0, maxHashSize);
@@ -98,26 +98,26 @@ static string printHash32(const Hash & hash)
string printHash16or32(const Hash & hash)
{
- return hash.to_string(hash.type == htMD5 ? Base16 : Base32, false);
+ return hash.to_string(hash.type == HashType::MD5 ? Base::Base16 : Base::Base32, false);
}
std::string Hash::to_string(Base base, bool includeType) const
{
std::string s;
- if (base == SRI || includeType) {
+ if (base == Base::SRI || includeType) {
s += printHashType(type);
- s += base == SRI ? '-' : ':';
+ s += base == Base::SRI ? '-' : ':';
}
switch (base) {
- case Base16:
+ case Base::Base16:
s += printHash16(*this);
break;
- case Base32:
+ case Base::Base32:
s += printHash32(*this);
break;
- case Base64:
- case SRI:
+ case Base::Base64:
+ case Base::SRI:
s += base64Encode(std::string((const char *) hash, hashSize));
break;
}
@@ -136,16 +136,16 @@ Hash::Hash(std::string_view s, HashType type)
sep = s.find('-');
if (sep != string::npos) {
isSRI = true;
- } else if (type == htUnknown)
+ } else if (type == HashType::Unknown)
throw BadHash("hash '%s' does not include a type", s);
}
if (sep != string::npos) {
string hts = string(s, 0, sep);
this->type = parseHashType(hts);
- if (this->type == htUnknown)
+ if (this->type == HashType::Unknown)
throw BadHash("unknown hash type '%s'", hts);
- if (type != htUnknown && type != this->type)
+ if (type != HashType::Unknown && type != this->type)
throw BadHash("hash '%s' should have type '%s'", s, printHashType(type));
pos = sep + 1;
}
@@ -209,7 +209,7 @@ Hash newHashAllowEmpty(std::string hashStr, HashType ht)
{
if (hashStr.empty()) {
Hash h(ht);
- warn("found empty hash, assuming '%s'", h.to_string(SRI, true));
+ warn("found empty hash, assuming '%s'", h.to_string(Base::SRI, true));
return h;
} else
return Hash(hashStr, ht);
@@ -227,29 +227,29 @@ union Ctx
static void start(HashType ht, Ctx & ctx)
{
- if (ht == htMD5) MD5_Init(&ctx.md5);
- else if (ht == htSHA1) SHA1_Init(&ctx.sha1);
- else if (ht == htSHA256) SHA256_Init(&ctx.sha256);
- else if (ht == htSHA512) SHA512_Init(&ctx.sha512);
+ if (ht == HashType::MD5) MD5_Init(&ctx.md5);
+ else if (ht == HashType::SHA1) SHA1_Init(&ctx.sha1);
+ else if (ht == HashType::SHA256) SHA256_Init(&ctx.sha256);
+ else if (ht == HashType::SHA512) SHA512_Init(&ctx.sha512);
}
static void update(HashType ht, Ctx & ctx,
const unsigned char * bytes, size_t len)
{
- if (ht == htMD5) MD5_Update(&ctx.md5, bytes, len);
- else if (ht == htSHA1) SHA1_Update(&ctx.sha1, bytes, len);
- else if (ht == htSHA256) SHA256_Update(&ctx.sha256, bytes, len);
- else if (ht == htSHA512) SHA512_Update(&ctx.sha512, bytes, len);
+ if (ht == HashType::MD5) MD5_Update(&ctx.md5, bytes, len);
+ else if (ht == HashType::SHA1) SHA1_Update(&ctx.sha1, bytes, len);
+ else if (ht == HashType::SHA256) SHA256_Update(&ctx.sha256, bytes, len);
+ else if (ht == HashType::SHA512) SHA512_Update(&ctx.sha512, bytes, len);
}
static void finish(HashType ht, Ctx & ctx, unsigned char * hash)
{
- if (ht == htMD5) MD5_Final(hash, &ctx.md5);
- else if (ht == htSHA1) SHA1_Final(hash, &ctx.sha1);
- else if (ht == htSHA256) SHA256_Final(hash, &ctx.sha256);
- else if (ht == htSHA512) SHA512_Final(hash, &ctx.sha512);
+ if (ht == HashType::MD5) MD5_Final(hash, &ctx.md5);
+ else if (ht == HashType::SHA1) SHA1_Final(hash, &ctx.sha1);
+ else if (ht == HashType::SHA256) SHA256_Final(hash, &ctx.sha256);
+ else if (ht == HashType::SHA512) SHA512_Final(hash, &ctx.sha512);
}
@@ -330,20 +330,20 @@ Hash compressHash(const Hash & hash, unsigned int newSize)
HashType parseHashType(const string & s)
{
- if (s == "md5") return htMD5;
- else if (s == "sha1") return htSHA1;
- else if (s == "sha256") return htSHA256;
- else if (s == "sha512") return htSHA512;
- else return htUnknown;
+ if (s == "md5") return HashType::MD5;
+ else if (s == "sha1") return HashType::SHA1;
+ else if (s == "sha256") return HashType::SHA256;
+ else if (s == "sha512") return HashType::SHA512;
+ else return HashType::Unknown;
}
string printHashType(HashType ht)
{
- if (ht == htMD5) return "md5";
- else if (ht == htSHA1) return "sha1";
- else if (ht == htSHA256) return "sha256";
- else if (ht == htSHA512) return "sha512";
+ if (ht == HashType::MD5) return "md5";
+ else if (ht == HashType::SHA1) return "sha1";
+ else if (ht == HashType::SHA256) return "sha256";
+ else if (ht == HashType::SHA512) return "sha512";
else abort();
}
diff --git a/src/libutil/hash.hh b/src/libutil/hash.hh
index 180fb7633..e87595f6d 100644
--- a/src/libutil/hash.hh
+++ b/src/libutil/hash.hh
@@ -10,7 +10,13 @@ namespace nix {
MakeError(BadHash, Error);
-enum HashType : char { htUnknown, htMD5, htSHA1, htSHA256, htSHA512 };
+enum struct HashType : char {
+ Unknown,
+ MD5,
+ SHA1,
+ SHA256,
+ SHA512,
+};
const int md5HashSize = 16;
@@ -20,7 +26,12 @@ const int sha512HashSize = 64;
extern const string base32Chars;
-enum Base : int { Base64, Base32, Base16, SRI };
+enum struct Base {
+ Base64,
+ Base32,
+ Base16,
+ SRI,
+};
struct Hash
@@ -29,7 +40,7 @@ struct Hash
unsigned int hashSize = 0;
unsigned char hash[maxHashSize] = {};
- HashType type = htUnknown;
+ HashType type = HashType::Unknown;
/* Create an unset hash object. */
Hash() { };
@@ -40,14 +51,14 @@ struct Hash
/* Initialize the hash from a string representation, in the format
"[<type>:]<base16|base32|base64>" or "<type>-<base64>" (a
Subresource Integrity hash expression). If the 'type' argument
- is htUnknown, then the hash type must be specified in the
+ is HashType::Unknown, then the hash type must be specified in the
string. */
- Hash(std::string_view s, HashType type = htUnknown);
+ Hash(std::string_view s, HashType type = HashType::Unknown);
void init();
/* Check whether a hash is set. */
- operator bool () const { return type != htUnknown; }
+ operator bool () const { return type != HashType::Unknown; }
/* Check whether two hash are equal. */
bool operator == (const Hash & h2) const;
@@ -83,14 +94,14 @@ struct Hash
std::string gitRev() const
{
- assert(type == htSHA1);
- return to_string(Base16, false);
+ assert(type == HashType::SHA1);
+ return to_string(Base::Base16, false);
}
std::string gitShortRev() const
{
- assert(type == htSHA1);
- return std::string(to_string(Base16, false), 0, 7);
+ assert(type == HashType::SHA1);
+ return std::string(to_string(Base::Base16, false), 0, 7);
}
};
diff --git a/src/libutil/logging.cc b/src/libutil/logging.cc
index 105fadb15..04156151f 100644
--- a/src/libutil/logging.cc
+++ b/src/libutil/logging.cc
@@ -22,7 +22,7 @@ Logger * logger = makeSimpleLogger(true);
void Logger::warn(const std::string & msg)
{
- log(lvlWarn, ANSI_YELLOW "warning:" ANSI_NORMAL " " + msg);
+ log(Verbosity::Warn, ANSI_YELLOW "warning:" ANSI_NORMAL " " + msg);
}
void Logger::writeToStdout(std::string_view s)
@@ -57,10 +57,10 @@ public:
if (systemd) {
char c;
switch (lvl) {
- case lvlError: c = '3'; break;
- case lvlWarn: c = '4'; break;
- case lvlInfo: c = '5'; break;
- case lvlTalkative: case lvlChatty: c = '6'; break;
+ case Verbosity::Error: c = '3'; break;
+ case Verbosity::Warn: c = '4'; break;
+ case Verbosity::Info: c = '5'; break;
+ case Verbosity::Talkative: case Verbosity::Chatty: c = '6'; break;
default: c = '7';
}
prefix = std::string("<") + c + ">";
@@ -87,18 +87,18 @@ public:
void result(ActivityId act, ResultType type, const Fields & fields) override
{
- if (type == resBuildLogLine && printBuildLogs) {
+ if (type == ResultType::BuildLogLine && printBuildLogs) {
auto lastLine = fields[0].s;
printError(lastLine);
}
- else if (type == resPostBuildLogLine && printBuildLogs) {
+ else if (type == ResultType::PostBuildLogLine && printBuildLogs) {
auto lastLine = fields[0].s;
printError("post-build-hook: " + lastLine);
}
}
};
-Verbosity verbosity = lvlInfo;
+Verbosity verbosity = Verbosity::Info;
void warnOnce(bool & haveWarned, const FormatOrString & fs)
{
@@ -158,7 +158,7 @@ struct JSONLogger : Logger {
void write(const nlohmann::json & json)
{
- prevLogger.log(lvlError, "@nix " + json.dump());
+ prevLogger.log(Verbosity::Error, "@nix " + json.dump());
}
void log(Verbosity lvl, const FormatOrString & fs) override
@@ -246,7 +246,7 @@ bool handleJSONLogMessage(const std::string & msg,
if (action == "start") {
auto type = (ActivityType) json["type"];
- if (trusted || type == actFileTransfer)
+ if (trusted || type == ActivityType::Download)
activities.emplace(std::piecewise_construct,
std::forward_as_tuple(json["id"]),
std::forward_as_tuple(*logger, (Verbosity) json["level"], type,
@@ -264,7 +264,7 @@ bool handleJSONLogMessage(const std::string & msg,
else if (action == "setPhase") {
std::string phase = json["phase"];
- act.result(resSetPhase, phase);
+ act.result(ResultType::SetPhase, phase);
}
else if (action == "msg") {
diff --git a/src/libutil/logging.hh b/src/libutil/logging.hh
index b1583eced..3b54101f0 100644
--- a/src/libutil/logging.hh
+++ b/src/libutil/logging.hh
@@ -5,32 +5,32 @@
namespace nix {
-typedef enum {
- actUnknown = 0,
- actCopyPath = 100,
- actFileTransfer = 101,
- actRealise = 102,
- actCopyPaths = 103,
- actBuilds = 104,
- actBuild = 105,
- actOptimiseStore = 106,
- actVerifyPaths = 107,
- actSubstitute = 108,
- actQueryPathInfo = 109,
- actPostBuildHook = 110,
- actBuildWaiting = 111,
-} ActivityType;
-
-typedef enum {
- resFileLinked = 100,
- resBuildLogLine = 101,
- resUntrustedPath = 102,
- resCorruptedPath = 103,
- resSetPhase = 104,
- resProgress = 105,
- resSetExpected = 106,
- resPostBuildLogLine = 107,
-} ResultType;
+enum struct ActivityType {
+ Unknown = 0,
+ CopyPath = 100,
+ Download = 101,
+ Realise = 102,
+ CopyPaths = 103,
+ Builds = 104,
+ Build = 105,
+ OptimiseStore = 106,
+ VerifyPaths = 107,
+ Substitute = 108,
+ QueryPathInfo = 109,
+ PostBuildHook = 110,
+ BuildWaiting = 111,
+};
+
+enum struct ResultType {
+ FileLinked = 100,
+ BuildLogLine = 101,
+ UntrustedPath = 102,
+ CorruptedPath = 103,
+ SetPhase = 104,
+ Progress = 105,
+ SetExpected = 106,
+ PostBuildLogLine = 107,
+};
typedef uint64_t ActivityId;
@@ -64,7 +64,7 @@ public:
void log(const FormatOrString & fs)
{
- log(lvlInfo, fs);
+ log(Verbosity::Info, fs);
}
virtual void logEI(const ErrorInfo &ei) = 0;
@@ -109,17 +109,17 @@ struct Activity
Activity(Logger & logger, ActivityType type,
const Logger::Fields & fields = {}, ActivityId parent = getCurActivity())
- : Activity(logger, lvlError, type, "", fields, parent) { };
+ : Activity(logger, Verbosity::Error, type, "", fields, parent) { };
Activity(const Activity & act) = delete;
~Activity();
void progress(uint64_t done = 0, uint64_t expected = 0, uint64_t running = 0, uint64_t failed = 0) const
- { result(resProgress, done, expected, running, failed); }
+ { result(ResultType::Progress, done, expected, running, failed); }
void setExpected(ActivityType type2, uint64_t expected) const
- { result(resSetExpected, type2, expected); }
+ { result(ResultType::SetExpected, (uint64_t)type2, expected); }
template<typename... Args>
void result(ResultType type, const Args & ... args) const
@@ -167,8 +167,8 @@ extern Verbosity verbosity; /* suppress msgs > this */
} \
} while (0)
-#define logError(errorInfo...) logErrorInfo(lvlError, errorInfo)
-#define logWarning(errorInfo...) logErrorInfo(lvlWarn, errorInfo)
+#define logError(errorInfo...) logErrorInfo(Verbosity::Error, errorInfo)
+#define logWarning(errorInfo...) logErrorInfo(Verbosity::Warn, errorInfo)
/* Print a string message if the current log level is at least the specified
level. Note that this has to be implemented as a macro to ensure that the
@@ -180,13 +180,13 @@ extern Verbosity verbosity; /* suppress msgs > this */
} \
} while (0)
-#define printError(args...) printMsg(lvlError, args)
-#define printInfo(args...) printMsg(lvlInfo, args)
-#define printTalkative(args...) printMsg(lvlTalkative, args)
-#define debug(args...) printMsg(lvlDebug, args)
-#define vomit(args...) printMsg(lvlVomit, args)
+#define printError(args...) printMsg(Verbosity::Error, args)
+#define printInfo(args...) printMsg(Verbosity::Info, args)
+#define printTalkative(args...) printMsg(Verbosity::Talkative, args)
+#define debug(args...) printMsg(Verbosity::Debug, args)
+#define vomit(args...) printMsg(Verbosity::Vomit, args)
-/* if verbosity >= lvlWarn, print a message with a yellow 'warning:' prefix. */
+/* if verbosity >= Verbosity::Warn, print a message with a yellow 'warning:' prefix. */
template<typename... Args>
inline void warn(const std::string & fs, const Args & ... args)
{
diff --git a/src/libutil/tests/hash.cc b/src/libutil/tests/hash.cc
index 5334b046e..f9ab9fef3 100644
--- a/src/libutil/tests/hash.cc
+++ b/src/libutil/tests/hash.cc
@@ -10,28 +10,28 @@ namespace nix {
TEST(hashString, testKnownMD5Hashes1) {
// values taken from: https://tools.ietf.org/html/rfc1321
auto s1 = "";
- auto hash = hashString(HashType::htMD5, s1);
+ auto hash = hashString(HashType::MD5, s1);
ASSERT_EQ(hash.to_string(Base::Base16, true), "md5:d41d8cd98f00b204e9800998ecf8427e");
}
TEST(hashString, testKnownMD5Hashes2) {
// values taken from: https://tools.ietf.org/html/rfc1321
auto s2 = "abc";
- auto hash = hashString(HashType::htMD5, s2);
+ auto hash = hashString(HashType::MD5, s2);
ASSERT_EQ(hash.to_string(Base::Base16, true), "md5:900150983cd24fb0d6963f7d28e17f72");
}
TEST(hashString, testKnownSHA1Hashes1) {
// values taken from: https://tools.ietf.org/html/rfc3174
auto s = "abc";
- auto hash = hashString(HashType::htSHA1, s);
+ auto hash = hashString(HashType::SHA1, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),"sha1:a9993e364706816aba3e25717850c26c9cd0d89d");
}
TEST(hashString, testKnownSHA1Hashes2) {
// values taken from: https://tools.ietf.org/html/rfc3174
auto s = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
- auto hash = hashString(HashType::htSHA1, s);
+ auto hash = hashString(HashType::SHA1, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),"sha1:84983e441c3bd26ebaae4aa1f95129e5e54670f1");
}
@@ -39,7 +39,7 @@ namespace nix {
// values taken from: https://tools.ietf.org/html/rfc4634
auto s = "abc";
- auto hash = hashString(HashType::htSHA256, s);
+ auto hash = hashString(HashType::SHA256, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),
"sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
}
@@ -47,7 +47,7 @@ namespace nix {
TEST(hashString, testKnownSHA256Hashes2) {
// values taken from: https://tools.ietf.org/html/rfc4634
auto s = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
- auto hash = hashString(HashType::htSHA256, s);
+ auto hash = hashString(HashType::SHA256, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),
"sha256:248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
}
@@ -55,7 +55,7 @@ namespace nix {
TEST(hashString, testKnownSHA512Hashes1) {
// values taken from: https://tools.ietf.org/html/rfc4634
auto s = "abc";
- auto hash = hashString(HashType::htSHA512, s);
+ auto hash = hashString(HashType::SHA512, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),
"sha512:ddaf35a193617abacc417349ae20413112e6fa4e89a9"
"7ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd"
@@ -66,7 +66,7 @@ namespace nix {
// values taken from: https://tools.ietf.org/html/rfc4634
auto s = "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu";
- auto hash = hashString(HashType::htSHA512, s);
+ auto hash = hashString(HashType::SHA512, s);
ASSERT_EQ(hash.to_string(Base::Base16, true),
"sha512:8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa1"
"7299aeadb6889018501d289e4900f7e4331b99dec4b5433a"
@@ -75,6 +75,6 @@ namespace nix {
TEST(hashString, hashingWithUnknownAlgoExits) {
auto s = "unknown";
- ASSERT_DEATH(hashString(HashType::htUnknown, s), "");
+ ASSERT_DEATH(hashString(HashType::Unknown, s), "");
}
}
diff --git a/src/libutil/tests/logging.cc b/src/libutil/tests/logging.cc
index 4cb54995b..2ffcbc41d 100644
--- a/src/libutil/tests/logging.cc
+++ b/src/libutil/tests/logging.cc
@@ -68,7 +68,7 @@ namespace nix {
TEST(logEI, loggingErrorOnInfoLevel) {
testing::internal::CaptureStderr();
- logger->logEI({ .level = lvlInfo,
+ logger->logEI({ .level = Verbosity::Info,
.name = "Info name",
.description = "Info description",
});
@@ -78,11 +78,11 @@ namespace nix {
}
TEST(logEI, loggingErrorOnTalkativeLevel) {
- verbosity = lvlTalkative;
+ verbosity = Verbosity::Talkative;
testing::internal::CaptureStderr();
- logger->logEI({ .level = lvlTalkative,
+ logger->logEI({ .level = Verbosity::Talkative,
.name = "Talkative name",
.description = "Talkative description",
});
@@ -92,11 +92,11 @@ namespace nix {
}
TEST(logEI, loggingErrorOnChattyLevel) {
- verbosity = lvlChatty;
+ verbosity = Verbosity::Chatty;
testing::internal::CaptureStderr();
- logger->logEI({ .level = lvlChatty,
+ logger->logEI({ .level = Verbosity::Chatty,
.name = "Chatty name",
.description = "Talkative description",
});
@@ -106,11 +106,11 @@ namespace nix {
}
TEST(logEI, loggingErrorOnDebugLevel) {
- verbosity = lvlDebug;
+ verbosity = Verbosity::Debug;
testing::internal::CaptureStderr();
- logger->logEI({ .level = lvlDebug,
+ logger->logEI({ .level = Verbosity::Debug,
.name = "Debug name",
.description = "Debug description",
});
@@ -120,11 +120,11 @@ namespace nix {
}
TEST(logEI, loggingErrorOnVomitLevel) {
- verbosity = lvlVomit;
+ verbosity = Verbosity::Vomit;
testing::internal::CaptureStderr();
- logger->logEI({ .level = lvlVomit,
+ logger->logEI({ .level = Verbosity::Vomit,
.name = "Vomit name",
.description = "Vomit description",
});
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 1268b146a..e912d4450 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -442,7 +442,7 @@ void deletePath(const Path & path)
void deletePath(const Path & path, unsigned long long & bytesFreed)
{
- //Activity act(*logger, lvlDebug, format("recursively deleting path '%1%'") % path);
+ //Activity act(*logger, Verbosity::Debug, format("recursively deleting path '%1%'") % path);
bytesFreed = 0;
_deletePath(path, bytesFreed);
}
@@ -1433,7 +1433,7 @@ string base64Decode(std::string_view s)
char digit = decode[(unsigned char) c];
if (digit == -1)
- throw Error("invalid character in Base64 string");
+ throw Error("invalid character in Base::Base64 string");
bits += 6;
d = d << 6 | digit;