aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-27 17:56:47 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-10-27 17:56:47 +0100
commit91287bb8407e3b9022bc663b07870510aedabbc3 (patch)
tree36fe3e2615d6d2dde4cd3eb3d8f382ac3d7dd2aa
parent939cec679d83d4d1133e358d0377c1d57dde1d82 (diff)
downloadrspamd-91287bb8407e3b9022bc663b07870510aedabbc3.tar.gz
rspamd-91287bb8407e3b9022bc663b07870510aedabbc3.zip
[Fix] Remove ambigious format flag from printf
-rw-r--r--clang-plugin/printf_check.cc14
-rw-r--r--src/libserver/cfg_rcl.c6
-rw-r--r--src/libutil/printf.c7
-rw-r--r--src/libutil/printf.h1
-rw-r--r--src/rspamadm/configdump.c4
5 files changed, 7 insertions, 25 deletions
diff --git a/clang-plugin/printf_check.cc b/clang-plugin/printf_check.cc
index 9b4819d08..f8a78aa0b 100644
--- a/clang-plugin/printf_check.cc
+++ b/clang-plugin/printf_check.cc
@@ -187,9 +187,6 @@ namespace rspamd {
case 'D':
return llvm::make_unique<PrintfArgChecker> (int32_arg_handler,
this->pcontext, this->ci);
- case 'B':
- return llvm::make_unique<PrintfArgChecker> (gboolean_arg_handler,
- this->pcontext, this->ci);
case 'T':
return llvm::make_unique<PrintfArgChecker> (tok_arg_handler,
this->pcontext, this->ci);
@@ -369,7 +366,7 @@ namespace rspamd {
format_specs = {
's', 'd', 'l', 'L', 'v', 'V', 'f', 'F', 'g', 'G',
- 'T', 'z', 'D', 'c', 'p', 'P', 'e', 'B'
+ 'T', 'z', 'D', 'c', 'p', 'P', 'e'
};
};
@@ -720,15 +717,6 @@ namespace rspamd {
}
static bool
- gboolean_arg_handler (const Expr *arg, struct PrintfArgChecker *ctx)
- {
- return check_builtin_type (arg,
- ctx,
- {BuiltinType::Kind::Int}, // gboolean is int in fact
- "%b");
- }
-
- static bool
check_struct_type (const Expr *arg, struct PrintfArgChecker *ctx,
const std::string &sname, const std::string &fmt)
{
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 8d18335d2..a96cd6b67 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -2509,7 +2509,8 @@ rspamd_rcl_parse_struct_string (rspamd_mempool_t *pool,
break;
case UCL_BOOLEAN:
*target = rspamd_mempool_alloc (pool, num_str_len);
- rspamd_snprintf (*target, num_str_len, "%B", (gboolean)obj->value.iv);
+ rspamd_snprintf (*target, num_str_len, "%s",
+ ((gboolean)obj->value.iv) ? "true" : "false");
break;
default:
g_set_error (err,
@@ -2869,7 +2870,8 @@ rspamd_rcl_parse_struct_string_list (rspamd_mempool_t *pool,
break;
case UCL_BOOLEAN:
val = rspamd_mempool_alloc (pool, num_str_len);
- rspamd_snprintf (val, num_str_len, "%B", (gboolean)cur->value.iv);
+ rspamd_snprintf (val, num_str_len, "%s",
+ ((gboolean)cur->value.iv) ? "true" : "false");
break;
default:
g_set_error (err,
diff --git a/src/libutil/printf.c b/src/libutil/printf.c
index 7ee4d35e6..148b49d9e 100644
--- a/src/libutil/printf.c
+++ b/src/libutil/printf.c
@@ -602,7 +602,6 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
rspamd_ftok_t *tok;
GString *gs;
GError *err;
- gboolean bv;
while (*fmt) {
@@ -969,12 +968,6 @@ rspamd_vprintf_common (rspamd_printf_append_func func,
continue;
- case 'B':
- bv = (gboolean) va_arg (args, double);
- RSPAMD_PRINTF_APPEND (bv ? "true" : "false", bv ? 4 : 5);
-
- continue;
-
case 'p':
ui64 = (uintptr_t) va_arg (args, void *);
hex = 2;
diff --git a/src/libutil/printf.h b/src/libutil/printf.h
index 73787d3a5..86947f67c 100644
--- a/src/libutil/printf.h
+++ b/src/libutil/printf.h
@@ -32,7 +32,6 @@
* %[0][width][.width]F long double
* %[0][width][.width]g double
* %[0][width][.width]G long double
- * %B boolean (true or false)
* %P pid_t
* %r rlim_t
* %p void *
diff --git a/src/rspamadm/configdump.c b/src/rspamadm/configdump.c
index 962089437..cf08ceac0 100644
--- a/src/rspamadm/configdump.c
+++ b/src/rspamadm/configdump.c
@@ -143,8 +143,8 @@ rspamadm_add_doc_elt (const ucl_object_t *obj, const ucl_object_t *doc_obj,
elt = ucl_object_lookup (doc_obj, "required");
if (elt) {
- rspamd_printf_fstring (&comment, " * Required: %B",
- ucl_object_toboolean (elt));
+ rspamd_printf_fstring (&comment, " * Required: %s",
+ ucl_object_toboolean (elt) ? "true" : "false");
cur_comment = ucl_object_fromstring_common (comment->str, comment->len, 0);
rspamd_fstring_erase (comment, 0, comment->len);
DL_APPEND (nobj, cur_comment);