]> git.e2factory.org Git - e2factory.git/commitdiff
e2lib: misuse of warnf() should trigger an assertion
authorTobias Ulmer <tu@emlix.com>
Tue, 9 Apr 2019 14:01:27 +0000 (16:01 +0200)
committerTobias Ulmer <tu@emlix.com>
Tue, 9 Apr 2019 14:01:27 +0000 (16:01 +0200)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2lib.lua

index 5b0c8316f8fc3bc3cd5c980bbcd57057577a19e7..d634ee2c79817748d2b32e79bbf5f284d81c1607 100644 (file)
@@ -686,13 +686,11 @@ end
 -- @param ... arguments required for the format string
 -- @return nil
 function e2lib.warnf(category, format, ...)
-    if (format:len() == 0) or (not format) then
-        e2lib.log(1, "Internal error: calling warnf() with zero length format")
-    end
-    if type(e2lib.globals.warn_category[category]) ~= "boolean" then
-        e2lib.log(1,
-            "Internal error: calling warnf() with invalid warning category")
-    end
+    assertIsStringN(format,
+        "Internal error: called warnf() with invalid format")
+    assertIsBoolean(e2lib.globals.warn_category[category],
+        "Internal error: called warnf() with invalid warning category")
+
     if e2lib.globals.warn_category[category] == true then
         local prefix = "Warning: "
         if e2lib.globals.log_debug then